From: Pekka Pessi <[email protected]>

---
 plugins/hso.c |   32 +++++++++++++++++++++++++++++---
 1 files changed, 29 insertions(+), 3 deletions(-)

diff --git a/plugins/hso.c b/plugins/hso.c
index 8611e07..7433a7b 100644
--- a/plugins/hso.c
+++ b/plugins/hso.c
@@ -46,6 +46,7 @@
 #include <ofono/log.h>
 
 #include <drivers/atmodem/vendor.h>
+#include <drivers/atmodem/atutil.h>
 
 static const char *none_prefix[] = { NULL };
 
@@ -172,7 +173,7 @@ static int hso_enable(struct ofono_modem *modem)
        g_at_chat_send(data->control, "ATE0", none_prefix, NULL, NULL, NULL);
        g_at_chat_send(data->app, "ATE0", none_prefix, NULL, NULL, NULL);
 
-       g_at_chat_send(data->control, "AT+CFUN=1", none_prefix,
+       g_at_chat_send(data->control, "AT+CFUN=4", none_prefix,
                                        cfun_enable, modem, NULL);
 
        return -EINPROGRESS;
@@ -213,6 +214,30 @@ static int hso_disable(struct ofono_modem *modem)
        return -EINPROGRESS;
 }
 
+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 hso_set_online(struct ofono_modem *modem, ofono_bool_t online,
+                               ofono_modem_online_cb_t cb, void *user_data)
+{
+       struct hso_data *data = 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(data->control, command, NULL,
+                       set_online_cb, cbd, g_free);
+}
+
 static void hso_pre_sim(struct ofono_modem *modem)
 {
        struct hso_data *data = ofono_modem_get_data(modem);
@@ -228,7 +253,7 @@ static void hso_pre_sim(struct ofono_modem *modem)
                ofono_sim_inserted_notify(sim, TRUE);
 }
 
-static void hso_post_sim(struct ofono_modem *modem)
+static void hso_post_online(struct ofono_modem *modem)
 {
        struct hso_data *data = ofono_modem_get_data(modem);
        struct ofono_gprs *gprs;
@@ -260,8 +285,9 @@ static struct ofono_modem_driver hso_driver = {
        .remove         = hso_remove,
        .enable         = hso_enable,
        .disable        = hso_disable,
+       .set_online     = hso_set_online,
        .pre_sim        = hso_pre_sim,
-       .post_sim       = hso_post_sim,
+       .post_online    = hso_post_online,
 };
 
 static int hso_init(void)
-- 
1.7.0.4

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

Reply via email to