[PATCH 2/2] bearer-qmi: detect disconnections when loading stats

Aleksander Morgado aleksander at aleksander.es
Tue Sep 5 20:26:13 UTC 2017


The Netgear AC341U seems to delay reporting packet service status
indications or actually not even send them. This leaves us with modems
in connected state in ModemManager but actually disconnected. We can
detect this situation by processing out-of-call errors when we load
connection statistics.

See e.g. this case where the indication is received 2.5 mins after the
first OutOfCall error detected when loading statistics.

    Aug 30 22:52:50 ModemManager[574]: <info>  Modem /org/freedesktop/ModemManager1/Modem/0: state changed (connecting -> connected)
    Aug 30 22:52:50 ModemManager[574]: <info>  Simple connect state (8/8): All done
    Aug 30 22:52:50 ModemManager[574]: <warn>  Reloading stats failed: Couldn't get packet statistics: QMI protocol error (15): 'OutOfCall'
    Aug 30 22:53:20 ModemManager[574]: <warn>  Reloading stats failed: Couldn't get packet statistics: QMI protocol error (15): 'OutOfCall'
    Aug 30 22:53:50 ModemManager[574]: <warn>  Reloading stats failed: Couldn't get packet statistics: QMI protocol error (15): 'OutOfCall'
    Aug 30 22:54:20 ModemManager[574]: <warn>  Reloading stats failed: Couldn't get packet statistics: QMI protocol error (15): 'OutOfCall'
    Aug 30 22:56:21 ModemManager[574]: <info>  bearer call end reason (2): 'generic-client-end'
    Aug 30 22:56:21 ModemManager[574]: <info>  bearer verbose call end reason (3,2000): [cm] client-end
    Aug 30 22:56:21 ModemManager[574]: <info>  Modem /org/freedesktop/ModemManager1/Modem/0: state changed (connected -> registered)
---
 src/mm-bearer-qmi.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/src/mm-bearer-qmi.c b/src/mm-bearer-qmi.c
index 90857a4a..c3ac764b 100644
--- a/src/mm-bearer-qmi.c
+++ b/src/mm-bearer-qmi.c
@@ -110,12 +110,14 @@ get_packet_statistics_ready (QmiClientWds *client,
                              GAsyncResult *res,
                              GTask *task)
 {
+    MMBearerQmi *self;
     ReloadStatsContext *ctx;
     GError *error = NULL;
     QmiMessageWdsGetPacketStatisticsOutput *output;
     guint64 tx_bytes_ok = 0;
     guint64 rx_bytes_ok = 0;
 
+    self = g_task_get_source_object (task);
     ctx = g_task_get_task_data (task);
 
     output = qmi_client_wds_get_packet_statistics_finish (client, res, &error);
@@ -127,6 +129,10 @@ get_packet_statistics_ready (QmiClientWds *client,
     }
 
     if (!qmi_message_wds_get_packet_statistics_output_get_result (output, &error)) {
+        /* An out-of-call error when loading statistics tells us the modem is disconnected */
+        if (g_error_matches (error, QMI_PROTOCOL_ERROR, QMI_PROTOCOL_ERROR_OUT_OF_CALL))
+            mm_base_bearer_report_connection_status (MM_BASE_BEARER (self), MM_BEARER_CONNECTION_STATUS_DISCONNECTED);
+
         g_prefix_error (&error, "Couldn't get packet statistics: ");
         g_task_return_error (task, error);
         g_object_unref (task);
-- 
2.13.1



More information about the ModemManager-devel mailing list