From de648cf96325495757e3261f5599301c5d9bb061 Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Thu, 27 Jan 2011 15:35:56 +0100 Subject: [PATCH] sierra: Add support for online mode --- plugins/sierra.c | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/plugins/sierra.c b/plugins/sierra.c index f886b374..dca6309d 100644 --- a/plugins/sierra.c +++ b/plugins/sierra.c @@ -136,7 +136,7 @@ static int sierra_enable(struct ofono_modem *modem) g_at_chat_send(data->chat, "ATE0 +CMEE=1", none_prefix, NULL, NULL, NULL); - g_at_chat_send(data->chat, "AT+CFUN=1", none_prefix, + g_at_chat_send(data->chat, "AT+CFUN=4", none_prefix, cfun_enable, modem, NULL); return -EINPROGRESS; @@ -174,6 +174,39 @@ static int sierra_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 sierra_set_online(struct ofono_modem *modem, ofono_bool_t online, + ofono_modem_online_cb_t cb, void *user_data) +{ + struct sierra_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"); + + if (cbd == NULL || data->chat == NULL) + goto error; + + if (g_at_chat_send(data->chat, command, NULL, + set_online_cb, cbd, g_free)) + return; + +error: + g_free(cbd); + + CALLBACK_WITH_FAILURE(cb, cbd->data); +} + static void sierra_pre_sim(struct ofono_modem *modem) { struct sierra_data *data = ofono_modem_get_data(modem); @@ -212,6 +245,7 @@ static struct ofono_modem_driver sierra_driver = { .remove = sierra_remove, .enable = sierra_enable, .disable = sierra_disable, + .set_online = sierra_set_online, .pre_sim = sierra_pre_sim, .post_sim = sierra_post_sim, .post_online = sierra_post_online,