diff options
author | Sven Schwermer <sven.schwermer@disruptive-technologies.com> | 2022-01-10 09:41:53 +0100 |
---|---|---|
committer | Aleksander Morgado <aleksander@aleksander.es> | 2022-01-11 09:31:32 +0000 |
commit | 300e1023ef2daed40685bb90ea38a029c443396a (patch) | |
tree | 65f9bb1b34ed600da514622a2d85b678e39e5f27 | |
parent | 382a7c2425ccb1c1e453c6d7939032c617cb79d1 (diff) |
fibocom: Double-check connection after dialing
Fibocom's documentation states that we must double-check the connection
is established when setting up an ECM connection. The possible replies -
according to the documentation - are:
+GTRNDIS: <state>,<cid>,<ip>,<prim. dns>,<sec. dns>
OK
or
+GTRNDIS: 0
We just care about the state value which is 1 if everything worked.
-rw-r--r-- | plugins/fibocom/mm-broadband-bearer-fibocom-ecm.c | 42 |
1 files changed, 36 insertions, 6 deletions
diff --git a/plugins/fibocom/mm-broadband-bearer-fibocom-ecm.c b/plugins/fibocom/mm-broadband-bearer-fibocom-ecm.c index 551fa7e4..0cad0003 100644 --- a/plugins/fibocom/mm-broadband-bearer-fibocom-ecm.c +++ b/plugins/fibocom/mm-broadband-bearer-fibocom-ecm.c @@ -87,23 +87,53 @@ dial_3gpp_finish (MMBroadbandBearer *self, } static void -gtrndis_activate_ready (MMBaseModem *modem, - GAsyncResult *res, - GTask *task) +gtrndis_verify_ready (MMBaseModem *modem, + GAsyncResult *res, + GTask *task) { DialContext *ctx; GError *error = NULL; + const gchar *response; ctx = g_task_get_task_data (task); + response = mm_base_modem_at_command_finish (modem, res, &error); - if (!mm_base_modem_at_command_finish (modem, res, &error)) + if (!response) g_task_return_error (task, error); - else - g_task_return_pointer (task, g_object_ref (ctx->data), g_object_unref); + else { + response = mm_strip_tag (response, "+GTRNDIS:"); + if (strtol (response, NULL, 10) != 1) + g_task_return_new_error (task, MM_CORE_ERROR, MM_CORE_ERROR_FAILED, + "Connection status verification failed"); + else + g_task_return_pointer (task, g_object_ref (ctx->data), g_object_unref); + } + g_object_unref (task); } static void +gtrndis_activate_ready (MMBaseModem *modem, + GAsyncResult *res, + GTask *task) +{ + GError *error = NULL; + + if (!mm_base_modem_at_command_finish (modem, res, &error)) { + g_task_return_error (task, error); + g_object_unref (task); + return; + } + + mm_base_modem_at_command (modem, + "+GTRNDIS?", + 6, /* timeout [s] */ + FALSE, /* allow_cached */ + (GAsyncReadyCallback) gtrndis_verify_ready, + task); +} + +static void dial_3gpp (MMBroadbandBearer *self, MMBaseModem *modem, MMPortSerialAt *primary, |