atmodem: Add really nasty hack for Nokia AT+COPS bug
authorMarcel Holtmann <marcel@holtmann.org>
Fri, 20 Aug 2010 01:00:49 +0000 (03:00 +0200)
committerMarcel Holtmann <marcel@holtmann.org>
Fri, 20 Aug 2010 01:00:49 +0000 (03:00 +0200)
The Nokia modem returns an invalid response when trying to read the
numeric value for MCC/MNC of the current network.

Control:> AT+COPS?\r
Control:< \r\n+COPS: 0,2,"26207,0\r\n\r\nOK\r\n

The closing " is just missing and this confuses the AT parser. In case
of a Nokia modem skip reading the numerical values for the network.

drivers/atmodem/network-registration.c

index f5cf12f..065b5d9 100644 (file)
@@ -353,12 +353,24 @@ static void at_current_operator(struct ofono_netreg *netreg,
 
        cbd->user = netreg;
 
-       ok = g_at_chat_send(nd->chat, "AT+COPS=3,2", none_prefix,
-                               NULL, NULL, NULL);
+       /* Nokia modems have a broken return value for the string
+        * returned for the numeric value. It misses a " at the end.
+        * Trying to read this will stall the parser. So skip it. */
+       if (nd->vendor == OFONO_VENDOR_NOKIA) {
+               ok = g_at_chat_send(nd->chat, "AT+COPS=3,0", none_prefix,
+                                                       NULL, NULL, NULL);
+
+               if (ok)
+                       ok = g_at_chat_send(nd->chat, "AT+COPS?", cops_prefix,
+                                                       cops_cb, cbd, NULL);
+       } else {
+               ok = g_at_chat_send(nd->chat, "AT+COPS=3,2", none_prefix,
+                                                       NULL, NULL, NULL);
 
-       if (ok)
-               ok = g_at_chat_send(nd->chat, "AT+COPS?", cops_prefix,
-                                       cops_numeric_cb, cbd, NULL);
+               if (ok)
+                       ok = g_at_chat_send(nd->chat, "AT+COPS?", cops_prefix,
+                                               cops_numeric_cb, cbd, NULL);
+       }
 
        if (ok)
                return;