gsm: fix direct registration info requests
This commit is contained in:
@@ -1250,8 +1250,7 @@ get_reg_status_done (MMSerialPort *port,
|
|||||||
GMatchInfo *match_info;
|
GMatchInfo *match_info;
|
||||||
char *tmp;
|
char *tmp;
|
||||||
guint id;
|
guint id;
|
||||||
|
gboolean status_done;
|
||||||
g_warn_if_fail (info == priv->pending_reg_info);
|
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
info->error = g_error_copy (error);
|
info->error = g_error_copy (error);
|
||||||
@@ -1285,31 +1284,38 @@ get_reg_status_done (MMSerialPort *port,
|
|||||||
g_regex_unref (r);
|
g_regex_unref (r);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( reg_status >= 0
|
if (reg_status >= 0) {
|
||||||
&& !reg_status_updated (self, reg_status, &info->error)
|
/* Update cached registration status */
|
||||||
&& priv->pending_reg_info) {
|
status_done = reg_status_updated (self, reg_status, &info->error);
|
||||||
g_clear_error (&info->error);
|
|
||||||
|
|
||||||
/* Not registered yet; poll registration status again */
|
/* If we're waiting for automatic registration to complete and it's
|
||||||
id = g_timeout_add_seconds (1, reg_status_again, info);
|
* not done yet, check again in a few seconds.
|
||||||
mm_callback_info_set_data (info, REG_STATUS_AGAIN_TAG,
|
*/
|
||||||
GUINT_TO_POINTER (id),
|
if ((info == priv->pending_reg_info) && !status_done) {
|
||||||
reg_status_again_remove);
|
g_clear_error (&info->error);
|
||||||
return;
|
|
||||||
|
/* Not registered yet; poll registration status again */
|
||||||
|
id = g_timeout_add_seconds (1, reg_status_again, info);
|
||||||
|
mm_callback_info_set_data (info, REG_STATUS_AGAIN_TAG,
|
||||||
|
GUINT_TO_POINTER (id),
|
||||||
|
reg_status_again_remove);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
reg_done:
|
reg_done:
|
||||||
/* This will schedule the callback for us */
|
if (info == priv->pending_reg_info) {
|
||||||
mm_generic_gsm_pending_registration_stop (self);
|
/* For pending registration, this will schedule the callback for us */
|
||||||
|
mm_generic_gsm_pending_registration_stop (self);
|
||||||
|
} else {
|
||||||
|
/* Otherwise for a direct registration request, schedule the callback now */
|
||||||
|
mm_callback_info_schedule (info);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
get_registration_status (MMSerialPort *port, MMCallbackInfo *info)
|
get_registration_status (MMSerialPort *port, MMCallbackInfo *info)
|
||||||
{
|
{
|
||||||
MMGenericGsmPrivate *priv = MM_GENERIC_GSM_GET_PRIVATE (info->modem);
|
|
||||||
|
|
||||||
g_warn_if_fail (info == priv->pending_reg_info);
|
|
||||||
|
|
||||||
mm_serial_port_queue_command (port, "+CREG?", 10, get_reg_status_done, info);
|
mm_serial_port_queue_command (port, "+CREG?", 10, get_reg_status_done, info);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1418,14 +1424,28 @@ get_registration_info (MMModemGsmNetwork *self,
|
|||||||
MMModemGsmNetworkRegInfoFn callback,
|
MMModemGsmNetworkRegInfoFn callback,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
{
|
{
|
||||||
|
MMGenericGsmPrivate *priv = MM_GENERIC_GSM_GET_PRIVATE (self);
|
||||||
MMCallbackInfo *info;
|
MMCallbackInfo *info;
|
||||||
|
MMSerialPort *port = priv->primary;
|
||||||
|
|
||||||
info = mm_callback_info_new_full (MM_MODEM (self),
|
info = mm_callback_info_new_full (MM_MODEM (self),
|
||||||
gsm_network_reg_info_invoke,
|
gsm_network_reg_info_invoke,
|
||||||
G_CALLBACK (callback),
|
G_CALLBACK (callback),
|
||||||
user_data);
|
user_data);
|
||||||
|
|
||||||
mm_callback_info_schedule (info);
|
if (mm_port_get_connected (MM_PORT (priv->primary))) {
|
||||||
|
if (!priv->secondary) {
|
||||||
|
info->error = g_error_new_literal (MM_MODEM_ERROR, MM_MODEM_ERROR_CONNECTED,
|
||||||
|
"Cannot get registration info while connected");
|
||||||
|
mm_callback_info_schedule (info);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Use secondary port if primary is connected */
|
||||||
|
port = priv->secondary;
|
||||||
|
}
|
||||||
|
|
||||||
|
get_registration_status (port, info);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
Reference in New Issue
Block a user