From: Pekka Pessi <[email protected]>

---
 plugins/g1.c |   31 ++++++++++++++++++++++++++++---
 1 files changed, 28 insertions(+), 3 deletions(-)

diff --git a/plugins/g1.c b/plugins/g1.c
index fa96eb1..8c04117 100644
--- a/plugins/g1.c
+++ b/plugins/g1.c
@@ -49,6 +49,7 @@
 #include <ofono/voicecall.h>
 
 #include <drivers/atmodem/vendor.h>
+#include <drivers/atmodem/atutil.h>
 
 static void g1_debug(const char *str, void *data)
 {
@@ -120,7 +121,7 @@ static int g1_enable(struct ofono_modem *modem)
        g_at_chat_send(chat, "ATE0Q0V1", NULL, NULL, NULL, NULL);
 
        /* power up modem */
-       g_at_chat_send(chat, "AT+CFUN=1", NULL, cfun_set_on_cb, modem, NULL);
+       g_at_chat_send(chat, "AT+CFUN=4", NULL, cfun_set_on_cb, modem, NULL);
 
        return 0;
 }
@@ -168,7 +169,30 @@ static void g1_pre_sim(struct ofono_modem *modem)
                ofono_sim_inserted_notify(sim, TRUE);
 }
 
-static void g1_post_sim(struct ofono_modem *modem)
+static void set_online_cb(gboolean ok, GAtResult *result, gpointer user_data)
+{
+       struct cb_data *cbd = user_data;
+       ofono_modem_online_cb_t cb = cbd->cb;
+
+       if (ok)
+               CALLBACK_WITH_SUCCESS(cb, cbd->data);
+       else
+               CALLBACK_WITH_FAILURE(cb, cbd->data);
+}
+
+static void g1_set_online(struct ofono_modem *modem, ofono_bool_t online,
+                               ofono_modem_online_cb_t cb, void *user_data)
+{
+       GAtChat *chat = ofono_modem_get_data(modem);
+       struct cb_data *cbd = cb_data_new(cb, user_data);
+       char const *command = online ? "AT+CFUN=1" : "AT+CFUN=4";
+
+       DBG("modem %p %s", modem, online ? "online" : "offline");
+
+       g_at_chat_send(chat, command, NULL, set_online_cb, cbd, g_free);
+}
+
+static void g1_post_online(struct ofono_modem *modem)
 {
        GAtChat *chat = ofono_modem_get_data(modem);
        struct ofono_message_waiting *mw;
@@ -196,8 +220,9 @@ static struct ofono_modem_driver g1_driver = {
        .remove         = g1_remove,
        .enable         = g1_enable,
        .disable        = g1_disable,
+       .set_online     = g1_set_online,
        .pre_sim        = g1_pre_sim,
-       .post_sim       = g1_post_sim,
+       .post_online    = g1_post_online,
 };
 
 static int g1_init(void)
-- 
1.7.0.4

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

Reply via email to