Skip to contentSkip to conversation

fixing SMS notification parsing for some cinterion modem

PATCH In review [email protected] 2 participants 2 messages Aug 28, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fixing SMS notification parsing for some cinterion modem

Hi Denis,

I've recently found a bug in the +CMT notification parsing on some cinterion modems. Some of them (ALS3, PLS8, maybe others...) have a leading coma right after "+CTM : ", before the PDU size, which makes the parser rejecting the message since the PDU size is not found.

Please find attached my proposed patch.

---
 drivers/atmodem/sms.c | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)
drivers/atmodem/sms.c +15 -2
index 68b89862..d650c0f6 100644
@@ -412,8 +412,21 @@ static void at_cmt_notify(GAtResult *result, gpointer user_data)
 
 	switch (data->vendor) {
 	case OFONO_VENDOR_CINTERION:
-		if (!g_at_result_iter_next_number(&iter, &tpdu_len))
-			goto err;
+		if (!g_at_result_iter_next_number(&iter, &tpdu_len)) {
+			/*
+			 * Can't get the PDU length, we need to skip
+			 * the leading coma for some modems (ALS3,PLS8...).
+			 */
+			DBG("Retrying to find the PDU length");
+
+			if (!g_at_result_iter_skip_next(&iter))
+				goto err;
+
+			/* Next attempt at finding the PDU length. */
+			if (!g_at_result_iter_next_number(&iter, &tpdu_len))
+				goto err;
+		}
+
 		break;
 	default:
 		if (!g_at_result_iter_skip_next(&iter))
Signature · 1 line
2.18.0
#1 lore raw

Hi,

The commit header needs a bit of tweaking. It should be prefixed by the driver name or core atom name. E.g.

atmodem: Handle broken +CMT notifications of some cinterion modems

Quoted 9 lines · tournier.julien(a)gmail.com

Hi Denis,

I've recently found a bug in the +CMT notification parsing on some cinterion modems. Some of them (ALS3, PLS8, maybe others...) have a leading coma right after "+CTM : ", before the PDU size, which makes the parser rejecting the message since the PDU size is not found.

Please find attached my proposed patch.

Could you fix the patch Author information to be something that I could I apply? E.g. in a format like the AUTHORS file in ofono.git.

Quoted 9 lines
---
  drivers/atmodem/sms.c | 17 +++++++++++++++--
  1 file changed, 15 insertions(+), 2 deletions(-)
drivers/atmodem/sms.c +0 -0
index 68b89862..d650c0f6 100644

drivers/atmodem/sms.c static void at_cmt_notify(GAtResult *result, gpointer user_data) · line 419

Quoted 10 lines
drivers/atmodem/sms.c +5 -2
@@ -412,8 +412,21 @@ static void at_cmt_notify(GAtResult *result, gpointer user_data)
 
  	switch (data->vendor) {
  	case OFONO_VENDOR_CINTERION:
-		if (!g_at_result_iter_next_number(&iter, &tpdu_len))
-			goto err;
+		if (!g_at_result_iter_next_number(&iter, &tpdu_len)) {
+			/*
+			 * Can't get the PDU length, we need to skip
+			 * the leading coma for some modems (ALS3,PLS8...).
+			 */

You might want to put an illustrative example of a broken +CMT notification above. Doesn't have to be an actual valid message, just something to showcase the broken syntax.

Quoted 4 lines
drivers/atmodem/sms.c +3 -0
+			DBG("Retrying to find the PDU length");
+
+			if (!g_at_result_iter_skip_next(&iter))

drivers/atmodem/sms.c static void at_cmt_notify(GAtResult *result, gpointer user_data) · line 432

Quoted 10 lines
drivers/atmodem/sms.c +7 -0
+				goto err;
+
+			/* Next attempt at finding the PDU length. */
+			if (!g_at_result_iter_next_number(&iter, &tpdu_len))
+				goto err;
+		}
+
  		break;
  	default:
  		if (!g_at_result_iter_skip_next(&iter))

Otherwise this looks good to me.

Regards,
-Denis