Skip to contentSkip to conversation

cbs: send topics one by one for ZTE modem.

PATCH In review Bertrand Aygon 3 participants 7 messages Aug 1, 2011

lore
Share & tools
lore
#0 lore raw

cover cbs: send topics one by one for ZTE modem.

Some ZTE modem don't support sending a long AT command.
So instead of sending all the CBS topics in one command, we send them one by one.

Bertrand Aygon (2):
cbs: send topics one by one for ZTE modem.
zte: specify the vendor to send cbs topics one by one.

 drivers/atmodem/cbs.c |   58 ++++++++++++++++++++++++++++++++++++++++++------
 plugins/zte.c         |    2 +-
 2 files changed, 51 insertions(+), 9 deletions(-)
Signature · 13 lines
1.7.4.1

---------------------------------------------------------------------
Intel Corporation SAS (French simplified joint stock company)
Registered headquarters: "Les Montalets"- 2, rue de Paris, 
92196 Meudon Cedex, France
Registration Number:  302 456 199 R.C.S. NANTERRE
Capital: 4,572,000 Euros

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.
#1 lore raw

PATCH 1/2 cbs: send topics one by one for ZTE modem.

---
 drivers/atmodem/cbs.c |   58 ++++++++++++++++++++++++++++++++++++++++++------
 1 files changed, 50 insertions(+), 8 deletions(-)
