static void nwdmat_ready (MMPortSerialAt *port, GAsyncResult *res, CustomInitContext *ctx) { const gchar *response; GError *error = NULL; response = mm_port_serial_at_command_finish (port, res, &error); if (error) { if (g_error_matches (error, MM_SERIAL_ERROR, MM_SERIAL_ERROR_RESPONSE_TIMEOUT)) { custom_init_step (ctx); goto out; } mm_dbg ("(Novatel) Error flipping secondary ports to AT mode: %s", error->message); } /* Finish custom_init */ g_simple_async_result_set_op_res_gboolean (ctx->result, TRUE); custom_init_context_complete_and_free (ctx); out: if (error) g_error_free (error); }
static void custom_init_step (CustomInitContext *ctx) { /* If cancelled, end */ if (g_cancellable_is_cancelled (ctx->cancellable)) { mm_dbg ("(Novatel) no need to keep on running custom init in (%s)", mm_port_get_device (MM_PORT (ctx->port))); g_simple_async_result_set_op_res_gboolean (ctx->result, TRUE); custom_init_context_complete_and_free (ctx); return; } /* If device has a QMI port, don't run $NWDMAT */ if (mm_port_probe_list_has_qmi_port (mm_device_peek_port_probe_list (mm_port_probe_peek_device (ctx->probe)))) { mm_dbg ("(Novatel) no need to run custom init in (%s): device has QMI port", mm_port_get_device (MM_PORT (ctx->port))); g_simple_async_result_set_op_res_gboolean (ctx->result, TRUE); custom_init_context_complete_and_free (ctx); return; } if (ctx->wait_time > 0) { ctx->wait_time--; g_timeout_add_seconds (1, (GSourceFunc)custom_init_wait_cb, ctx); return; } if (ctx->nwdmat_retries > 0) { ctx->nwdmat_retries--; mm_port_serial_at_command (ctx->port, "$NWDMAT=1", 3, FALSE, /* raw */ FALSE, /* allow_cached */ ctx->cancellable, (GAsyncReadyCallback)nwdmat_ready, ctx); return; } /* Finish custom_init */ mm_dbg ("(Novatel) couldn't flip secondary port to AT in (%s): all retries consumed", mm_port_get_device (MM_PORT (ctx->port))); g_simple_async_result_set_op_res_gboolean (ctx->result, TRUE); custom_init_context_complete_and_free (ctx); }
static void novatel_custom_init_ready (MMPortProbe *probe, GAsyncResult *res, CustomInitContext *ctx) { GError *error = NULL; if (!mm_common_novatel_custom_init_finish (probe, res, &error)) g_simple_async_result_take_error (ctx->result, error); else g_simple_async_result_set_op_res_gboolean (ctx->result, TRUE); custom_init_context_complete_and_free (ctx); }
static void custom_init_step (CustomInitContext *ctx) { /* If cancelled, end */ if (g_cancellable_is_cancelled (ctx->cancellable)) { mm_dbg ("(Dell) no need to keep on running custom init in (%s)", mm_port_get_device (MM_PORT (ctx->port))); g_simple_async_result_set_op_res_gboolean (ctx->result, TRUE); custom_init_context_complete_and_free (ctx); return; } #if defined WITH_QMI /* If device has a QMI port, don't run anything else, as we don't care */ if (mm_port_probe_list_has_qmi_port (mm_device_peek_port_probe_list (mm_port_probe_peek_device (ctx->probe)))) { mm_dbg ("(Dell) no need to run custom init in (%s): device has QMI port", mm_port_get_device (MM_PORT (ctx->port))); mm_port_probe_set_result_at (ctx->probe, FALSE); mm_port_probe_set_result_qcdm (ctx->probe, FALSE); g_simple_async_result_set_op_res_gboolean (ctx->result, TRUE); custom_init_context_complete_and_free (ctx); return; } #endif #if defined WITH_MBIM /* If device has a MBIM port, don't run anything else, as we don't care */ if (mm_port_probe_list_has_mbim_port (mm_device_peek_port_probe_list (mm_port_probe_peek_device (ctx->probe)))) { mm_dbg ("(Dell) no need to run custom init in (%s): device has MBIM port", mm_port_get_device (MM_PORT (ctx->port))); mm_port_probe_set_result_at (ctx->probe, FALSE); mm_port_probe_set_result_qcdm (ctx->probe, FALSE); g_simple_async_result_set_op_res_gboolean (ctx->result, TRUE); custom_init_context_complete_and_free (ctx); return; } #endif if (ctx->gmi_retries > 0) { ctx->gmi_retries--; mm_port_serial_at_command (ctx->port, "AT+GMI", 3, FALSE, /* raw */ FALSE, /* allow_cached */ ctx->cancellable, (GAsyncReadyCallback)response_ready, ctx); return; } if (ctx->cgmi_retries > 0) { ctx->cgmi_retries--; mm_port_serial_at_command (ctx->port, "AT+CGMI", 3, FALSE, /* raw */ FALSE, /* allow_cached */ ctx->cancellable, (GAsyncReadyCallback)response_ready, ctx); return; } if (ctx->ati_retries > 0) { ctx->ati_retries--; /* Note: in Ericsson devices, ATI3 seems to reply the vendor string */ mm_port_serial_at_command (ctx->port, "ATI1I2I3", 3, FALSE, /* raw */ FALSE, /* allow_cached */ ctx->cancellable, (GAsyncReadyCallback)response_ready, ctx); return; } /* Finish custom_init */ mm_dbg ("(Dell) couldn't flip secondary port to AT in (%s): all retries consumed", mm_port_get_device (MM_PORT (ctx->port))); g_simple_async_result_set_op_res_gboolean (ctx->result, TRUE); custom_init_context_complete_and_free (ctx); }
static void response_ready (MMPortSerialAt *port, GAsyncResult *res, CustomInitContext *ctx) { const gchar *response; GError *error = NULL; gchar *lower; DellManufacturer manufacturer; response = mm_port_serial_at_command_finish (port, res, &error); if (error) { /* Non-timeout error, jump to next command */ if (!g_error_matches (error, MM_SERIAL_ERROR, MM_SERIAL_ERROR_RESPONSE_TIMEOUT)) { mm_dbg ("(Dell) Error probing AT port: %s", error->message); g_error_free (error); custom_init_step_next_command (ctx); return; } /* Directly retry same command on timeout */ custom_init_step (ctx); g_error_free (error); return; } /* Guess manufacturer from response */ lower = g_ascii_strdown (response, -1); if (strstr (lower, "novatel")) manufacturer = DELL_MANUFACTURER_NOVATEL; else if (strstr (lower, "sierra")) manufacturer = DELL_MANUFACTURER_SIERRA; else if (strstr (lower, "ericsson")) manufacturer = DELL_MANUFACTURER_ERICSSON; else if (strstr (lower, "telit")) manufacturer = DELL_MANUFACTURER_TELIT; else manufacturer = DELL_MANUFACTURER_UNKNOWN; g_free (lower); /* Tag based on manufacturer */ if (manufacturer != DELL_MANUFACTURER_UNKNOWN) { g_object_set_data (G_OBJECT (ctx->probe), TAG_DELL_MANUFACTURER, GUINT_TO_POINTER (manufacturer)); /* Run additional custom init, if needed */ if (manufacturer == DELL_MANUFACTURER_NOVATEL) { mm_common_novatel_custom_init (ctx->probe, ctx->port, ctx->cancellable, (GAsyncReadyCallback) novatel_custom_init_ready, ctx); return; } if (manufacturer == DELL_MANUFACTURER_SIERRA) { mm_common_sierra_custom_init (ctx->probe, ctx->port, ctx->cancellable, (GAsyncReadyCallback) sierra_custom_init_ready, ctx); return; } if (manufacturer == DELL_MANUFACTURER_TELIT) { telit_custom_init (ctx->probe, ctx->port, ctx->cancellable, (GAsyncReadyCallback) telit_custom_init_ready, ctx); return; } /* Finish custom_init */ g_simple_async_result_set_op_res_gboolean (ctx->result, TRUE); custom_init_context_complete_and_free (ctx); return; } /* If we got a response, but we didn't get an expected string, try with next command */ custom_init_step_next_command (ctx); }