base-modem: implement new modem-wide cancellable, and rework AT commands

Instead of the `_in_port()' variants, we'll provide more generic
`_full()' methods. These should be used either if we want to send commands
to a specific port, or if we want to use a specific user-provided GCancellable.

In addition to this user-provided GCancellable, we keep the internal modem-wide
one.
This commit is contained in:
Aleksander Morgado
2012-03-16 14:53:23 +01:00
parent 215c278082
commit cdd339f802
16 changed files with 334 additions and 390 deletions
@@ -118,20 +118,16 @@ enable_unsolicited_events (MMIfaceModem3gpp *self,
GAsyncReadyCallback callback,
gpointer user_data)
{
mm_base_modem_at_command_in_port (
MM_BASE_MODEM (self),
/* Only primary port is expected in the Cinterion modems */
mm_base_modem_peek_port_primary (MM_BASE_MODEM (self)),
/* AT=CMER=[<mode>[,<keyp>[,<disp>[,<ind>[,<bfr>]]]]]
* but <ind> should be either not set, or equal to 0 or 2.
* Enabled with 2.
*/
"+CMER=3,0,0,2",
3,
FALSE,
NULL, /* cancellable */
callback,
user_data);
/* AT=CMER=[<mode>[,<keyp>[,<disp>[,<ind>[,<bfr>]]]]]
* but <ind> should be either not set, or equal to 0 or 2.
* Enabled with 2.
*/
mm_base_modem_at_command (MM_BASE_MODEM (self),
"+CMER=3,0,0,2",
3,
FALSE,
callback,
user_data);
}
/*****************************************************************************/
@@ -158,7 +154,6 @@ messaging_enable_unsolicited_events (MMIfaceModemMessaging *self,
"+CNMI=2,1,2,2,1",
3,
FALSE,
NULL, /* cancellable */
callback,
user_data);
}
@@ -204,7 +199,6 @@ send_sleep_mode_command (MMBroadbandModemCinterion *self,
self->priv->sleep_mode_cmd,
5,
FALSE,
NULL, /* cancellable */
(GAsyncReadyCallback)sleep_ready,
operation_result);
return;
@@ -281,7 +275,6 @@ modem_power_down (MMIfaceModem *self,
"+CFUN=?",
3,
FALSE,
NULL, /* cancellable */
(GAsyncReadyCallback)supported_functionality_status_query_ready,
result);
}
@@ -484,7 +477,6 @@ sind_query_ready (MMBroadbandModemCinterion *self,
"^SMONG",
3,
FALSE,
NULL, /* cancellable */
(GAsyncReadyCallback)smong_query_ready,
operation_result);
}
@@ -512,7 +504,6 @@ load_access_technologies (MMIfaceModem *self,
"^SIND?",
3,
FALSE,
NULL, /* cancellable */
(GAsyncReadyCallback)sind_query_ready,
result);
return;
@@ -523,7 +514,6 @@ load_access_technologies (MMIfaceModem *self,
"^SMONG",
3,
FALSE,
NULL, /* cancellable */
(GAsyncReadyCallback)smong_query_ready,
result);
}
@@ -620,7 +610,6 @@ load_supported_modes (MMIfaceModem *self,
"+WS46=?",
3,
FALSE,
NULL, /* cancellable */
(GAsyncReadyCallback)supported_networks_query_ready,
result);
}
@@ -708,7 +697,6 @@ set_allowed_modes (MMIfaceModem *self,
cmd->str,
3,
FALSE,
NULL, /* cancellable */
(GAsyncReadyCallback)allowed_access_technology_update_ready,
result);
g_string_free (cmd, TRUE);
@@ -983,7 +971,6 @@ load_current_bands (MMIfaceModem *self,
"AT^SCFG=\"Radio/Band\"",
3,
FALSE,
NULL, /* cancellable */
(GAsyncReadyCallback)((!broadband->priv->only_utran &&
!broadband->priv->both_geran_utran) ?
get_2g_band_ready :
@@ -1082,7 +1069,6 @@ set_bands_3g (MMIfaceModem *self,
cmd,
3,
FALSE,
NULL, /* cancellable */
(GAsyncReadyCallback)scfg_set_ready,
result);
g_free (cmd);
@@ -1179,7 +1165,6 @@ set_bands_2g (MMIfaceModem *self,
cmd,
3,
FALSE,
NULL, /* cancellable */
(GAsyncReadyCallback)scfg_set_ready,
result);
@@ -1261,7 +1246,6 @@ setup_flow_control (MMIfaceModem *self,
"\\Q3",
3,
FALSE,
NULL, /* cancellable */
(GAsyncReadyCallback)setup_flow_control_ready,
result);
}
-1
View File
@@ -81,7 +81,6 @@ load_access_technologies (MMIfaceModem *self,
"*CNTI=0",
3,
FALSE,
NULL, /* cancellable */
callback,
user_data);
}
+6 -6
View File
@@ -114,7 +114,7 @@ connect_report_ready (MMBaseModem *modem,
}
/* If we got a proper extended reply, build the new error to be set */
result = mm_base_modem_at_command_in_port_finish (modem, res, NULL);
result = mm_base_modem_at_command_full_finish (modem, res, NULL);
if (result &&
g_str_has_prefix (result, "+CEER: ") &&
strlen (result) > 7) {
@@ -146,10 +146,10 @@ dial_ready (MMBaseModem *modem,
/* DO NOT check for cancellable here. If we got here without errors, the
* bearer is really connected and therefore we need to reflect that in
* the state machine. */
mm_base_modem_at_command_in_port_finish (modem, res, &(ctx->saved_error));
mm_base_modem_at_command_full_finish (modem, res, &(ctx->saved_error));
if (ctx->saved_error) {
/* Try to get more information why it failed */
mm_base_modem_at_command_in_port (
mm_base_modem_at_command_full (
modem,
ctx->primary,
"+CEER",
@@ -199,7 +199,7 @@ service_type_ready (MMBaseModem *modem,
}
/* Errors setting the service type will be critical */
mm_base_modem_at_command_in_port_finish (modem, res, &error);
mm_base_modem_at_command_full_finish (modem, res, &error);
if (error) {
g_simple_async_result_take_error (ctx->result, error);
connect_context_complete_and_free (ctx);
@@ -209,7 +209,7 @@ service_type_ready (MMBaseModem *modem,
/* We just use the default number to dial in the Iridium network. Also note
* that we won't specify a specific port to use; Iridium modems only expose
* one. */
mm_base_modem_at_command_in_port (
mm_base_modem_at_command_full (
modem,
ctx->primary,
"ATDT008816000025",
@@ -249,7 +249,7 @@ connect (MMBearer *self,
/* Bearer service type set to 9600bps (V.110), which behaves better than the
* default 9600bps (V.32). */
mm_base_modem_at_command_in_port (
mm_base_modem_at_command_full (
modem,
ctx->primary,
"+CBST=71,0,1",
@@ -88,7 +88,6 @@ after_atz_sleep_cb (GSimpleAsyncResult *simple)
modem_init_sequence,
NULL, /* response_processor_context */
NULL, /* response_processor_context_free */
NULL, /* cancellable */
(GAsyncReadyCallback)init_sequence_ready,
simple);
g_object_unref (self);
@@ -132,7 +131,6 @@ modem_init (MMIfaceModem *self,
"Z",
3,
TRUE,
NULL, /* cancellable */
(GAsyncReadyCallback)atz_ready,
result);
}
@@ -201,7 +199,6 @@ messaging_enable_unsolicited_events (MMIfaceModemMessaging *self,
"+CNMI=2,1,0,0,1",
3,
FALSE,
NULL, /* cancellable */
callback,
user_data);
}
@@ -251,7 +248,6 @@ load_signal_quality (MMIfaceModem *self,
"+CSQF",
3,
FALSE,
NULL, /* cancellable */
callback,
user_data);
}
@@ -308,7 +304,6 @@ setup_flow_control (MMIfaceModem *self,
"&K3",
3,
FALSE,
NULL, /* cancellable */
(GAsyncReadyCallback)setup_flow_control_ready,
result);
}
-1
View File
@@ -79,7 +79,6 @@ modem_init (MMIfaceModem *self,
modem_init_sequence,
NULL, /* response_processor_context */
NULL, /* response_processor_context_free */
NULL, /* cancellable */
callback,
user_data);
}
@@ -171,7 +171,6 @@ connect_3gpp_qmistatus (DetailedConnectContext *ctx)
"$NWQMISTATUS",
3, /* timeout */
FALSE, /* allow_cached */
NULL, /* cancellable */
(GAsyncReadyCallback)connect_3gpp_qmistatus_ready, /* callback */
ctx); /* user_data */
@@ -230,7 +229,6 @@ connect_3gpp (MMBroadbandBearer *self,
"$NWQMICONNECT=,,,,,,,,,,",
10, /* timeout */
FALSE, /* allow_cached */
NULL, /* cancellable */
(GAsyncReadyCallback)connect_3gpp_qmiconnect_ready,
ctx); /* user_data */
}
@@ -338,7 +336,6 @@ disconnect_3gpp_check_status (MMBaseModem *modem,
"$NWQMISTATUS",
3, /* timeout */
FALSE, /* allow_cached */
NULL, /* cancellable */
(GAsyncReadyCallback)disconnect_3gpp_status_complete,
ctx); /* user_data */
}
@@ -362,7 +359,6 @@ disconnect_3gpp (MMBroadbandBearer *self,
"$NWQMIDISCONNECT",
10, /* timeout */
FALSE, /* allow_cached */
NULL, /* cancellable */
(GAsyncReadyCallback)disconnect_3gpp_check_status,
ctx); /* user_data */
}
@@ -206,7 +206,6 @@ load_supported_modes (MMIfaceModem *self,
"+WS46=?",
3,
FALSE,
NULL, /* cancellable */
(GAsyncReadyCallback)supported_networks_query_ready,
result);
}
@@ -362,7 +361,6 @@ load_current_bands (MMIfaceModem *self,
"$NWBAND?",
3,
FALSE,
NULL,
(GAsyncReadyCallback)load_current_bands_done,
result);
}
@@ -424,7 +422,6 @@ set_bands (MMIfaceModem *self,
cmd,
3,
FALSE,
NULL,
(GAsyncReadyCallback)set_bands_done,
result);
@@ -306,7 +306,6 @@ load_access_technologies_step (AccessTechnologiesContext *ctx)
"_OSSYS?",
3,
FALSE,
NULL, /* cancellable */
(GAsyncReadyCallback)ossys_query_ready,
ctx);
break;
@@ -317,7 +316,6 @@ load_access_technologies_step (AccessTechnologiesContext *ctx)
"_OCTI?",
3,
FALSE,
NULL, /* cancellable */
(GAsyncReadyCallback)octi_query_ready,
ctx);
return;
@@ -331,7 +329,6 @@ load_access_technologies_step (AccessTechnologiesContext *ctx)
"_OWCTI?",
3,
FALSE,
NULL, /* cancellable */
(GAsyncReadyCallback)owcti_query_ready,
ctx);
return;