drivers/atmodem/cbs.c +50 -8
index e2e1ca4..4673a77 100644
@@ -109,9 +109,9 @@ static void at_cbs_set_topics(struct ofono_cbs *cbs, const char *topics,
 				ofono_cbs_set_cb_t cb, void *user_data)
 {
 	struct cbs_data *data = ofono_cbs_get_data(cbs);
-	struct cb_data *cbd = cb_data_new(cb, user_data);
 	char *buf;
-	unsigned int id;
+	unsigned int id = 0;
+	gboolean send_by_one = FALSE;
 
 	DBG("");
 
@@ -125,6 +125,7 @@ static void at_cbs_set_topics(struct ofono_cbs *cbs, const char *topics,
 	switch (data->vendor) {
 	case OFONO_VENDOR_GOBI:
 	case OFONO_VENDOR_QUALCOMM_MSM:
+	case OFONO_VENDOR_ZTE:
 		g_at_chat_send(data->chat, "AT+CSCB=1", none_prefix,
 				NULL, NULL, NULL);
 		break;
@@ -132,17 +133,58 @@ static void at_cbs_set_topics(struct ofono_cbs *cbs, const char *topics,
 		break;
 	}
 
-	buf = g_strdup_printf("AT+CSCB=0,\"%s\"", topics);
+	/* Some ZTE modem doesn't support sending a long AT command
+	 * so we send topics one by one
+	 */
+	switch (data->vendor) {
+	case OFONO_VENDOR_ZTE:
+		send_by_one = TRUE;
+		break;
+	default:
+		break;
+	}
+
+	if (send_by_one) {
+		gchar **topic_list = NULL;
+		gchar **topic_list_orig = NULL;
+
+		topic_list = topic_list_orig = g_strsplit_set(topics, ",", -1);
+
+		for (; *topic_list; topic_list++) {
+			struct cb_data *cbd = cb_data_new(cb, user_data);
+
+			buf = g_strdup_printf("AT+CSCB=0,\"%s\"", *topic_list);
 
-	id = g_at_chat_send(data->chat, buf, none_prefix,
+			id = g_at_chat_send(data->chat, buf, none_prefix,
 				at_cscb_set_cb, cbd, g_free);
 
-	g_free(buf);
+			g_free(buf);
 
-	if (id > 0)
-		return;
+			if (id > 0)
+				continue;
 
-	g_free(cbd);
+			g_free(cbd);
+		}
+
+		g_strfreev(topic_list_orig);
+
+		if (id > 0)
+			return;
+	} else {
+		struct cb_data *cbd = cb_data_new(cb, user_data);
+
+		buf = g_strdup_printf("AT+CSCB=0,\"%s\"", topics);
+
+		id = g_at_chat_send(data->chat, buf, none_prefix,
+				at_cscb_set_cb, cbd, g_free);
+
+		g_free(buf);
+
+		if (id > 0)
+			return;
+
+		g_free(cbd);
+	}
 
 	CALLBACK_WITH_FAILURE(cb, user_data);
 }
Signature · 13 lines
1.7.4.1

---------------------------------------------------------------------
Intel Corporation SAS (French simplified joint stock company)
Registered headquarters: "Les Montalets"- 2, rue de Paris, 
92196 Meudon Cedex, France
Registration Number:  302 456 199 R.C.S. NANTERRE
Capital: 4,572,000 Euros

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.
#2 lore raw

Hi Bertrand,

Quoted 32 lines
 drivers/atmodem/cbs.c |   58 ++++++++++++++++++++++++++++++++++++++++++------
 1 files changed, 50 insertions(+), 8 deletions(-)
drivers/atmodem/cbs.c +3 -3
index e2e1ca4..4673a77 100644
@@ -109,9 +109,9 @@ static void at_cbs_set_topics(struct ofono_cbs *cbs, const char *topics,
 				ofono_cbs_set_cb_t cb, void *user_data)
 {
 	struct cbs_data *data = ofono_cbs_get_data(cbs);
-	struct cb_data *cbd = cb_data_new(cb, user_data);
 	char *buf;
-	unsigned int id;
+	unsigned int id = 0;
+	gboolean send_by_one = FALSE;
 
 	DBG("");
 
@@ -125,6 +125,7 @@ static void at_cbs_set_topics(struct ofono_cbs *cbs, const char *topics,
 	switch (data->vendor) {
 	case OFONO_VENDOR_GOBI:
 	case OFONO_VENDOR_QUALCOMM_MSM:
+	case OFONO_VENDOR_ZTE:
 		g_at_chat_send(data->chat, "AT+CSCB=1", none_prefix,
 				NULL, NULL, NULL);
 		break;
@@ -132,17 +133,58 @@ static void at_cbs_set_topics(struct ofono_cbs *cbs, const char *topics,
 		break;
 	}
 
-	buf = g_strdup_printf("AT+CSCB=0,\"%s\"", topics);

drivers/atmodem/cbs.c static void at_cbs_set_topics(struct ofono_cbs *cbs, const char *topics, · line 145

Quoted 10 lines
drivers/atmodem/cbs.c +10 -0
+	/* Some ZTE modem doesn't support sending a long AT command
+	 * so we send topics one by one
+	 */
+	switch (data->vendor) {
+	case OFONO_VENDOR_ZTE:
+		send_by_one = TRUE;
+		break;
+	default:
+		break;
+	}

so we already have a vendor switch statement a few lines above. Why bother introducing another one here?

Quoted 5 lines
drivers/atmodem/cbs.c +5 -0
+
+	if (send_by_one) {
+		gchar **topic_list = NULL;
+		gchar **topic_list_orig = NULL;
+

drivers/atmodem/cbs.c static void at_cbs_set_topics(struct ofono_cbs *cbs, const char *topics, · line 159

Quoted 10 lines
drivers/atmodem/cbs.c +7 -1
+		topic_list = topic_list_orig = g_strsplit_set(topics, ",", -1);
+
+		for (; *topic_list; topic_list++) {
+			struct cb_data *cbd = cb_data_new(cb, user_data);
+
+			buf = g_strdup_printf("AT+CSCB=0,\"%s\"", *topic_list);
 
-	id = g_at_chat_send(data->chat, buf, none_prefix,
+			id = g_at_chat_send(data->chat, buf, none_prefix,
 				at_cscb_set_cb, cbd, g_free);

So this is not going to work out as nicely as you might think it would. You keep calling ofono_cbs_set_cb_t callback now for every single topic you send. And also as a result, the D-Bus call returns successful after the first one.

You need to properly queue this and properly fail and roll back in case of a failure.

I addition to that, I would prefer to send as many topics at once as possible. So how many can ZTE set at once?

Regards

Marcel

#3 lore raw

Hi Marcel,

Quoted 35 lines
Quoted 1 line
 drivers/atmodem/cbs.c |   58 ++++++++++++++++++++++++++++++++++++++++++----

--

drivers/atmodem/cbs.c static void at_cbs_set_topics(struct ofono_cbs *cbs,

Quoted 7 lines
 1 files changed, 50 insertions(+), 8 deletions(-)
drivers/atmodem/cbs.c +0 -0
index e2e1ca4..4673a77 100644
@@ -109,9 +109,9 @@ static void at_cbs_set_topics(struct ofono_cbs *cbs,

const char *topics,

drivers/atmodem/cbs.c static void at_cbs_set_topics(struct ofono_cbs *cbs,

Quoted 12 lines
drivers/atmodem/cbs.c +2 -2
 				ofono_cbs_set_cb_t cb, void *user_data)
 {
 	struct cbs_data *data = ofono_cbs_get_data(cbs);
-	struct cb_data *cbd = cb_data_new(cb, user_data);
 	char *buf;
-	unsigned int id;
+	unsigned int id = 0;
+	gboolean send_by_one = FALSE;
 
 	DBG("");
 
@@ -125,6 +125,7 @@ static void at_cbs_set_topics(struct ofono_cbs *cbs,

const char *topics,

drivers/atmodem/cbs.c static void at_cbs_set_topics(struct ofono_cbs *cbs,

Quoted 8 lines
drivers/atmodem/cbs.c +1 -0
 	switch (data->vendor) {
 	case OFONO_VENDOR_GOBI:
 	case OFONO_VENDOR_QUALCOMM_MSM:
+	case OFONO_VENDOR_ZTE:
 		g_at_chat_send(data->chat, "AT+CSCB=1", none_prefix,
 				NULL, NULL, NULL);
 		break;
@@ -132,17 +133,58 @@ static void at_cbs_set_topics(struct ofono_cbs *cbs,

const char *topics,

Quoted 3 lines
drivers/atmodem/cbs.c +0 -0
 		break;
 	}
 
Quoted 14 lines

drivers/atmodem/cbs.c static void at_cbs_set_topics(struct ofono_cbs *cbs, const char *topics, · line 145

Quoted 11 lines
drivers/atmodem/cbs.c +10 -1
-	buf = g_strdup_printf("AT+CSCB=0,\"%s\"", topics);
+	/* Some ZTE modem doesn't support sending a long AT command
+	 * so we send topics one by one
+	 */
+	switch (data->vendor) {
+	case OFONO_VENDOR_ZTE:
+		send_by_one = TRUE;
+		break;
+	default:
+		break;
+	}

so we already have a vendor switch statement a few lines above. Why bother introducing another one here?

Ok, I will use the first one.

Quoted 12 lines
Quoted 12 lines
drivers/atmodem/cbs.c +11 -0
+
+	if (send_by_one) {
+		gchar **topic_list = NULL;
+		gchar **topic_list_orig = NULL;
+
+		topic_list = topic_list_orig = g_strsplit_set(topics, ",", -1);
+
+		for (; *topic_list; topic_list++) {
+			struct cb_data *cbd = cb_data_new(cb, user_data);
+
+			buf = g_strdup_printf("AT+CSCB=0,\"%s\"", *topic_list);
 
Quoted 8 lines

drivers/atmodem/cbs.c static void at_cbs_set_topics(struct ofono_cbs *cbs, const char *topics, · line 159

Quoted 3 lines
drivers/atmodem/cbs.c +1 -1
-	id = g_at_chat_send(data->chat, buf, none_prefix,
+			id = g_at_chat_send(data->chat, buf, none_prefix,
 				at_cscb_set_cb, cbd, g_free);

So this is not going to work out as nicely as you might think it would. You keep calling ofono_cbs_set_cb_t callback now for every single topic you send. And also as a result, the D-Bus call returns successful after the first one.

OK, I see.

Quoted 2 lines

You need to properly queue this and properly fail and roll back in case of a failure.

Roll back? You means that if there is a failure in the middle of sending, you want to send AT command to remove the first topics?

Quoted 2 lines

I addition to that, I would prefer to send as many topics at once as possible. So how many can ZTE set at once?

I can do some test, but I think that it's not related to topics, but to AT command length. And we cannot guaranty to find another model more restrictive. Sending one by one seems to be the 'safest' solution.

Regards,

Bertrand
---------------------------------------------------------------------
Intel Corporation SAS (French simplified joint stock company) Registered headquarters: "Les Montalets"- 2, rue de Paris, 92196 Meudon Cedex, France
Registration Number: 302 456 199 R.C.S. NANTERRE
Capital: 4,572,000 Euros

This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies.

#4 lore raw

Hi Bertrand,

Quoted 21 lines
Quoted 12 lines
Quoted 12 lines
drivers/atmodem/cbs.c +11 -0
+
+	if (send_by_one) {
+		gchar **topic_list = NULL;
+		gchar **topic_list_orig = NULL;
+
+		topic_list = topic_list_orig = g_strsplit_set(topics, ",", -1);
+
+		for (; *topic_list; topic_list++) {
+			struct cb_data *cbd = cb_data_new(cb, user_data);
+
+			buf = g_strdup_printf("AT+CSCB=0,\"%s\"", *topic_list);
Quoted 8 lines

drivers/atmodem/cbs.c static void at_cbs_set_topics(struct ofono_cbs *cbs, const char *topics, · line 159

Quoted 3 lines
drivers/atmodem/cbs.c +1 -1
-	id = g_at_chat_send(data->chat, buf, none_prefix,
+			id = g_at_chat_send(data->chat, buf, none_prefix,
 				at_cscb_set_cb, cbd, g_free);

So this is not going to work out as nicely as you might think it would. You keep calling ofono_cbs_set_cb_t callback now for every single topic you send. And also as a result, the D-Bus call returns successful after the first one.

Quoted 6 lines

OK, I see.

Quoted 2 lines

You need to properly queue this and properly fail and roll back in case of a failure.

Roll back? You means that if there is a failure in the middle of sending, you want to send AT command to remove the first topics?

at minimum clear all topics again.

Quoted 4 lines
Quoted 2 lines

I addition to that, I would prefer to send as many topics at once as possible. So how many can ZTE set at once?

I can do some test, but I think that it's not related to topics, but to AT command length. And we cannot guaranty to find another model more restrictive. Sending one by one seems to be the 'safest' solution.

Please check this. And AT command length limitation would be funny. Not unlikely, but funny.

And while at it, please check if it is actually capable of handling any kind of topic ranges properly. You currently only split the topics, but have no special handling for ranges. So if the modem does not handle topic ranges, then you have a problem here.

For example if it can only set 10 topics at once, and you give 1-11. Is this 11 topics and the modem can handle it. Or it can handle only 10 topics and would fail.

Another thing that came to mind, please check that it actually adds the topics and not just overwrites it. Some manufactures don't read the AT command specification carefully.

Regards

Marcel

#5 lore raw

Hi,

Quoted 25 lines
Quoted 6 lines
Quoted 6 lines

drivers/atmodem/cbs.c static void at_cbs_set_topics(struct ofono_cbs *cbs, const char *topics,

Quoted 6 lines
drivers/atmodem/cbs.c +6 -0
+
+	if (send_by_one) {
+		gchar **topic_list = NULL;
+		gchar **topic_list_orig = NULL;
+
+		topic_list = topic_list_orig = g_strsplit_set(topics, ",",

-1);

Quoted 5 lines
Quoted 5 lines

drivers/atmodem/cbs.c static void at_cbs_set_topics(struct ofono_cbs *cbs, const char *topics,

Quoted 5 lines
drivers/atmodem/cbs.c +5 -0
+
+		for (; *topic_list; topic_list++) {
+			struct cb_data *cbd = cb_data_new(cb, user_data);
+
+			buf = g_strdup_printf("AT+CSCB=0,\"%s\"",

*topic_list);

Quoted 12 lines
Quoted 9 lines

drivers/atmodem/cbs.c static void at_cbs_set_topics(struct ofono_cbs *cbs, const char *topics, · line 159

Quoted 4 lines
drivers/atmodem/cbs.c +1 -1
-	id = g_at_chat_send(data->chat, buf, none_prefix,
+			id = g_at_chat_send(data->chat, buf, none_prefix,
 				at_cscb_set_cb, cbd, g_free);

So this is not going to work out as nicely as you might think it would. You keep calling ofono_cbs_set_cb_t callback now for every single topic you send. And also as a result, the D-Bus call returns successful after the first one.

OK, I see.

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

You need to properly queue this and properly fail and roll back in case of a failure.

Roll back? You means that if there is a failure in the middle of sending,

you want to send AT command to remove the first topics?

at minimum clear all topics again.

Ok, I will do this.

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

I addition to that, I would prefer to send as many topics at once as possible. So how many can ZTE set at once?

I can do some test, but I think that it's not related to topics, but to AT

command length. And we cannot guaranty to find another model more restrictive. Sending one by one seems to be the 'safest' solution.

Quoted 7 lines

Please check this. And AT command length limitation would be funny. Not unlikely, but funny.

And while at it, please check if it is actually capable of handling any kind of topic ranges properly. You currently only split the topics, but have no special handling for ranges. So if the modem does not handle topic ranges, then you have a problem here.

Topic range is OK. You can have a look at the log.

ofonod[2040]: Aux: > AT+CSCB=0,"4352-4356"\r
ofonod[2040]: Aux: < \r\nOK\r\n

Quoted 7 lines

For example if it can only set 10 topics at once, and you give 1-11. Is this 11 topics and the modem can handle it. Or it can handle only 10 topics and would fail.

Another thing that came to mind, please check that it actually adds the topics and not just overwrites it. Some manufactures don't read the AT command specification carefully.

Seems to be fine.

So as you can see in the log, I have found the 'limit'.

at+cscb=0, "4352-4356,11000,10000,9000,8000,7000,6000,5000,1,2"

OK

at+cscb=0, "4352-4356,11000,10000,9000,8000,7000,6000,5000,1,21"

ERROR

50 characters inside the string is OK, but 51 not.

So do you prefer to use such limit, instead of sending one by one?

Regards,

Bertrand

---------------------------------------------------------------------
Intel Corporation SAS (French simplified joint stock company) Registered headquarters: "Les Montalets"- 2, rue de Paris, 92196 Meudon Cedex, France
Registration Number: 302 456 199 R.C.S. NANTERRE
Capital: 4,572,000 Euros

This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies.

ofonod[2040]: Aux: > AT+CSCB=1\r
ofonod[2040]: Aux: < \r\nOK\r\n
ofonod[2040]: Aux: > AT+CSCB=0,"0"\r
ofonod[2040]: Aux: < \r\nOK\r\n
ofonod[2040]: Aux: > AT+CSCB=0,"11"\r
ofonod[2040]: Aux: < \r\nOK\r\n
ofonod[2040]: Aux: > AT+CSCB=0,"30"\r
ofonod[2040]: Aux: < \r\nOK\r\n
ofonod[2040]: Aux: > AT+CSCB=0,"50"\r
ofonod[2040]: Aux: < \r\nOK\r\n
ofonod[2040]: Aux: > AT+CSCB=0,"53"\r
ofonod[2040]: Aux: < \r\nOK\r\n
ofonod[2040]: Aux: > AT+CSCB=0,"97"\r
ofonod[2040]: Aux: < \r\nOK\r\n
ofonod[2040]: Aux: > AT+CSCB=0,"101"\r
ofonod[2040]: Aux: < \r\nOK\r\n
ofonod[2040]: Aux: > AT+CSCB=0,"130"\r
ofonod[2040]: Aux: < \r\nOK\r\n
ofonod[2040]: Aux: > AT+CSCB=0,"237"\r
ofonod[2040]: Aux: < \r\nOK\r\n
ofonod[2040]: Aux: > AT+CSCB=0,"2000"\r
ofonod[2040]: Aux: < \r\nOK\r\n
ofonod[2040]: Aux: > AT+CSCB=0,"3000"\r
ofonod[2040]: Aux: < \r\nOK\r\n
ofonod[2040]: Aux: > AT+CSCB=0,"4000"\r
ofonod[2040]: Aux: < \r\nOK\r\n
ofonod[2040]: Aux: > AT+CSCB=0,"5000"\r
ofonod[2040]: Aux: < \r\nOK\r\n
ofonod[2040]: Aux: > AT+CSCB=0,"6000"\r
ofonod[2040]: Aux: < \r\nOK\r\n
ofonod[2040]: Aux: > AT+CSCB=0,"7000"\r
ofonod[2040]: Aux: < \r\nOK\r\n
ofonod[2040]: Aux: > AT+CSCB=0,"8000"\r
ofonod[2040]: Aux: < \r\nOK\r\n
ofonod[2040]: Aux: > AT+CSCB=0,"9000"\r
ofonod[2040]: Aux: < \r\nOK\r\n
ofonod[2040]: Aux: > AT+CSCB=0,"10000"\r
ofonod[2040]: Aux: < \r\nOK\r\n
ofonod[2040]: Aux: > AT+CSCB=0,"11000"\r
ofonod[2040]: Aux: < \r\nOK\r\n
ofonod[2040]: Aux: > AT+CSCB=0,"4352-4356"\r
ofonod[2040]: Aux: < \r\nOK\r\n

Using minicom:

at+cscb?

+CSCB: 0, "4352-4356,11000,10000,9000,8000,7000,6000,5000,4000,3000,2000,237,130,101,97,53,50,30,11,0",""

OK

at+cscb=0,"1000"

OK
at+cscb?

+CSCB: 0, "1000,4352-4356,11000,10000,9000,8000,7000,6000,5000,4000,3000,2000,237,130,101,97,53,50,30,11,0",""

OK

at+cscb=1

OK
at+cscb?

+CSCB: 1, "",""

OK

at+cscb=0, "4352-4356,11000,10000,9000,8000,7000,6000"

OK
at+cscb=0, "4352-4356,11000,10000,9000,8000,7000,6000,5000"

OK

at+cscb=0, "4352-4356,11000,10000,9000,8000,7000,6000,5000,4000"

ERROR

at+cscb?

+CSCB: 0, "",""

OK
at+cscb=0, "4352-4356,11000,10000,9000,8000,7000,6000,5000,1"

OK

at+cscb=0, "4352-4356,11000,10000,9000,8000,7000,6000,5000,1,2"

OK

at+cscb=0, "4352-4356,11000,10000,9000,8000,7000,6000,5000,1,21"

ERROR

#6 lore raw

PATCH 2/2 zte: specify the vendor to send cbs topics one by one.

In reply to Bertrand Aygon
---
 plugins/zte.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
plugins/zte.c +1 -1
index 9fa9940..c572860 100644
@@ -297,7 +297,7 @@ static void zte_post_online(struct ofono_modem *modem)
 
 	ofono_netreg_create(modem, OFONO_VENDOR_ZTE, "atmodem", data->aux);
 
-	ofono_cbs_create(modem, OFONO_VENDOR_QUALCOMM_MSM,
+	ofono_cbs_create(modem, OFONO_VENDOR_ZTE,
 					"atmodem", data->aux);
 	ofono_ussd_create(modem, OFONO_VENDOR_QUALCOMM_MSM,
 					"atmodem", data->aux);
Signature · 13 lines
1.7.4.1

---------------------------------------------------------------------
Intel Corporation SAS (French simplified joint stock company)
Registered headquarters: "Les Montalets"- 2, rue de Paris, 
92196 Meudon Cedex, France
Registration Number:  302 456 199 R.C.S. NANTERRE
Capital: 4,572,000 Euros

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.