summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGustavo F. Padovan <padovan@profusion.mobi>2011-09-28 18:24:13 -0300
committerDenis Kenzior <denkenz@gmail.com>2011-09-29 11:13:05 -0500
commitdeca4a32d38885b5c3bb9832dea9db38e5d56e4d (patch)
tree55a36c11e6f25420875c0f70c03ec2cb5a90f407
parentd4da014f6fce615ff8a801db38c524e580787f04 (diff)
telit: add suport the disable SAP client
-rw-r--r--plugins/bluetooth.h1
-rw-r--r--plugins/telit.c100
2 files changed, 69 insertions, 32 deletions
diff --git a/plugins/bluetooth.h b/plugins/bluetooth.h
index 7e94f961..d38e72e5 100644
--- a/plugins/bluetooth.h
+++ b/plugins/bluetooth.h
@@ -47,6 +47,7 @@ struct bluetooth_sap_driver {
const char *name;
int (*enable) (struct ofono_modem *modem, struct ofono_modem *sap_modem,
int bt_fd);
+ int (*disable) (struct ofono_modem *modem);
};
struct server;
diff --git a/plugins/telit.c b/plugins/telit.c
index d2f6c5af..9a338409 100644
--- a/plugins/telit.c
+++ b/plugins/telit.c
@@ -243,6 +243,58 @@ static void rsen_enable_cb(gboolean ok, GAtResult *result, gpointer user_data)
}
}
+static void cfun_disable_cb(gboolean ok, GAtResult *result, gpointer user_data)
+{
+ struct ofono_modem *modem = user_data;
+ struct telit_data *data = ofono_modem_get_data(modem);
+
+ if(data->sap_modem)
+ modem = data->sap_modem;
+
+ DBG("%p", modem);
+
+ g_at_chat_unref(data->chat);
+ data->chat = NULL;
+
+ if (data->sim_inserted_source > 0)
+ g_source_remove(data->sim_inserted_source);
+
+ if (ok)
+ ofono_modem_set_powered(modem, FALSE);
+
+ data->sap_modem = NULL;
+}
+
+static int telit_disable(struct ofono_modem *modem)
+{
+ struct telit_data *data = ofono_modem_get_data(modem);
+ DBG("%p", modem);
+
+ g_at_chat_cancel_all(data->chat);
+ g_at_chat_unregister_all(data->chat);
+
+ /* Power down modem */
+ g_at_chat_send(data->chat, "AT+CFUN=0", none_prefix,
+ cfun_disable_cb, modem, NULL);
+
+ return -EINPROGRESS;
+}
+
+static void rsen_disable_cb(gboolean ok, GAtResult *result, gpointer user_data)
+{
+ struct ofono_modem *modem = user_data;
+ struct telit_data *data = ofono_modem_get_data(modem);
+
+ DBG("%p", modem);
+
+ g_at_chat_unref(data->aux);
+ data->aux = NULL;
+
+ sap_close_io(modem);
+
+ telit_disable(modem);
+}
+
static int telit_sap_open()
{
const char *device = "/dev/ttyUSB4";
@@ -331,9 +383,25 @@ error:
return -EINVAL;
}
+static int telit_sap_disable(struct ofono_modem *modem)
+{
+ struct telit_data *data = ofono_modem_get_data(modem);
+
+ DBG("%p", modem);
+
+ g_at_chat_cancel_all(data->aux);
+ g_at_chat_unregister_all(data->aux);
+
+ g_at_chat_send(data->aux, "AT#RSEN=0", rsen_prefix,
+ rsen_disable_cb, modem, NULL);
+
+ return -EINPROGRESS;
+}
+
static struct bluetooth_sap_driver sap_driver = {
.name = "telit",
.enable = telit_sap_enable,
+ .disable = telit_sap_disable,
};
static int telit_probe(struct ofono_modem *modem)
@@ -475,23 +543,6 @@ static void cfun_enable_cb(gboolean ok, GAtResult *result, gpointer user_data)
telit_qss_cb, modem, NULL);
}
-static void cfun_disable_cb(gboolean ok, GAtResult *result, gpointer user_data)
-{
- struct ofono_modem *modem = user_data;
- struct telit_data *data = ofono_modem_get_data(modem);
-
- DBG("%p", modem);
-
- g_at_chat_unref(data->chat);
- data->chat = NULL;
-
- if (data->sim_inserted_source > 0)
- g_source_remove(data->sim_inserted_source);
-
- if (ok)
- ofono_modem_set_powered(modem, FALSE);
-}
-
static int telit_enable(struct ofono_modem *modem)
{
struct telit_data *data = ofono_modem_get_data(modem);
@@ -516,21 +567,6 @@ static int telit_enable(struct ofono_modem *modem)
return -EINPROGRESS;
}
-static int telit_disable(struct ofono_modem *modem)
-{
- struct telit_data *data = ofono_modem_get_data(modem);
- DBG("%p", modem);
-
- g_at_chat_cancel_all(data->chat);
- g_at_chat_unregister_all(data->chat);
-
- /* Power down modem */
- g_at_chat_send(data->chat, "AT+CFUN=0", none_prefix,
- cfun_disable_cb, modem, NULL);
-
- return -EINPROGRESS;
-}
-
static void set_online_cb(gboolean ok, GAtResult *result, gpointer user_data)
{
struct cb_data *cbd = user_data;