summaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorPekka Pessi <Pekka.Pessi@nokia.com>2010-09-06 21:46:14 +0300
committerMarcel Holtmann <marcel@holtmann.org>2010-09-09 01:19:37 +0200
commit6ce4fb368909d687c9d4bff360880090cac1aa6b (patch)
treefe7709d9649041399fa53b891583b8a88cc064d2 /plugins
parent9cbff5e19ae9d78a29d35f33a8e6ff5b3ed0bfd8 (diff)
downloadofono-6ce4fb368909d687c9d4bff360880090cac1aa6b.tar.bz2
hso: implement Online property
Diffstat (limited to 'plugins')
-rw-r--r--plugins/hso.c41
1 files changed, 38 insertions, 3 deletions
diff --git a/plugins/hso.c b/plugins/hso.c
index 8611e071..25ca1574 100644
--- a/plugins/hso.c
+++ b/plugins/hso.c
@@ -45,6 +45,7 @@
#include <ofono/radio-settings.h>
#include <ofono/log.h>
+#include <drivers/atmodem/atutil.h>
#include <drivers/atmodem/vendor.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,39 @@ 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);
+ GAtChat *chat = data->control;
+ 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");
+
+ if (!cbd)
+ goto error;
+
+ if (g_at_chat_send(chat, command, NULL, set_online_cb, cbd, g_free))
+ return;
+
+error:
+ g_free(cbd);
+
+ CALLBACK_WITH_FAILURE(cb, cbd->data);
+}
+
static void hso_pre_sim(struct ofono_modem *modem)
{
struct hso_data *data = ofono_modem_get_data(modem);
@@ -228,7 +262,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 +294,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)