diff options
author | Aleksander Morgado <aleksander@lanedo.com> | 2012-07-21 18:01:02 +0200 |
---|---|---|
committer | Aleksander Morgado <aleksander@lanedo.com> | 2012-08-06 20:07:27 +0200 |
commit | 0b3eb27856462e232f54762a3ba496bf36e25775 (patch) | |
tree | 6e95a4bee529c399ab2714995ed14b76c70da519 | |
parent | 5b96aa9db4899d6c217b7ba5596e1dd64ca8f931 (diff) |
port-probe: include Icera support check in the probing sequence
-rw-r--r-- | src/mm-port-probe-at.c | 19 | ||||
-rw-r--r-- | src/mm-port-probe-at.h | 8 | ||||
-rw-r--r-- | src/mm-port-probe.c | 75 | ||||
-rw-r--r-- | src/mm-port-probe.h | 6 |
4 files changed, 104 insertions, 4 deletions
diff --git a/src/mm-port-probe-at.c b/src/mm-port-probe-at.c index ba9e30cc..fb20a74d 100644 --- a/src/mm-port-probe-at.c +++ b/src/mm-port-probe-at.c @@ -91,3 +91,22 @@ mm_port_probe_response_processor_string (const gchar *command, return TRUE; } + +/* ---- Other ---- */ + +gboolean +mm_port_probe_response_processor_no_error (const gchar *command, + const gchar *response, + gboolean last_command, + const GError *error, + GVariant **result, + GError **result_error) +{ + if (error) { + *result = g_variant_new_boolean (FALSE); + return TRUE; + } + + *result = g_variant_new_boolean (TRUE); + return TRUE; +} diff --git a/src/mm-port-probe-at.h b/src/mm-port-probe-at.h index ee21b7aa..d180be4f 100644 --- a/src/mm-port-probe-at.h +++ b/src/mm-port-probe-at.h @@ -75,5 +75,13 @@ gboolean mm_port_probe_response_processor_is_at (const gchar *command, const GError *error, GVariant **result, GError **result_error); +/* Generic response parser which returns TRUE if no error */ +gboolean mm_port_probe_response_processor_no_error (const gchar *command, + const gchar *response, + gboolean last_command, + const GError *error, + GVariant **result, + GError **result_error); + #endif /* MM_PORT_PROBE_AT_H */ diff --git a/src/mm-port-probe.c b/src/mm-port-probe.c index 2dd3b4fb..08468a75 100644 --- a/src/mm-port-probe.c +++ b/src/mm-port-probe.c @@ -41,6 +41,7 @@ * |----> AT? * |----> Vendor * |----> Product + * |----> Is Icera? * ----> QCDM Serial Open * |----> QCDM? */ @@ -94,6 +95,7 @@ struct _MMPortProbePrivate { gboolean is_qcdm; gchar *vendor; gchar *product; + gboolean is_icera; /* Current probing task. Only one can be available at a time */ PortProbeRunTask *task; @@ -120,7 +122,10 @@ mm_port_probe_set_result_at (MMPortProbe *self, g_udev_device_get_name (self->priv->port)); self->priv->vendor = NULL; self->priv->product = NULL; - self->priv->flags |= (MM_PORT_PROBE_AT_VENDOR | MM_PORT_PROBE_AT_PRODUCT); + self->priv->is_icera = FALSE; + self->priv->flags |= (MM_PORT_PROBE_AT_VENDOR | + MM_PORT_PROBE_AT_PRODUCT | + MM_PORT_PROBE_AT_ICERA); } } @@ -164,6 +169,25 @@ mm_port_probe_set_result_at_product (MMPortProbe *self, } void +mm_port_probe_set_result_at_icera (MMPortProbe *self, + gboolean is_icera) +{ + if (is_icera) { + mm_dbg ("(%s/%s) Modem is Icera-based", + g_udev_device_get_subsystem (self->priv->port), + g_udev_device_get_name (self->priv->port)); + self->priv->is_icera = TRUE; + self->priv->flags |= MM_PORT_PROBE_AT_ICERA; + } else { + mm_dbg ("(%s/%s) Modem is NOT Icera-based", + g_udev_device_get_subsystem (self->priv->port), + g_udev_device_get_name (self->priv->port)); + self->priv->is_icera = FALSE; + self->priv->flags |= MM_PORT_PROBE_AT_ICERA; + } +} + +void mm_port_probe_set_result_qcdm (MMPortProbe *self, gboolean qcdm) { @@ -179,9 +203,11 @@ mm_port_probe_set_result_qcdm (MMPortProbe *self, self->priv->is_at = FALSE; self->priv->vendor = NULL; self->priv->product = NULL; + self->priv->is_icera = FALSE; self->priv->flags |= (MM_PORT_PROBE_AT | MM_PORT_PROBE_AT_VENDOR | - MM_PORT_PROBE_AT_PRODUCT); + MM_PORT_PROBE_AT_PRODUCT | + MM_PORT_PROBE_AT_ICERA); } else mm_dbg ("(%s/%s) port is not QCDM-capable", g_udev_device_get_subsystem (self->priv->port), @@ -398,6 +424,23 @@ serial_probe_qcdm (MMPortProbe *self) } static void +serial_probe_at_icera_result_processor (MMPortProbe *self, + GVariant *result) +{ + if (result) { + /* If any result given, it must be a boolean */ + g_assert (g_variant_is_of_type (result, G_VARIANT_TYPE_BOOLEAN)); + + if (g_variant_get_boolean (result)) { + mm_port_probe_set_result_at_icera (self, TRUE); + return; + } + } + + mm_port_probe_set_result_at_icera (self, FALSE); +} + +static void serial_probe_at_product_result_processor (MMPortProbe *self, GVariant *result) { @@ -567,6 +610,11 @@ static const MMPortProbeAtCommand product_probing[] = { { NULL } }; +static const MMPortProbeAtCommand icera_probing[] = { + { "%IPSYS?", 3, mm_port_probe_response_processor_string }, + { NULL } +}; + static void at_custom_init_ready (MMPortProbe *self, GAsyncResult *res) @@ -635,6 +683,13 @@ serial_probe_schedule (MMPortProbe *self) task->at_result_processor = serial_probe_at_product_result_processor; task->at_commands = product_probing; } + /* Icera support check requested and not already done? */ + else if ((task->flags & MM_PORT_PROBE_AT_ICERA) && + !(self->priv->flags & MM_PORT_PROBE_AT_ICERA)) { + /* Prepare AT product probing */ + task->at_result_processor = serial_probe_at_icera_result_processor; + task->at_commands = icera_probing; + } /* If a next AT group detected, go for it */ if (task->at_result_processor && @@ -930,7 +985,8 @@ mm_port_probe_run (MMPortProbe *self, /* If any AT probing is needed, start by opening as AT port */ if (task->flags & MM_PORT_PROBE_AT || task->flags & MM_PORT_PROBE_AT_VENDOR || - task->flags & MM_PORT_PROBE_AT_PRODUCT) { + task->flags & MM_PORT_PROBE_AT_PRODUCT || + task->flags & MM_PORT_PROBE_AT_ICERA) { task->at_probing_cancellable = g_cancellable_new (); task->source_id = g_idle_add ((GSourceFunc)serial_open_at, self); return; @@ -1064,6 +1120,19 @@ mm_port_probe_get_product (MMPortProbe *self) NULL); } +gboolean +mm_port_probe_is_icera (MMPortProbe *self) +{ + g_return_val_if_fail (MM_IS_PORT_PROBE (self), FALSE); + + if (g_str_equal (g_udev_device_get_subsystem (self->priv->port), "net")) + return FALSE; + + return (self->priv->flags & MM_PORT_PROBE_AT_ICERA ? + self->priv->is_icera : + FALSE); +} + const gchar * mm_port_probe_get_port_name (MMPortProbe *self) { diff --git a/src/mm-port-probe.h b/src/mm-port-probe.h index f3b9f905..93b71c84 100644 --- a/src/mm-port-probe.h +++ b/src/mm-port-probe.h @@ -39,7 +39,8 @@ typedef enum { /*< underscore_name=mm_port_probe_flag >*/ MM_PORT_PROBE_AT = 1 << 0, MM_PORT_PROBE_AT_VENDOR = 1 << 1, MM_PORT_PROBE_AT_PRODUCT = 1 << 2, - MM_PORT_PROBE_QCDM = 1 << 3, + MM_PORT_PROBE_AT_ICERA = 1 << 3, + MM_PORT_PROBE_QCDM = 1 << 4, } MMPortProbeFlag; typedef struct _MMPortProbe MMPortProbe; @@ -90,6 +91,8 @@ void mm_port_probe_set_result_at_vendor (MMPortProbe *self, const gchar *at_vendor); void mm_port_probe_set_result_at_product (MMPortProbe *self, const gchar *at_product); +void mm_port_probe_set_result_at_icera (MMPortProbe *self, + gboolean is_icera); void mm_port_probe_set_result_qcdm (MMPortProbe *self, gboolean qcdm); @@ -114,6 +117,7 @@ gboolean mm_port_probe_is_at (MMPortProbe *self); gboolean mm_port_probe_is_qcdm (MMPortProbe *self); const gchar *mm_port_probe_get_vendor (MMPortProbe *self); const gchar *mm_port_probe_get_product (MMPortProbe *self); +gboolean mm_port_probe_is_icera (MMPortProbe *self); /* Additional helpers */ gboolean mm_port_probe_list_has_at_port (GList *list); |