summaryrefslogtreecommitdiffstats
path: root/plugins/telit.c
diff options
context:
space:
mode:
authorGustavo F. Padovan <padovan@profusion.mobi>2011-09-26 14:26:56 -0300
committerDenis Kenzior <denkenz@gmail.com>2011-09-26 13:37:55 -0500
commit4f3b9ff36c453824c48af6490b6b706699869e3d (patch)
tree20436e18e293556879fc3386b949259438b1e02b /plugins/telit.c
parent7771fa07c899bdddb6386b2a96d11884e9e735af (diff)
downloadofono-4f3b9ff36c453824c48af6490b6b706699869e3d.tar.bz2
telit: add support to enable SAP client
Diffstat (limited to 'plugins/telit.c')
-rw-r--r--plugins/telit.c109
1 files changed, 73 insertions, 36 deletions
diff --git a/plugins/telit.c b/plugins/telit.c
index 18cf0c40..cc10668a 100644
--- a/plugins/telit.c
+++ b/plugins/telit.c
@@ -58,6 +58,7 @@
static const char *none_prefix[] = { NULL };
static const char *qss_prefix[] = { "#QSS:", NULL };
+static const char *rsen_prefix[]= { "#RSEN:", NULL };
struct telit_data {
GAtChat *chat;
@@ -65,10 +66,6 @@ struct telit_data {
guint sim_inserted_source;
};
-static struct bluetooth_sap_driver sap_driver = {
- .name = "telit",
-};
-
static void telit_debug(const char *str, void *user_data)
{
const char *prefix = user_data;
@@ -76,6 +73,78 @@ static void telit_debug(const char *str, void *user_data)
ofono_info("%s%s", prefix, str);
}
+static GAtChat *open_device(struct ofono_modem *modem,
+ const char *key, char *debug)
+{
+ const char *device;
+ GAtSyntax *syntax;
+ GIOChannel *channel;
+ GAtChat *chat;
+
+ device = ofono_modem_get_string(modem, key);
+ if (device == NULL)
+ return NULL;
+
+ DBG("%s %s", key, device);
+
+ channel = g_at_tty_open(device, NULL);
+ if (channel == NULL)
+ return NULL;
+
+ syntax = g_at_syntax_new_gsmv1();
+ chat = g_at_chat_new(channel, syntax);
+ g_at_syntax_unref(syntax);
+ g_io_channel_unref(channel);
+
+ if (chat == NULL)
+ return NULL;
+
+ if (getenv("OFONO_AT_DEBUG"))
+ g_at_chat_set_debug(chat, telit_debug, debug);
+
+ return chat;
+}
+
+static void rsen_enable_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);
+
+ if (!ok) {
+ g_at_chat_unref(data->chat);
+ data->chat = NULL;
+ ofono_modem_set_powered(modem, FALSE);
+ return;
+ }
+
+}
+
+static int telit_sap_enable(struct ofono_modem *modem)
+{
+ struct telit_data *data = ofono_modem_get_data(modem);
+
+ DBG("%p", modem);
+
+ data->chat = open_device(modem, "Data", "Aux: ");
+ if (data->chat == NULL)
+ return -EINVAL;
+
+ g_at_chat_send(data->chat, "AT#NOPT=3", NULL, NULL, NULL, NULL);
+
+ /* Set SAP functionality */
+ g_at_chat_send(data->chat, "AT#RSEN=1,1,0,2,0", rsen_prefix,
+ rsen_enable_cb, modem, NULL);
+
+ return -EINPROGRESS;
+}
+
+static struct bluetooth_sap_driver sap_driver = {
+ .name = "telit",
+ .enable = telit_sap_enable,
+};
+
static int telit_probe(struct ofono_modem *modem)
{
struct telit_data *data;
@@ -232,38 +301,6 @@ static void cfun_disable_cb(gboolean ok, GAtResult *result, gpointer user_data)
ofono_modem_set_powered(modem, FALSE);
}
-static GAtChat *open_device(struct ofono_modem *modem,
- const char *key, char *debug)
-{
- const char *device;
- GAtSyntax *syntax;
- GIOChannel *channel;
- GAtChat *chat;
-
- device = ofono_modem_get_string(modem, key);
- if (device == NULL)
- return NULL;
-
- DBG("%s %s", key, device);
-
- channel = g_at_tty_open(device, NULL);
- if (channel == NULL)
- return NULL;
-
- syntax = g_at_syntax_new_gsmv1();
- chat = g_at_chat_new(channel, syntax);
- g_at_syntax_unref(syntax);
- g_io_channel_unref(channel);
-
- if (chat == NULL)
- return NULL;
-
- if (getenv("OFONO_AT_DEBUG"))
- g_at_chat_set_debug(chat, telit_debug, debug);
-
- return chat;
-}
-
static int telit_enable(struct ofono_modem *modem)
{
struct telit_data *data = ofono_modem_get_data(modem);