diff options
author | Aleksander Morgado <aleksander@aleksander.es> | 2019-06-13 18:43:06 +0200 |
---|---|---|
committer | Aleksander Morgado <aleksander@aleksander.es> | 2019-06-13 18:43:06 +0200 |
commit | 1d52e5c24da3bde30feba6067e2b7040c58f4129 (patch) | |
tree | 13d3285414cef24e3424f6fb63465910e977b64f | |
parent | ca5f2e8b3e0e7fbe27b14ff8e51748364969e4e1 (diff) |
cinterion: make custom +CIEV parser much more generic
The custom +CIEV parser configured for Cinterion modems was
exclusively matching the "psinfo" indicator updates, which were the
ones really used afterwards.
But, in order to avoid having undesired URCs mixed with other command
responses, we should anyway match any +CIEV indicator reported, not
only "psinfo".
The text indicator ids used in +CIEV seem to bee specific to Cinterion
devices when they're configured via AT^SIND, so we do a generic match
for any lowercase ascii text as indicator id.
-rw-r--r-- | plugins/cinterion/mm-broadband-modem-cinterion.c | 41 |
1 files changed, 23 insertions, 18 deletions
diff --git a/plugins/cinterion/mm-broadband-modem-cinterion.c b/plugins/cinterion/mm-broadband-modem-cinterion.c index 14ff248c..e9a70497 100644 --- a/plugins/cinterion/mm-broadband-modem-cinterion.c +++ b/plugins/cinterion/mm-broadband-modem-cinterion.c @@ -80,8 +80,8 @@ struct _MMBroadbandModemCinterionPrivate { GArray *cnmi_supported_ds; GArray *cnmi_supported_bfr; - /* +CIEV 'psinfo' indications */ - GRegex *ciev_psinfo_regex; + /* +CIEV indications as configured via AT^SIND */ + GRegex *ciev_regex; /* Flags for feature support checks */ FeatureSupport swwan_support; @@ -814,20 +814,25 @@ modem_3gpp_enable_unsolicited_events (MMIfaceModem3gpp *self, /* Setup/Cleanup unsolicited events (3GPP interface) */ static void -sind_psinfo_received (MMPortSerialAt *port, - GMatchInfo *match_info, - MMBroadbandModemCinterion *self) +sind_ciev_received (MMPortSerialAt *port, + GMatchInfo *match_info, + MMBroadbandModemCinterion *self) { - guint val; + guint val = 0; + gchar *indicator; - if (!mm_get_uint_from_match_info (match_info, 1, &val)) { - mm_dbg ("Failed to convert psinfo value"); - return; + indicator = mm_get_string_unquoted_from_match_info (match_info, 1); + if (!mm_get_uint_from_match_info (match_info, 2, &val)) + mm_dbg ("couldn't parse indicator '%s' value", indicator); + else { + mm_dbg ("received indicator '%s' update: %u", indicator, val); + if (g_strcmp0 (indicator, "psinfo") == 0) { + mm_iface_modem_update_access_technologies (MM_IFACE_MODEM (self), + mm_cinterion_get_access_technology_from_sind_psinfo (val), + MM_IFACE_MODEM_3GPP_ALL_ACCESS_TECHNOLOGIES_MASK); + } } - - mm_iface_modem_update_access_technologies (MM_IFACE_MODEM (self), - mm_cinterion_get_access_technology_from_sind_psinfo (val), - MM_IFACE_MODEM_3GPP_ALL_ACCESS_TECHNOLOGIES_MASK); + g_free (indicator); } static void @@ -847,8 +852,8 @@ set_unsolicited_events_handlers (MMBroadbandModemCinterion *self, mm_port_serial_at_add_unsolicited_msg_handler ( ports[i], - self->priv->ciev_psinfo_regex, - enable ? (MMPortSerialAtUnsolicitedMsgFn)sind_psinfo_received : NULL, + self->priv->ciev_regex, + enable ? (MMPortSerialAtUnsolicitedMsgFn)sind_ciev_received : NULL, enable ? self : NULL, NULL); } @@ -1819,8 +1824,8 @@ mm_broadband_modem_cinterion_init (MMBroadbandModemCinterion *self) self->priv->sind_psinfo_support = FEATURE_SUPPORT_UNKNOWN; self->priv->swwan_support = FEATURE_SUPPORT_UNKNOWN; - self->priv->ciev_psinfo_regex = g_regex_new ("\\r\\n\\+CIEV: psinfo,(\\d+)\\r\\n", - G_REGEX_RAW | G_REGEX_OPTIMIZE, 0, NULL); + self->priv->ciev_regex = g_regex_new ("\\r\\n\\+CIEV:\\s*([a-z]+),(\\d+)\\r\\n", + G_REGEX_RAW | G_REGEX_OPTIMIZE, 0, NULL); } static void @@ -1842,7 +1847,7 @@ finalize (GObject *object) if (self->priv->cnmi_supported_bfr) g_array_unref (self->priv->cnmi_supported_bfr); - g_regex_unref (self->priv->ciev_psinfo_regex); + g_regex_unref (self->priv->ciev_regex); G_OBJECT_CLASS (mm_broadband_modem_cinterion_parent_class)->finalize (object); } |