From: "Gustavo F. Padovan" <padovan(a)profusion.mobi>
Support to disable the SAP modem from the sap plugin
---
plugins/bluetooth.h | 1 +
plugins/telit.c | 30 ++++++++++++++++++++++++++++++
2 files changed, 31 insertions(+), 0 deletions(-)
diff --git a/plugins/bluetooth.h b/plugins/bluetooth.h
index 20df890..d2ccb21 100644
--- a/plugins/bluetooth.h
+++ b/plugins/bluetooth.h
@@ -46,6 +46,7 @@ struct bluetooth_profile {
struct bluetooth_sap_driver {
const char *name;
int (*enable) (struct ofono_modem *modem);
+ int (*disable) (struct ofono_modem *modem);
int (*open) (struct ofono_modem *modem);
};
diff --git a/plugins/telit.c b/plugins/telit.c
index 69f9eed..4626c4b 100644
--- a/plugins/telit.c
+++ b/plugins/telit.c
@@ -139,6 +139,20 @@ static void rsen_enable_cb(gboolean ok, GAtResult *result, gpointer
user_data)
}
}
+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->chat);
+ data->chat = NULL;
+
+ if (ok)
+ ofono_modem_set_powered(modem, FALSE);
+}
+
static int telit_sap_open(struct ofono_modem *modem)
{
const char *device = "/dev/ttyUSB4";
@@ -186,9 +200,25 @@ static int telit_sap_enable(struct ofono_modem *modem)
return -EINPROGRESS;
}
+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->chat);
+ g_at_chat_unregister_all(data->chat);
+
+ g_at_chat_send(data->chat, "AT#RSEN=0", rsen_prefix,
+ rsen_disable_cb, modem, NULL);
+
+ return 0;
+}
+
static struct bluetooth_sap_driver sap_driver = {
.name = "telit",
.enable = telit_sap_enable,
+ .disable = telit_sap_disable,
.open = telit_sap_open,
};
--
1.7.6.1