static void parse_modem_eri (DetailedRegistrationStateContext *ctx, QcdmResult *result) { MMModemCdmaRegistrationState new_state; guint8 indicator_id = 0, icon_id = 0, icon_mode = 0; qcdm_result_get_u8 (result, QCDM_CMD_NW_SUBSYS_ERI_ITEM_INDICATOR_ID, &indicator_id); qcdm_result_get_u8 (result, QCDM_CMD_NW_SUBSYS_ERI_ITEM_ICON_ID, &icon_id); qcdm_result_get_u8 (result, QCDM_CMD_NW_SUBSYS_ERI_ITEM_ICON_MODE, &icon_mode); /* We use the "Icon ID" (also called the "Icon Index") because if it is 1, * the device is never roaming. Any operator-defined IDs (greater than 2) * may or may not be roaming, but that's operator-defined and we don't * know anything about them. * * Indicator ID: * 0 appears to be "not roaming", contrary to standard ERI values * >= 1 appears to be the actual ERI value, which may or may not be * roaming depending on the operator's custom ERI list * * Icon ID: * 0 = roaming indicator on * 1 = roaming indicator off * 2 = roaming indicator flash * * Icon Mode: * 0 = normal * 1 = flash (only used with Icon ID >= 2) * * Roaming example: * Roam: 160 * Indicator ID: 160 * Icon ID: 3 * Icon Mode: 0 * Call Prompt: 1 * * Home example: * Roam: 0 * Indicator ID: 0 * Icon ID: 1 * Icon Mode: 0 * Call Prompt: 1 */ if (icon_id == 1) new_state = MM_MODEM_CDMA_REGISTRATION_STATE_HOME; else new_state = MM_MODEM_CDMA_REGISTRATION_STATE_ROAMING; if (ctx->state.detailed_cdma1x_state != MM_MODEM_CDMA_REGISTRATION_STATE_UNKNOWN) ctx->state.detailed_cdma1x_state = new_state; if (ctx->state.detailed_evdo_state != MM_MODEM_CDMA_REGISTRATION_STATE_UNKNOWN) ctx->state.detailed_evdo_state = new_state; }
static void nw_snapshot_old_cb (MMPortSerialQcdm *port, GAsyncResult *res, SnapshotContext *ctx) { QcdmResult *result; guint8 hdr_revision = QCDM_HDR_REV_UNKNOWN; GError *error = NULL; GByteArray *response; response = mm_port_serial_qcdm_command_finish (port, res, &error); if (error) { /* Just ignore the error and complete with the input info */ mm_dbg ("Couldn't run QCDM Novatel Modem MSM6500 snapshot: '%s'", error->message); g_error_free (error); snapshot_context_complete_and_free (ctx, QCDM_HDR_REV_UNKNOWN); return; } /* Parse the response */ result = qcdm_cmd_nw_subsys_modem_snapshot_cdma_result ((const gchar *) response->data, response->len, NULL); g_byte_array_unref (response); if (result) { qcdm_result_get_u8 (result, QCDM_CMD_NW_SUBSYS_MODEM_SNAPSHOT_CDMA_ITEM_HDR_REV, &hdr_revision); qcdm_result_unref (result); } else mm_dbg ("Failed to get QCDM Novatel Modem MSM6500 snapshot."); snapshot_context_complete_and_free (ctx, hdr_revision); }
static void parse_modem_snapshot (MMCallbackInfo *info, QcdmResult *result) { MMModemCdmaRegistrationState evdo_state, cdma1x_state, new_state; guint8 eri = 0; g_return_if_fail (info != NULL); g_return_if_fail (result != NULL); evdo_state = mm_generic_cdma_query_reg_state_get_callback_evdo_state (info); cdma1x_state = mm_generic_cdma_query_reg_state_get_callback_1x_state (info); /* Roaming? */ if (qcdm_result_get_u8 (result, QCDM_CMD_NW_SUBSYS_MODEM_SNAPSHOT_CDMA_ITEM_ERI, &eri)) { char *str; gboolean roaming = FALSE; str = g_strdup_printf ("%u", eri); if (mm_cdma_parse_eri (str, &roaming, NULL, NULL)) { new_state = roaming ? MM_MODEM_CDMA_REGISTRATION_STATE_HOME : MM_MODEM_CDMA_REGISTRATION_STATE_ROAMING; if (cdma1x_state != MM_MODEM_CDMA_REGISTRATION_STATE_UNKNOWN) mm_generic_cdma_query_reg_state_set_callback_1x_state (info, new_state); if (evdo_state != MM_MODEM_CDMA_REGISTRATION_STATE_UNKNOWN) mm_generic_cdma_query_reg_state_set_callback_evdo_state (info, new_state); } g_free (str); } }
static void nw_snapshot_new_cb (MMPortSerialQcdm *port, GAsyncResult *res, SnapshotContext *ctx) { QcdmResult *result; GByteArray *nwsnap; guint8 hdr_revision = QCDM_HDR_REV_UNKNOWN; GError *error = NULL; GByteArray *response; response = mm_port_serial_qcdm_command_finish (port, res, &error); if (error) { mm_dbg ("Couldn't run QCDM Novatel Modem MSM6800 snapshot: '%s'", error->message); g_error_free (error); snapshot_context_complete_and_free (ctx, QCDM_HDR_REV_UNKNOWN); return; } /* Parse the response */ result = qcdm_cmd_nw_subsys_modem_snapshot_cdma_result ((const gchar *) response->data, response->len, NULL); g_byte_array_unref (response); if (result) { qcdm_result_get_u8 (result, QCDM_CMD_NW_SUBSYS_MODEM_SNAPSHOT_CDMA_ITEM_HDR_REV, &hdr_revision); qcdm_result_unref (result); snapshot_context_complete_and_free (ctx, hdr_revision); return; } mm_dbg ("Failed to get QCDM Novatel Modem MSM6800 snapshot."); /* Try for MSM6500 */ nwsnap = g_byte_array_sized_new (25); nwsnap->len = qcdm_cmd_nw_subsys_modem_snapshot_cdma_new ((char *) nwsnap->data, 25, QCDM_NW_CHIPSET_6500); g_assert (nwsnap->len); mm_port_serial_qcdm_command (port, nwsnap, 3, NULL, (GAsyncReadyCallback)nw_snapshot_old_cb, ctx); g_byte_array_unref (nwsnap); }