[PATCH v2 2/2] huawei: ignore ^RFSWITCH unsolicited messages
Aleksander Morgado
aleksander at lanedo.com
Mon Aug 26 07:27:56 PDT 2013
On 22/08/13 02:32, Ben Chan wrote:
> This patch ignores the ^RFSWITCH unsolicited messages in order to avoid
> them being mixed with other unsolicited messages. The modem power state
> is explicitly determined by the ^RFSWITCH? command, if supported, so we
> don't need to depend on the ^RFSWITCH unsolicited messages.
> ---
Pushed, thanks.
> plugins/huawei/mm-broadband-modem-huawei.c | 38 ++++++++++++++++++++++++++++++
> 1 file changed, 38 insertions(+)
>
> diff --git a/plugins/huawei/mm-broadband-modem-huawei.c b/plugins/huawei/mm-broadband-modem-huawei.c
> index 453fbbd..d075958 100644
> --- a/plugins/huawei/mm-broadband-modem-huawei.c
> +++ b/plugins/huawei/mm-broadband-modem-huawei.c
> @@ -95,6 +95,7 @@ struct _MMBroadbandModemHuaweiPrivate {
> GRegex *ndisstat_regex;
> GRegex *pdpdeact_regex;
> GRegex *ndisend_regex;
> + GRegex *rfswitch_regex;
>
> NdisdupSupport ndisdup_support;
> RfswitchSupport rfswitch_support;
> @@ -2583,6 +2584,27 @@ modem_time_load_network_time (MMIfaceModemTime *self,
> /* Power state loading (Modem interface) */
>
> static void
> +enable_disable_unsolicited_rfswitch_event_handler (MMBroadbandModemHuawei *self,
> + gboolean enable)
> +{
> + MMAtSerialPort *ports[2];
> + guint i;
> +
> + mm_dbg ("%s ^RFSWITCH unsolicited event handler",
> + enable ? "Enable" : "Disable");
> +
> + ports[0] = mm_base_modem_peek_port_primary (MM_BASE_MODEM (self));
> + ports[1] = mm_base_modem_peek_port_secondary (MM_BASE_MODEM (self));
> +
> + for (i = 0; i < 2; i++)
> + if (ports[i])
> + mm_at_serial_port_enable_disable_unsolicited_msg_handler (
> + ports[i],
> + self->priv->rfswitch_regex,
> + enable);
> +}
> +
> +static void
> parent_load_power_state_ready (MMIfaceModem *self,
> GAsyncResult *res,
> GSimpleAsyncResult *result)
> @@ -2610,6 +2632,9 @@ huawei_rfswitch_check_ready (MMBaseModem *_self,
> const gchar *response;
> gint sw_state;
>
> + enable_disable_unsolicited_rfswitch_event_handler (MM_BROADBAND_MODEM_HUAWEI (self),
> + TRUE /* enable */);
> +
> response = mm_base_modem_at_command_finish (_self, res, &error);
> if (response) {
> response = mm_strip_tag (response, "^RFSWITCH:");
> @@ -2685,6 +2710,12 @@ load_power_state (MMIfaceModem *self,
> switch (MM_BROADBAND_MODEM_HUAWEI (self)->priv->rfswitch_support) {
> case RFSWITCH_SUPPORT_UNKNOWN:
> case RFSWITCH_SUPPORTED: {
> + /* Temporarily disable the unsolicited ^RFSWITCH event handler in order to
> + * prevent it from discarding the response to the ^RFSWITCH? command.
> + * It will be re-enabled in huawei_rfswitch_check_ready.
> + */
> + enable_disable_unsolicited_rfswitch_event_handler (MM_BROADBAND_MODEM_HUAWEI (self),
> + FALSE /* enable */);
> mm_base_modem_at_command (MM_BASE_MODEM (self),
> "^RFSWITCH?",
> 3,
> @@ -2883,6 +2914,10 @@ set_ignored_unsolicited_events_handlers (MMBroadbandModemHuawei *self)
> ports[i],
> self->priv->ndisend_regex,
> NULL, NULL, NULL);
> + mm_at_serial_port_add_unsolicited_msg_handler (
> + ports[i],
> + self->priv->rfswitch_regex,
> + NULL, NULL, NULL);
> }
> }
>
> @@ -2958,6 +2993,8 @@ mm_broadband_modem_huawei_init (MMBroadbandModemHuawei *self)
> G_REGEX_RAW | G_REGEX_OPTIMIZE, 0, NULL);
> self->priv->ndisend_regex = g_regex_new ("\\r\\n\\^NDISEND:.+\\r+\\n",
> G_REGEX_RAW | G_REGEX_OPTIMIZE, 0, NULL);
> + self->priv->rfswitch_regex = g_regex_new ("\\r\\n\\^RFSWITCH:.+\\r\\n",
> + G_REGEX_RAW | G_REGEX_OPTIMIZE, 0, NULL);
>
> self->priv->ndisdup_support = NDISDUP_SUPPORT_UNKNOWN;
> self->priv->rfswitch_support = RFSWITCH_SUPPORT_UNKNOWN;
> @@ -2985,6 +3022,7 @@ finalize (GObject *object)
> g_regex_unref (self->priv->ndisstat_regex);
> g_regex_unref (self->priv->pdpdeact_regex);
> g_regex_unref (self->priv->ndisend_regex);
> + g_regex_unref (self->priv->rfswitch_regex);
>
> G_OBJECT_CLASS (mm_broadband_modem_huawei_parent_class)->finalize (object);
> }
>
--
Aleksander
More information about the ModemManager-devel
mailing list