diff options
author | Pekka Pessi <Pekka.Pessi@nokia.com> | 2010-09-06 21:46:16 +0300 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2010-09-09 01:24:34 +0200 |
commit | 8a7e919578d81a25c04a4e5d803088eb03884b6e (patch) | |
tree | 07f55d33de639782d5ec51c081273b70c70866b2 /plugins/mbm.c | |
parent | de4d998e37eab4fe1e4736b54508f24b45e27bd5 (diff) | |
download | ofono-8a7e919578d81a25c04a4e5d803088eb03884b6e.tar.bz2 |
mbm: implement Online property
Diffstat (limited to 'plugins/mbm.c')
-rw-r--r-- | plugins/mbm.c | 51 |
1 files changed, 47 insertions, 4 deletions
diff --git a/plugins/mbm.c b/plugins/mbm.c index b9de55a9..a706a34c 100644 --- a/plugins/mbm.c +++ b/plugins/mbm.c @@ -46,6 +46,7 @@ #include <ofono/gprs-context.h> #include <ofono/log.h> +#include <drivers/atmodem/atutil.h> #include <drivers/atmodem/vendor.h> static const char *cfun_prefix[] = { "+CFUN:", NULL }; @@ -221,8 +222,8 @@ static void cfun_query(gboolean ok, GAtResult *result, gpointer user_data) g_at_result_iter_next_number(&iter, &status); - if (status == 4) { - g_at_chat_send(data->modem_port, "AT+CFUN=1", none_prefix, + if (status != 4) { + g_at_chat_send(data->modem_port, "AT+CFUN=4", none_prefix, cfun_enable, modem, NULL); return; } @@ -376,6 +377,39 @@ static int mbm_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 mbm_set_online(struct ofono_modem *modem, ofono_bool_t online, + ofono_modem_online_cb_t cb, void *user_data) +{ + struct mbm_data *data = ofono_modem_get_data(modem); + GAtChat *chat = data->modem_port; + 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 mbm_pre_sim(struct ofono_modem *modem) { struct mbm_data *data = ofono_modem_get_data(modem); @@ -394,12 +428,19 @@ static void mbm_pre_sim(struct ofono_modem *modem) static void mbm_post_sim(struct ofono_modem *modem) { struct mbm_data *data = ofono_modem_get_data(modem); - struct ofono_gprs *gprs; - struct ofono_gprs_context *gc; DBG("%p", modem); ofono_stk_create(modem, 0, "mbmmodem", data->modem_port); +} + +static void mbm_post_online(struct ofono_modem *modem) +{ + struct mbm_data *data = ofono_modem_get_data(modem); + struct ofono_gprs *gprs; + struct ofono_gprs_context *gc; + + DBG("%p", modem); ofono_netreg_create(modem, OFONO_VENDOR_MBM, "atmodem", data->modem_port); @@ -431,8 +472,10 @@ static struct ofono_modem_driver mbm_driver = { .remove = mbm_remove, .enable = mbm_enable, .disable = mbm_disable, + .set_online = mbm_set_online, .pre_sim = mbm_pre_sim, .post_sim = mbm_post_sim, + .post_online = mbm_post_online, }; static int mbm_init(void) |