Mikko,

Any chance you can check with the attached patch applied?

On Sat, Mar 28, 2015 at 6:37 PM, Aleksander Morgado
<[email protected]> wrote:
> On Sat, Mar 28, 2015 at 11:32 AM, Mikko Vinni <[email protected]> wrote:
>> Hi,
>>
>> Testing a Huawei E353 directly connected to my laptop (instead of a WLAN 
>> router) gives this
>> debug output (note the lowercase ry in ^NDISSTATQry):
>>
>>
>> maalis 27 22:09:02 ubium-1 ModemManager[2508]: <debug> [1427486942.121397] 
>> [mm-port-serial-at.c:440] debug_log(): (cdc-wdm0): --> 
>> 'AT^NDISSTATQRY?<CR><LF>'
>> maalis 27 22:09:02 ubium-1 ModemManager[2508]: <debug> [1427486942.128666] 
>> [mm-port-serial-at.c:440] debug_log(): (cdc-wdm0): <-- 
>> '<CR><LF>^NDISSTATQry:1<CR><LF><CR><LF>OK<CR><LF>'
>> maalis 27 22:09:02 ubium-1 ModemManager[2508]: <debug> [1427486942.128827] 
>> [huawei/mm-broadband-bearer-huawei.c:161] connect_ndisstatqry_check_ready(): 
>> Unexpected response to ^NDISSTATQRY command: Missing ^NDISSTAT / 
>> ^NDISSTATQRY prefix (Attempts so far: 11)
>> maalis 27 22:09:02 ubium-1 ModemManager[2508]: <debug> [1427486942.128886] 
>> [mm-port-serial.c:1294] _close_internal(): (cdc-wdm0) device open count is 0 
>> (close)
>> maalis 27 22:09:02 ubium-1 ModemManager[2508]: <debug> [1427486942.128924] 
>> [mm-port-serial.c:1310] _close_internal(): (cdc-wdm0) closing serial port...
>> maalis 27 22:09:02 ubium-1 ModemManager[2508]: <debug> [1427486942.131157] 
>> [mm-port-serial.c:1359] _close_internal(): (cdc-wdm0) serial port closed
>> maalis 27 22:09:02 ubium-1 ModemManager[2508]: <debug> [1427486942.755252] 
>> [mm-port-serial-at.c:440] debug_log(): (ttyUSB2): <-- 
>> '<CR><LF>^DSFLOWRPT:000001F6,00000000,00000000,0000000000000000,0000000000000288,000B4000,00290400<CR><LF>'
>> maalis 27 22:09:02 ubium-1 ModemManager[2508]: <debug> [1427486942.755416] 
>> [huawei/mm-broadband-modem-huawei.c:1650] huawei_status_changed(): Duration: 
>> 502 Up: 0 Kbps Down: 0 Kbps Total: 0 Total: 0
>> maalis 27 22:09:03 ubium-1 ModemManager[2508]: <debug> [1427486943.120052] 
>> [mm-base-bearer.c:465] connect_ready(): Couldn't connect bearer 
>> '/org/freedesktop/ModemManager1/Bearer/0': 'Connection attempt not 
>> supported.'
>> maalis 27 22:09:03 ubium-1 ModemManager[2508]: <info>  [1427486943.120152] 
>> [mm-iface-modem.c:1392] __iface_modem_update_state_internal(): Modem 
>> /org/freedesktop/ModemManager1/Modem/0: state changed (connecting -> 
>> registered)
>> ---
>>
>>
>>
>> The connection doesn't work.
>>
>> I recall this modem having worked before, so something must have changed 
>> (not the parsing of
>> '^NDISSTATQRY:' in 
>> http://cgit.freedesktop.org/ModemManager/ModemManager/tree/plugins/huawei/mm-modem-helpers-huawei.c
>>  though, which seems to be hardcoded to look for the string in uppercase).
>>
>> Currently running
>> ModemManager (version 1.4.6) and NetworkManager (version 1.0.0) on Arch 
>> Linux (kernel 3.19.2-1-ARCH). The modem is:
>>
>>
>> # mmcli -m 0
>>
>> /org/freedesktop/ModemManager1/Modem/0 (device id 
>> '3433326290b146a4ae694d0a9d6ba061292e957b')
>> -------------------------
>> Hardware |   manufacturer: 'huawei'
>> |          model: 'E353'
>> |       revision: '21.137.05.00.864'
>> |      supported: 'gsm-umts'
>> |        current: 'gsm-umts'
>> |   equipment id: '867989013808965'
>> -------------------------
>> System   |         device: 
>> '/sys/devices/pci0000:00/0000:00:1a.0/usb3/3-1/3-1.2'
>> |        drivers: 'huawei_cdc_ncm, option1'
>> |         plugin: 'Huawei'
>> |   primary port: 'ttyUSB2'
>> |          ports: 'ttyUSB0 (at), ttyUSB2 (at), cdc-wdm0 (at), wwp0s26u1u2i1 
>> (net)'
>> -------------------------
>> Numbers  |           own : 'unknown'
>> -------------------------
>> Status   |           lock: 'none'
>> | unlock retries: 'sim-pin (3), sim-pin2 (3), sim-puk (10), sim-puk2 (10)'
>> |          state: 'registered'
>> |    power state: 'on'
>> |    access tech: 'umts'
>> | signal quality: '25' (recent)
>> -------------------------
>> Modes    |      supported: 'allowed: 2g, 3g; preferred: none
>> |                  allowed: 2g, 3g; preferred: 2g
>> |                  allowed: 2g, 3g; preferred: 3g
>> |                  allowed: 2g; preferred: none
>> |                  allowed: 3g; preferred: none'
>> |        current: 'allowed: 2g, 3g; preferred: 3g'
>> -------------------------
>> Bands    |      supported: 'unknown'
>> |        current: 'unknown'
>> -------------------------
>> IP       |      supported: 'ipv4'
>> -------------------------
>> 3GPP     |           imei: '867989013808965'
>> |  enabled locks: 'none'
>> |    operator id: '24405'
>> |  operator name: 'elisa'
>> |   subscription: 'unknown'
>> |   registration: 'home'
>> -------------------------
>> SIM      |           path: '/org/freedesktop/ModemManager1/SIM/0'
>>
>> -------------------------
>> Bearers  |          paths: 'none'
>>
>> ----
>>
>> Is this a known issue or something that should be debugged further?
>>
>
> The issue really is the NDISSTATQRY? response parsing:
>
>         /* Give up if too many unexpected responses to NIDSSTATQRY are
> encountered. */
>         if (ctx->failed_ndisstatqry_count > 10) {
>             /* Clear context */
>             ctx->self->priv->connect_pending = NULL;
>             g_simple_async_result_set_error (ctx->result,
>                                              MM_MOBILE_EQUIPMENT_ERROR,
>
> MM_MOBILE_EQUIPMENT_ERROR_NOT_SUPPORTED,
>                                              "Connection attempt not
> supported.");
>             connect_3gpp_context_complete_and_free (ctx);
>             return;
>         }
>
> I'll change that to make it case insensitive.
>
> Someone at Huawei deserves a punishment for this ^NDISSTATQry thing.
>
> --
> Aleksander
> https://aleksander.es



-- 
Aleksander
https://aleksander.es
From 071a0f8302a1f7d044899270cc2a6a8f5b8c040a Mon Sep 17 00:00:00 2001
From: Aleksander Morgado <[email protected]>
Date: Sat, 28 Mar 2015 19:03:19 +0100
Subject: [PATCH] huawei: allow responses like ^NDISSTATQry (e.g. Huawei E353)

---
 plugins/huawei/mm-modem-helpers-huawei.c         | 91 ++++++++++++++++--------
 plugins/huawei/tests/test-modem-helpers-huawei.c |  4 ++
 2 files changed, 66 insertions(+), 29 deletions(-)

diff --git a/plugins/huawei/mm-modem-helpers-huawei.c b/plugins/huawei/mm-modem-helpers-huawei.c
index 7612e64..5362c55 100644
--- a/plugins/huawei/mm-modem-helpers-huawei.c
+++ b/plugins/huawei/mm-modem-helpers-huawei.c
@@ -42,8 +42,8 @@ mm_huawei_parse_ndisstatqry_response (const gchar *response,
     GError *inner_error = NULL;
 
     if (!response ||
-        !(g_str_has_prefix (response, "^NDISSTAT:") ||
-          g_str_has_prefix (response, "^NDISSTATQRY:"))) {
+        !(g_ascii_strncasecmp (response, "^NDISSTAT:", strlen ("^NDISSTAT:")) == 0 ||
+          g_ascii_strncasecmp (response, "^NDISSTATQRY:", strlen ("^NDISSTATQRY:")) == 0)) {
         g_set_error (error, MM_CORE_ERROR, MM_CORE_ERROR_FAILED, "Missing ^NDISSTAT / ^NDISSTATQRY prefix");
         return FALSE;
     }
@@ -61,47 +61,81 @@ mm_huawei_parse_ndisstatqry_response (const gchar *response,
      * Or, in newer firmwares:
      *     ^NDISSTATQRY:0,,,"IPV4",0,,,"IPV6"
      *     OK
+     *
+     * Or, even (handled separately):
+     *     ^NDISSTATQry:1
+     *     OK
      */
-    r = g_regex_new ("\\^NDISSTAT(?:QRY)?:\\s*(\\d),([^,]*),([^,]*),([^,\\r\\n]*)(?:\\r\\n)?"
-                     "(?:\\^NDISSTAT:|\\^NDISSTATQRY:)?\\s*,?(\\d)?,?([^,]*)?,?([^,]*)?,?([^,\\r\\n]*)?(?:\\r\\n)?",
-                     G_REGEX_DOLLAR_ENDONLY | G_REGEX_RAW,
-                     0, NULL);
-    g_assert (r != NULL);
 
-    g_regex_match_full (r, response, strlen (response), 0, 0, &match_info, &inner_error);
-    if (!inner_error && g_match_info_matches (match_info)) {
-        guint ip_type_field = 4;
+    /* If multiple fields available, try first parsing method */
+    if (strchr (response, ',')) {
+        r = g_regex_new ("\\^NDISSTAT(?:QRY)?(?:Qry)?:\\s*(\\d),([^,]*),([^,]*),([^,\\r\\n]*)(?:\\r\\n)?"
+                         "(?:\\^NDISSTAT:|\\^NDISSTATQRY:)?\\s*,?(\\d)?,?([^,]*)?,?([^,]*)?,?([^,\\r\\n]*)?(?:\\r\\n)?",
+                         G_REGEX_DOLLAR_ENDONLY | G_REGEX_RAW,
+                         0, NULL);
+        g_assert (r != NULL);
+
+        g_regex_match_full (r, response, strlen (response), 0, 0, &match_info, &inner_error);
+        if (!inner_error && g_match_info_matches (match_info)) {
+            guint ip_type_field = 4;
+
+            /* IPv4 and IPv6 are fields 4 and (if available) 8 */
+
+            while (!inner_error && ip_type_field <= 8) {
+                gchar *ip_type_str;
+                guint connected;
+
+                ip_type_str = mm_get_string_unquoted_from_match_info (match_info, ip_type_field);
+                if (!ip_type_str)
+                    break;
+
+                if (!mm_get_uint_from_match_info (match_info, (ip_type_field - 3), &connected) ||
+                    (connected != 0 && connected != 1)) {
+                    inner_error = g_error_new (MM_CORE_ERROR,
+                                               MM_CORE_ERROR_FAILED,
+                                               "Couldn't parse ^NDISSTAT / ^NDISSTATQRY fields");
+                } else if (g_ascii_strcasecmp (ip_type_str, "IPV4") == 0) {
+                    *ipv4_available = TRUE;
+                    *ipv4_connected = (gboolean)connected;
+                } else if (g_ascii_strcasecmp (ip_type_str, "IPV6") == 0) {
+                    *ipv6_available = TRUE;
+                    *ipv6_connected = (gboolean)connected;
+                }
 
-        /* IPv4 and IPv6 are fields 4 and (if available) 8 */
+                g_free (ip_type_str);
+                ip_type_field += 4;
+            }
+        }
 
-        while (!inner_error && ip_type_field <= 8) {
-            gchar *ip_type_str;
+        g_match_info_free (match_info);
+        g_regex_unref (r);
+    }
+    /* No separate IPv4/IPv6 info given just connected/not connected */
+    else {
+        r = g_regex_new ("\\^NDISSTAT(?:QRY)?(?:Qry)?:\\s*(\\d)(?:\\r\\n)?",
+                         G_REGEX_DOLLAR_ENDONLY | G_REGEX_RAW,
+                         0, NULL);
+        g_assert (r != NULL);
+
+        g_regex_match_full (r, response, strlen (response), 0, 0, &match_info, &inner_error);
+        if (!inner_error && g_match_info_matches (match_info)) {
             guint connected;
 
-            ip_type_str = mm_get_string_unquoted_from_match_info (match_info, ip_type_field);
-            if (!ip_type_str)
-                break;
-
-            if (!mm_get_uint_from_match_info (match_info, (ip_type_field - 3), &connected) ||
+            if (!mm_get_uint_from_match_info (match_info, 1, &connected) ||
                 (connected != 0 && connected != 1)) {
                 inner_error = g_error_new (MM_CORE_ERROR,
                                            MM_CORE_ERROR_FAILED,
                                            "Couldn't parse ^NDISSTAT / ^NDISSTATQRY fields");
-            } else if (g_ascii_strcasecmp (ip_type_str, "IPV4") == 0) {
+            } else {
+                /* We'll assume IPv4 */
                 *ipv4_available = TRUE;
                 *ipv4_connected = (gboolean)connected;
-            } else if (g_ascii_strcasecmp (ip_type_str, "IPV6") == 0) {
-                *ipv6_available = TRUE;
-                *ipv6_connected = (gboolean)connected;
             }
-
-            g_free (ip_type_str);
-            ip_type_field += 4;
         }
-    }
 
-    g_match_info_free (match_info);
-    g_regex_unref (r);
+        g_match_info_free (match_info);
+        g_regex_unref (r);
+    }
 
     if (!ipv4_available && !ipv6_available) {
         inner_error = g_error_new (MM_CORE_ERROR,
@@ -1183,4 +1217,3 @@ gboolean mm_huawei_parse_time_response (const gchar *response,
 
     return ret;
 }
-
diff --git a/plugins/huawei/tests/test-modem-helpers-huawei.c b/plugins/huawei/tests/test-modem-helpers-huawei.c
index 9e92eee..9670203 100644
--- a/plugins/huawei/tests/test-modem-helpers-huawei.c
+++ b/plugins/huawei/tests/test-modem-helpers-huawei.c
@@ -101,6 +101,10 @@ static const NdisstatqryTest ndisstatqry_tests[] = {
     { "^NDISSTATQRY: 1,,,\"IPV4\",0,,,\"IPV6\"\r\n", TRUE,  TRUE,  TRUE,  FALSE },
     { "^NDISSTATQRY: 0,,,\"IPV4\",1,,,\"IPV6\"\r\n", TRUE,  FALSE, TRUE,  TRUE  },
     { "^NDISSTATQRY: 0,,,\"IPV4\",0,,,\"IPV6\"\r\n", TRUE,  FALSE, TRUE,  FALSE },
+    { "^NDISSTATQry:1",     TRUE, TRUE,  FALSE, FALSE },
+    { "^NDISSTATQry:1\r\n", TRUE, TRUE,  FALSE, FALSE },
+    { "^NDISSTATQry:0",     TRUE, FALSE, FALSE, FALSE },
+    { "^NDISSTATQry:0\r\n", TRUE, FALSE, FALSE, FALSE },
     { NULL, FALSE, FALSE, FALSE, FALSE }
 };
 
-- 
2.3.4

_______________________________________________
ModemManager-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/modemmanager-devel

Reply via email to