diff options
author | Gustavo F. Padovan <padovan@profusion.mobi> | 2011-09-28 18:24:18 -0300 |
---|---|---|
committer | Denis Kenzior <denkenz@gmail.com> | 2011-09-29 11:19:03 -0500 |
commit | fde698c2a5e0102e744ca70712fd4595d4579020 (patch) | |
tree | 56b33af0697fc5d6175edde254db6d9d666496a0 | |
parent | 9c7f0aa45e994454aa8768cac5727b2d15e69c3b (diff) | |
download | ofono-fde698c2a5e0102e744ca70712fd4595d4579020.tar.bz2 |
telit: add set_online to SAP Client
-rw-r--r-- | plugins/bluetooth.h | 2 | ||||
-rw-r--r-- | plugins/telit.c | 47 |
2 files changed, 26 insertions, 23 deletions
diff --git a/plugins/bluetooth.h b/plugins/bluetooth.h index a9d36838..89733a1c 100644 --- a/plugins/bluetooth.h +++ b/plugins/bluetooth.h @@ -49,6 +49,8 @@ struct bluetooth_sap_driver { int bt_fd); void (*pre_sim) (struct ofono_modem *modem); void (*post_sim) (struct ofono_modem *modem); + void (*set_online) (struct ofono_modem *modem, ofono_bool_t online, + ofono_modem_online_cb_t cb, void *user_data); int (*disable) (struct ofono_modem *modem); }; diff --git a/plugins/telit.c b/plugins/telit.c index b5b2dbe7..3908985e 100644 --- a/plugins/telit.c +++ b/plugins/telit.c @@ -565,11 +565,35 @@ static void telit_post_sim(struct ofono_modem *modem) ofono_sms_create(modem, 0, "atmodem", data->chat); } +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; + struct ofono_error error; + + decode_at_error(&error, g_at_result_final_response(result)); + cb(&error, cbd->data); +} + +static void telit_set_online(struct ofono_modem *modem, ofono_bool_t online, + ofono_modem_online_cb_t cb, void *user_data) +{ + struct telit_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->chat, command, none_prefix, set_online_cb, + cbd, g_free); +} + static struct bluetooth_sap_driver sap_driver = { .name = "telit", .enable = telit_sap_enable, .pre_sim = telit_pre_sim, .post_sim = telit_post_sim, + .set_online = telit_set_online, .disable = telit_sap_disable, }; @@ -606,29 +630,6 @@ static void telit_remove(struct ofono_modem *modem) g_free(data); } -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; - struct ofono_error error; - - decode_at_error(&error, g_at_result_final_response(result)); - cb(&error, cbd->data); -} - -static void telit_set_online(struct ofono_modem *modem, ofono_bool_t online, - ofono_modem_online_cb_t cb, void *user_data) -{ - struct telit_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->chat, command, none_prefix, set_online_cb, - cbd, g_free); -} - static void telit_post_online(struct ofono_modem *modem) { struct telit_data *data = ofono_modem_get_data(modem); |