static gboolean getportmode_response_cb (MMPluginBaseSupportsTask *task, GString *response, GError *error, guint32 tries, gboolean *out_stop, guint32 *out_level, gpointer user_data) { /* If any error occurred that was not ERROR or COMMAND NOT SUPPORT then * retry the command. */ if (error) { if (g_error_matches (error, MM_MOBILE_ERROR, MM_MOBILE_ERROR_UNKNOWN) == FALSE) return tries <= 4 ? TRUE : FALSE; } else { MMPlugin *plugin = mm_plugin_base_supports_task_get_plugin (task); cache_port_mode (plugin, response->str, "PCUI:", TAG_HUAWEI_PCUI_PORT); cache_port_mode (plugin, response->str, "MDM:", TAG_HUAWEI_MODEM_PORT); cache_port_mode (plugin, response->str, "DIAG:", TAG_HUAWEI_DIAG_PORT); g_object_set_data (G_OBJECT (plugin), TAG_GETPORTMODE_SUPPORTED, GUINT_TO_POINTER (1)); } /* No error or if ^GETPORTMODE is not supported, assume success */ return FALSE; }
static void getportmode_ready (MMAtSerialPort *port, GString *response, GError *error, HuaweiCustomInitContext *ctx) { if (error) { mm_dbg ("(Huawei) couldn't get port mode: '%s'", error->message); /* If any error occurred that was not ERROR or COMMAND NOT SUPPORT then * retry the command. */ if (!g_error_matches (error, MM_MOBILE_EQUIPMENT_ERROR, MM_MOBILE_EQUIPMENT_ERROR_UNKNOWN)) { /* Retry */ huawei_custom_init_step (ctx); return; } /* Port mode not supported */ } else { MMDevice *device; mm_dbg ("(Huawei) port mode layout retrieved"); /* Results are cached in the parent device object */ device = mm_port_probe_peek_device (ctx->probe); cache_port_mode (device, response->str, "PCUI:", TAG_HUAWEI_PCUI_PORT); cache_port_mode (device, response->str, "MDM:", TAG_HUAWEI_MODEM_PORT); cache_port_mode (device, response->str, "NDIS:", TAG_HUAWEI_NDIS_PORT); cache_port_mode (device, response->str, "DIAG:", TAG_HUAWEI_DIAG_PORT); g_object_set_data (G_OBJECT (device), TAG_GETPORTMODE_SUPPORTED, GUINT_TO_POINTER (TRUE)); /* Mark port as being AT already */ mm_port_probe_set_result_at (ctx->probe, TRUE); } ctx->getportmode_done = TRUE; huawei_custom_init_step (ctx); }
static void getportmode_ready (MMPortSerialAt *port, GAsyncResult *res, HuaweiCustomInitContext *ctx) { const gchar *response; GError *error = NULL; response = mm_port_serial_at_command_finish (port, res, &error); if (error) { mm_dbg ("(Huawei) couldn't get port mode: '%s'", error->message); /* If any error occurred that was not ERROR or COMMAND NOT SUPPORT then * retry the command. */ if (!g_error_matches (error, MM_MOBILE_EQUIPMENT_ERROR, MM_MOBILE_EQUIPMENT_ERROR_UNKNOWN)) goto out; /* Port mode not supported */ } else { MMDevice *device; mm_dbg ("(Huawei) port mode layout retrieved"); /* Results are cached in the parent device object */ device = mm_port_probe_peek_device (ctx->probe); cache_port_mode (device, response, "PCUI:", TAG_HUAWEI_PCUI_PORT); cache_port_mode (device, response, "MDM:", TAG_HUAWEI_MODEM_PORT); cache_port_mode (device, response, "NDIS:", TAG_HUAWEI_NDIS_PORT); cache_port_mode (device, response, "DIAG:", TAG_HUAWEI_DIAG_PORT); /* GETPORTMODE response format in newer devices... (e.g. E3372) */ cache_port_mode (device, response, "pcui:", TAG_HUAWEI_PCUI_PORT); cache_port_mode (device, response, "modem:", TAG_HUAWEI_MODEM_PORT); g_object_set_data (G_OBJECT (device), TAG_GETPORTMODE_SUPPORTED, GUINT_TO_POINTER (TRUE)); /* Mark port as being AT already */ mm_port_probe_set_result_at (ctx->probe, TRUE); } ctx->getportmode_done = TRUE; out: if (error) g_error_free (error); huawei_custom_init_step (ctx); }
static void getportcfg_ready (MMPortSerialAt *port, GAsyncResult *res, TelitCustomInitContext *ctx) { const gchar *response; GError *error = NULL; response = mm_port_serial_at_command_finish (port, res, &error); if (error) { mm_dbg ("telit: couldn't get port mode: '%s'", error->message); /* If ERROR or COMMAND NOT SUPPORT occur then do not retry the * command. */ if (g_error_matches (error, MM_MOBILE_EQUIPMENT_ERROR, MM_MOBILE_EQUIPMENT_ERROR_UNKNOWN)) ctx->getportcfg_done = TRUE; } else { MMDevice *device; device = mm_port_probe_peek_device (ctx->probe); /* Results are cached in the parent device object */ if (g_object_get_data (G_OBJECT (device), TAG_GETPORTCFG_SUPPORTED) == NULL) { mm_dbg ("telit: retrieving port mode layout"); if (cache_port_mode (device, response)) { g_object_set_data (G_OBJECT (device), TAG_GETPORTCFG_SUPPORTED, GUINT_TO_POINTER (TRUE)); ctx->getportcfg_done = TRUE; } } /* Port answered to #PORTCFG, so mark it as being AT already */ mm_port_probe_set_result_at (ctx->probe, TRUE); } if (error) g_error_free (error); telit_custom_init_step (ctx); }