icera: consolidate Icera check code into utility lib
This commit is contained in:
@@ -263,3 +263,36 @@ mm_icera_utils_get_access_technology (MMGenericGsm *modem,
|
||||
mm_at_serial_port_queue_command (port, "%NWSTATE=1", 3, get_nwstate_done, info);
|
||||
}
|
||||
|
||||
static void
|
||||
icera_check_done (MMAtSerialPort *port,
|
||||
GString *response,
|
||||
GError *error,
|
||||
gpointer user_data)
|
||||
{
|
||||
MMCallbackInfo *info = user_data;
|
||||
|
||||
info->error = mm_modem_check_removed (info->modem, error);
|
||||
if (!info->error)
|
||||
mm_callback_info_set_result (info, GUINT_TO_POINTER (TRUE), NULL);
|
||||
mm_callback_info_schedule (info);
|
||||
}
|
||||
|
||||
void
|
||||
mm_icera_utils_is_icera (MMGenericGsm *modem,
|
||||
MMModemUIntFn callback,
|
||||
gpointer user_data)
|
||||
{
|
||||
MMAtSerialPort *port;
|
||||
MMCallbackInfo *info;
|
||||
|
||||
info = mm_callback_info_uint_new (MM_MODEM (modem), callback, user_data);
|
||||
|
||||
port = mm_generic_gsm_get_best_at_port (modem, &info->error);
|
||||
if (!port) {
|
||||
mm_callback_info_schedule (info);
|
||||
return;
|
||||
}
|
||||
|
||||
mm_at_serial_port_queue_command (port, "%IPSYS?", 5, icera_check_done, info);
|
||||
}
|
||||
|
||||
|
@@ -41,5 +41,9 @@ void mm_icera_utils_get_access_technology (MMGenericGsm *modem,
|
||||
MMModemUIntFn callback,
|
||||
gpointer user_data);
|
||||
|
||||
void mm_icera_utils_is_icera (MMGenericGsm *modem,
|
||||
MMModemUIntFn callback,
|
||||
gpointer user_data);
|
||||
|
||||
#endif /* MM_ICERA_UTILS_H */
|
||||
|
||||
|
@@ -364,15 +364,15 @@ static void enable_flash_done (MMSerialPort *port,
|
||||
gpointer user_data);
|
||||
|
||||
static void
|
||||
icera_check_cb (MMAtSerialPort *port,
|
||||
GString *response,
|
||||
icera_check_cb (MMModem *modem,
|
||||
guint32 result,
|
||||
GError *error,
|
||||
gpointer user_data)
|
||||
{
|
||||
if (!error) {
|
||||
MMModemZte *self = MM_MODEM_ZTE (user_data);
|
||||
|
||||
MM_MODEM_ZTE_GET_PRIVATE (self)->is_icera = TRUE;
|
||||
MM_MODEM_ZTE_GET_PRIVATE (self)->is_icera = !!result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -383,7 +383,8 @@ pre_init_done (MMAtSerialPort *port,
|
||||
gpointer user_data)
|
||||
{
|
||||
MMCallbackInfo *info = (MMCallbackInfo *) user_data;
|
||||
MMModemZtePrivate *priv = MM_MODEM_ZTE_GET_PRIVATE (info->modem);
|
||||
MMModemZte *self = MM_MODEM_ZTE (info->modem);
|
||||
MMModemZtePrivate *priv = MM_MODEM_ZTE_GET_PRIVATE (self);
|
||||
|
||||
if (error) {
|
||||
/* Retry the init string one more time; the modem sometimes throws it away */
|
||||
@@ -392,10 +393,10 @@ pre_init_done (MMAtSerialPort *port,
|
||||
priv->init_retried = TRUE;
|
||||
enable_flash_done (MM_SERIAL_PORT (port), NULL, user_data);
|
||||
} else
|
||||
mm_generic_gsm_enable_complete (MM_GENERIC_GSM (info->modem), error, info);
|
||||
mm_generic_gsm_enable_complete (MM_GENERIC_GSM (self), error, info);
|
||||
} else {
|
||||
/* Finish the initialization */
|
||||
mm_at_serial_port_queue_command (port, "%IPSYS?", 10, icera_check_cb, info->modem);
|
||||
mm_icera_utils_is_icera (MM_GENERIC_GSM (self), icera_check_cb, self);
|
||||
mm_at_serial_port_queue_command (port, "Z E0 V1 X4 &C1 +CMEE=1;+CFUN=1;", 10, init_modem_done, info);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user