port-probe: include Icera support check in the probing sequence
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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 */
|
||||
|
||||
+72
-3
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -163,6 +168,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),
|
||||
@@ -397,6 +423,23 @@ serial_probe_qcdm (MMPortProbe *self)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
|
||||
+5
-1
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user