summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@aleksander.es>2014-02-26 12:37:01 +0100
committerAleksander Morgado <aleksander@aleksander.es>2014-02-28 16:35:17 +0100
commita9a4a2a337d14baecbcc6a76670ed48ce6b91259 (patch)
treef8de703efc9a9af9939a95dfff74c18e9ecc9178
parent177f15f295810614d1ee8f845745b9b40a02dac7 (diff)
cinterion: allow recovering automatic mode
When automatic mode (i.e. 2G+3G+none preferred) is selected, we need to explicitly request it by giving the AT+COPS write command with values (i.e. not just empty fields).
-rw-r--r--plugins/cinterion/mm-broadband-modem-cinterion.c34
1 files changed, 21 insertions, 13 deletions
diff --git a/plugins/cinterion/mm-broadband-modem-cinterion.c b/plugins/cinterion/mm-broadband-modem-cinterion.c
index 1348e3d3..dd1dca5b 100644
--- a/plugins/cinterion/mm-broadband-modem-cinterion.c
+++ b/plugins/cinterion/mm-broadband-modem-cinterion.c
@@ -773,13 +773,14 @@ allowed_access_technology_update_ready (MMBroadbandModemCinterion *self,
}
static void
-set_current_modes (MMIfaceModem *self,
+set_current_modes (MMIfaceModem *_self,
MMModemMode allowed,
MMModemMode preferred,
GAsyncReadyCallback callback,
gpointer user_data)
{
GSimpleAsyncResult *result;
+ MMBroadbandModemCinterion *self = MM_BROADBAND_MODEM_CINTERION (_self);
g_assert (preferred == MM_MODEM_MODE_NONE);
@@ -789,9 +790,9 @@ set_current_modes (MMIfaceModem *self,
set_current_modes);
/* For dual 2G/3G devices... */
- if (mm_iface_modem_is_2g (self) &&
- mm_iface_modem_is_3g (self)) {
- GString *cmd;
+ if (mm_iface_modem_is_2g (_self) &&
+ mm_iface_modem_is_3g (_self)) {
+ gchar *command;
/* We will try to simulate the possible allowed modes here. The
* Cinterion devices do not seem to allow setting preferred access
@@ -802,24 +803,31 @@ set_current_modes (MMIfaceModem *self,
* - for the remaining ones, we default to automatic selection of RAT,
* which is based on the quality of the connection.
*/
- cmd = g_string_new ("+COPS=,,,");
- if (allowed == MM_MODEM_MODE_3G) {
- g_string_append (cmd, "2");
- } else if (allowed == MM_MODEM_MODE_2G) {
- g_string_append (cmd, "0");
- } else if (allowed == (MM_MODEM_MODE_3G | MM_MODEM_MODE_2G)) {
- /* no AcT given, defaults to Auto */
+
+ if (allowed == MM_MODEM_MODE_3G)
+ command = g_strdup ("+COPS=,,,2");
+ else if (allowed == MM_MODEM_MODE_2G)
+ command = g_strdup ("+COPS=,,,0");
+ else if (allowed == (MM_MODEM_MODE_3G | MM_MODEM_MODE_2G)) {
+ /* no AcT given, defaults to Auto. For this case, we cannot provide
+ * AT+COPS=,,, (i.e. just without a last value). Instead, we need to
+ * re-run the last manual/automatic selection command which succeeded,
+ * (or auto by default if none was launched) */
+ if (self->priv->manual_operator_id)
+ command = g_strdup_printf ("+COPS=1,2,\"%s\"", self->priv->manual_operator_id);
+ else
+ command = g_strdup ("+COPS=0");
} else
g_assert_not_reached ();
mm_base_modem_at_command (
MM_BASE_MODEM (self),
- cmd->str,
+ command,
20,
FALSE,
(GAsyncReadyCallback)allowed_access_technology_update_ready,
result);
- g_string_free (cmd, TRUE);
+ g_free (command);
return;
}