From fde698c2a5e0102e744ca70712fd4595d4579020 Mon Sep 17 00:00:00 2001 From: "Gustavo F. Padovan" Date: Wed, 28 Sep 2011 18:24:18 -0300 Subject: [PATCH] telit: add set_online to SAP Client --- plugins/bluetooth.h | 2 ++ 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); -- 2.34.1