atmodem: Fix issue with AT+CREG=? and AT+CGREG=? handling
authorMarcel Holtmann <marcel@holtmann.org>
Thu, 24 May 2012 01:28:50 +0000 (03:28 +0200)
committerMarcel Holtmann <marcel@holtmann.org>
Thu, 24 May 2012 01:28:50 +0000 (03:28 +0200)
Some modems might see an interim +CREG: or +CGREG: notification when
querying the supported modes.

  Aux: > AT+CFUN=1\r
  Aux: < \r\nOK\r\n
  Aux: > AT+CREG=?\r
  Aux: < \r\n+CREG: 2\r\n
  Aux: < \r\n+CREG: (0-2)\r\nOK\r\n
  Unable to initialize Network Registration

To make this work, skip to the first line with an actual range value.

drivers/atmodem/gprs.c
drivers/atmodem/network-registration.c

index 5f1d610..65a8b7b 100644 (file)
@@ -318,11 +318,12 @@ static void at_cgreg_test_cb(gboolean ok, GAtResult *result,
 
        g_at_result_iter_init(&iter, result);
 
+retry:
        if (!g_at_result_iter_next(&iter, "+CGREG:"))
                goto error;
 
        if (!g_at_result_iter_open_list(&iter))
-               goto error;
+               goto retry;
 
        while (g_at_result_iter_next_range(&iter, &range[0], &range[1])) {
                if (1 >= range[0] && 1 <= range[1])
index 770c166..a42ae50 100644 (file)
@@ -1556,11 +1556,12 @@ static void at_creg_test_cb(gboolean ok, GAtResult *result, gpointer user_data)
 
        g_at_result_iter_init(&iter, result);
 
+retry:
        if (!g_at_result_iter_next(&iter, "+CREG:"))
                goto error;
 
        if (!g_at_result_iter_open_list(&iter))
-               goto error;
+               goto retry;
 
        while (g_at_result_iter_next_range(&iter, &range[0], &range[1])) {
                if (1 >= range[0] && 1 <= range[1])