---
 plugins/phonesim.c |   34 +++++++++++++++++++++++++++++++++-
 1 files changed, 33 insertions(+), 1 deletions(-)

diff --git a/plugins/phonesim.c b/plugins/phonesim.c
index 13f942e..0727baf 100644
--- a/plugins/phonesim.c
+++ b/plugins/phonesim.c
@@ -66,6 +66,7 @@
 
 static const char *none_prefix[] = { NULL };
 static const char *ptty_prefix[] = { "+PTTY:", NULL };
+static const char *cemode_prefix[] = { "+CEMODE:", NULL };
 static int next_iface = 0;
 
 struct phonesim_data {
@@ -73,6 +74,7 @@ struct phonesim_data {
        GAtChat *chat;
        gboolean calypso;
        gboolean use_mux;
+       int pref_ue_mode;
 };
 
 struct packet_context_data {
@@ -419,6 +421,31 @@ static void crst_notify(GAtResult *result, gpointer 
user_data)
        g_idle_add(phonesim_reset, user_data);
 }
 
+static void cemode_read_cb(gboolean ok, GAtResult *result, gpointer user_data)
+{
+       struct ofono_modem *modem = user_data;
+       struct phonesim_data *data = ofono_modem_get_data(modem);
+       GAtResultIter iter;
+       int mode;
+
+       if (!ok)
+               goto out;
+
+       g_at_result_iter_init(&iter, result);
+
+       if (g_at_result_iter_next(&iter, "+CEMODE:") == FALSE)
+               goto out;
+
+       if (g_at_result_iter_next_number(&iter, &mode) == FALSE)
+               goto out;
+
+       data->pref_ue_mode = mode;
+       ofono_modem_set_preferred_ue_mode(modem, mode);
+
+out:
+       ofono_modem_set_powered(modem, TRUE);
+}
+
 static void phonesim_disconnected(gpointer user_data)
 {
        struct ofono_modem *modem = user_data;
@@ -529,6 +556,8 @@ static int phonesim_enable(struct ofono_modem *modem)
                return -ENOMEM;
        }
 
+       data->pref_ue_mode = -1;
+
        if (data->calypso)
                syntax = g_at_syntax_new_gsm_permissive();
        else
@@ -574,7 +603,10 @@ static int phonesim_enable(struct ofono_modem *modem)
        g_at_chat_register(data->chat, "+CRST:",
                                crst_notify, FALSE, modem, NULL);
 
-       return 0;
+       g_at_chat_send(data->chat, "AT+CEMODE?", cemode_prefix,
+                       cemode_read_cb, modem, NULL);
+
+       return -EINPROGRESS;
 }
 
 static void set_online_cb(gboolean ok, GAtResult *result, gpointer user_data)
-- 
1.7.0.4

_______________________________________________
ofono mailing list
[email protected]
http://lists.ofono.org/listinfo/ofono

Reply via email to