* [PATCH -v4 01/21] udevng: look also to VID
@ 2011-09-27 21:04 Gustavo F. Padovan
2011-09-27 21:04 ` [PATCH -v4 02/21] sap: add watch for the Bluetooth Link Gustavo F. Padovan
0 siblings, 1 reply; 24+ messages in thread
From: Gustavo F. Padovan @ 2011-09-27 21:04 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 1071 bytes --]
From: "Gustavo F. Padovan" <padovan@profusion.mobi>
Some drivers name are not properly set, so we need to rely on the VID
information as well
---
plugins/udevng.c | 14 ++++++++------
1 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/plugins/udevng.c b/plugins/udevng.c
index 1365bd1..5fd9475 100644
--- a/plugins/udevng.c
+++ b/plugins/udevng.c
@@ -857,14 +857,16 @@ static void check_usb_device(struct udev_device *device)
DBG("%s [%s:%s]", drv, vid, pid);
for (i = 0; vendor_list[i].driver; i++) {
- if (g_str_equal(vendor_list[i].drv, drv) == FALSE)
- continue;
-
- if (vendor_list[i].vid == NULL) {
- driver = vendor_list[i].driver;
- break;
+ if (g_str_equal(vendor_list[i].drv, drv) == TRUE) {
+ if (vendor_list[i].vid == NULL) {
+ driver = vendor_list[i].driver;
+ break;
+ }
}
+ if (vendor_list[i].vid == NULL)
+ continue;
+
if (g_str_equal(vendor_list[i].vid, vid) == TRUE) {
if (vendor_list[i].pid == NULL) {
if (driver == NULL)
--
1.7.6.2
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH -v4 02/21] sap: add watch for the Bluetooth Link
2011-09-27 21:04 [PATCH -v4 01/21] udevng: look also to VID Gustavo F. Padovan
@ 2011-09-27 21:04 ` Gustavo F. Padovan
2011-09-27 21:04 ` [PATCH -v4 03/21] sap: add support to enable SAP Gustavo F. Padovan
0 siblings, 1 reply; 24+ messages in thread
From: Gustavo F. Padovan @ 2011-09-27 21:04 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 2815 bytes --]
From: "Gustavo F. Padovan" <padovan@profusion.mobi>
---
plugins/sap.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++---
1 files changed, 55 insertions(+), 4 deletions(-)
diff --git a/plugins/sap.c b/plugins/sap.c
index 169bb7f..004d225 100644
--- a/plugins/sap.c
+++ b/plugins/sap.c
@@ -55,6 +55,8 @@ struct sap_data {
char *server_path;
struct ofono_modem *hw_modem;
struct bluetooth_sap_driver *sap_driver;
+ GIOChannel *bt_io;
+ guint bt_watch;
};
int bluetooth_sap_client_register(struct bluetooth_sap_driver *sap,
@@ -100,6 +102,36 @@ void bluetooth_sap_client_unregister(struct ofono_modem *modem)
sap_hw_driver = NULL;
}
+static void bt_watch_remove(gpointer userdata)
+{
+ struct ofono_modem *modem = userdata;
+ struct sap_data *data = ofono_modem_get_data(modem);
+
+ ofono_modem_set_powered(modem, FALSE);
+
+ data->bt_watch = 0;
+}
+
+static gboolean bt_event_cb(GIOChannel *bt_io, GIOCondition condition,
+ gpointer data)
+{
+ if (condition & G_IO_IN) {
+ GIOStatus status;
+ gsize bytes_read;
+ gchar buf[300];
+
+ status = g_io_channel_read_chars(bt_io, buf, 300,
+ &bytes_read, NULL);
+
+ if (status != G_IO_STATUS_NORMAL && status != G_IO_STATUS_AGAIN)
+ return FALSE;
+
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
static int sap_probe(struct ofono_modem *modem)
{
DBG("%p", modem);
@@ -115,8 +147,10 @@ static void sap_remove(struct ofono_modem *modem)
static void sap_connect_reply(DBusPendingCall *call, gpointer user_data)
{
struct ofono_modem *modem = user_data;
+ struct sap_data *data = ofono_modem_get_data(modem);
DBusError derr;
DBusMessage *reply;
+ int fd;
DBG("");
@@ -126,14 +160,31 @@ static void sap_connect_reply(DBusPendingCall *call, gpointer user_data)
goto done;
dbus_error_init(&derr);
- if (!dbus_set_error_from_message(&derr, reply))
+ if (dbus_set_error_from_message(&derr, reply)) {
+
+ DBG("Connect reply: %s", derr.message);
+
+ ofono_modem_set_powered(modem, FALSE);
+
+ dbus_error_free(&derr);
goto done;
+ }
+
+ if (!dbus_message_get_args(reply, NULL, DBUS_TYPE_UNIX_FD, &fd,
+ DBUS_TYPE_INVALID))
+ return;
- DBG("Connect reply: %s", derr.message);
+ data->bt_io = g_io_channel_unix_new(fd);
+ if (data->bt_io == NULL)
+ return;
- ofono_modem_set_powered(modem, FALSE);
+ g_io_channel_set_encoding(data->bt_io, NULL, NULL);
+ g_io_channel_set_buffered(data->bt_io, FALSE);
+ g_io_channel_set_close_on_unref(data->bt_io, TRUE);
- dbus_error_free(&derr);
+ data->bt_watch = g_io_add_watch_full(data->bt_io, G_PRIORITY_DEFAULT,
+ G_IO_HUP | G_IO_ERR | G_IO_NVAL | G_IO_IN,
+ bt_event_cb, modem, bt_watch_remove);
done:
dbus_message_unref(reply);
--
1.7.6.2
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH -v4 03/21] sap: add support to enable SAP
2011-09-27 21:04 ` [PATCH -v4 02/21] sap: add watch for the Bluetooth Link Gustavo F. Padovan
@ 2011-09-27 21:04 ` Gustavo F. Padovan
2011-09-27 21:04 ` [PATCH -v4 04/21] telit: add telit_sap_disable() Gustavo F. Padovan
0 siblings, 1 reply; 24+ messages in thread
From: Gustavo F. Padovan @ 2011-09-27 21:04 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 4890 bytes --]
From: "Gustavo F. Padovan" <padovan@profusion.mobi>
connects the bluetooth link with the the hw and initiate the SAP
connection procedure.
---
plugins/sap.c | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-
plugins/telit.c | 34 +++++++++++++++++++++++++-
2 files changed, 104 insertions(+), 2 deletions(-)
diff --git a/plugins/sap.c b/plugins/sap.c
index 004d225..f0965f1 100644
--- a/plugins/sap.c
+++ b/plugins/sap.c
@@ -56,7 +56,9 @@ struct sap_data {
struct ofono_modem *hw_modem;
struct bluetooth_sap_driver *sap_driver;
GIOChannel *bt_io;
+ GIOChannel *hw_io;
guint bt_watch;
+ guint hw_watch;
};
int bluetooth_sap_client_register(struct bluetooth_sap_driver *sap,
@@ -115,14 +117,58 @@ static void bt_watch_remove(gpointer userdata)
static gboolean bt_event_cb(GIOChannel *bt_io, GIOCondition condition,
gpointer data)
{
+ struct ofono_modem *modem = data;
+ struct sap_data *sap_data = ofono_modem_get_data(modem);
+
if (condition & G_IO_IN) {
GIOStatus status;
- gsize bytes_read;
+ gsize bytes_read, bytes_written;
gchar buf[300];
status = g_io_channel_read_chars(bt_io, buf, 300,
&bytes_read, NULL);
+ if (bytes_read > 0)
+ g_io_channel_write_chars(sap_data->bt_io, buf,
+ bytes_read, &bytes_written, NULL);
+
+ if (status != G_IO_STATUS_NORMAL && status != G_IO_STATUS_AGAIN)
+ return FALSE;
+
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+static void hw_watch_remove(gpointer userdata)
+{
+ struct ofono_modem *modem = userdata;
+ struct sap_data *data = ofono_modem_get_data(modem);
+
+ ofono_modem_set_powered(modem, FALSE);
+
+ data->hw_watch = 0;
+}
+
+static gboolean hw_event_cb(GIOChannel *hw_io, GIOCondition condition,
+ gpointer data)
+{
+ struct ofono_modem *modem = data;
+ struct sap_data *sap_data = ofono_modem_get_data(modem);
+
+ if (condition & G_IO_IN) {
+ GIOStatus status;
+ gsize bytes_read, bytes_written;
+ gchar buf[300];
+
+ status = g_io_channel_read_chars(hw_io, buf, 300,
+ &bytes_read, NULL);
+
+ if (bytes_read > 0)
+ g_io_channel_write_chars(sap_data->bt_io, buf,
+ bytes_read, &bytes_written, NULL);
+
if (status != G_IO_STATUS_NORMAL && status != G_IO_STATUS_AGAIN)
return FALSE;
@@ -186,6 +232,30 @@ static void sap_connect_reply(DBusPendingCall *call, gpointer user_data)
G_IO_HUP | G_IO_ERR | G_IO_NVAL | G_IO_IN,
bt_event_cb, modem, bt_watch_remove);
+ data->hw_modem = sap_hw_modem;
+ data->sap_driver = sap_hw_driver;
+
+ fd = data->sap_driver->enable(data->hw_modem);
+ if (fd < 0)
+ return;
+
+ data->hw_io = g_io_channel_unix_new(fd);
+ if (data->hw_io == NULL) {
+ g_io_channel_unref(data->bt_io);
+ close(fd);
+ return;
+ }
+
+ g_io_channel_set_encoding(data->hw_io, NULL, NULL);
+ g_io_channel_set_buffered(data->hw_io, FALSE);
+ g_io_channel_set_close_on_unref(data->hw_io, TRUE);
+
+ data->hw_watch = g_io_add_watch_full(data->hw_io, G_PRIORITY_DEFAULT,
+ G_IO_HUP | G_IO_ERR | G_IO_NVAL | G_IO_IN,
+ hw_event_cb, modem, hw_watch_remove);
+
+ ofono_modem_set_powered(modem, TRUE);
+
done:
dbus_message_unref(reply);
}
diff --git a/plugins/telit.c b/plugins/telit.c
index 1f950aa..a5f9941 100644
--- a/plugins/telit.c
+++ b/plugins/telit.c
@@ -27,6 +27,9 @@
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
+#include <fcntl.h>
+#include <termios.h>
+#include <string.h>
#include <glib.h>
#include <gatchat.h>
@@ -134,12 +137,37 @@ static void rsen_enable_cb(gboolean ok, GAtResult *result, gpointer user_data)
ofono_modem_set_powered(modem, FALSE);
return;
}
+}
+
+static int telit_sap_open()
+{
+ const char *device = "/dev/ttyUSB4";
+ struct termios ti;
+ int fd;
+
+ DBG("%s", device);
+
+ fd = open(device, O_RDWR | O_NOCTTY | O_NONBLOCK);
+ if (fd < 0)
+ return -EINVAL;
+ /* Switch TTY to raw mode */
+ memset(&ti, 0, sizeof(ti));
+ cfmakeraw(&ti);
+
+ tcflush(fd, TCIOFLUSH);
+ if (tcsetattr(fd, TCSANOW, &ti) < 0) {
+ close(fd);
+ return -EBADF;
+ }
+
+ return fd;
}
static int telit_sap_enable(struct ofono_modem *modem)
{
struct telit_data *data = ofono_modem_get_data(modem);
+ int fd;
DBG("%p", modem);
@@ -147,6 +175,10 @@ static int telit_sap_enable(struct ofono_modem *modem)
if (data->chat == NULL)
return -EINVAL;
+ fd = telit_sap_open();
+ if (fd < 0)
+ return fd;
+
g_at_chat_register(data->chat, "#RSEN:", telit_rsen_notify,
FALSE, modem, NULL);
@@ -156,7 +188,7 @@ static int telit_sap_enable(struct ofono_modem *modem)
g_at_chat_send(data->chat, "AT#RSEN=1,1,0,2,0", rsen_prefix,
rsen_enable_cb, modem, NULL);
- return -EINPROGRESS;
+ return fd;
}
static struct bluetooth_sap_driver sap_driver = {
--
1.7.6.2
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH -v4 04/21] telit: add telit_sap_disable()
2011-09-27 21:04 ` [PATCH -v4 03/21] sap: add support to enable SAP Gustavo F. Padovan
@ 2011-09-27 21:04 ` Gustavo F. Padovan
2011-09-27 21:04 ` [PATCH -v4 05/21] sap: add support to the disable the SAP client Gustavo F. Padovan
2011-09-28 4:34 ` [PATCH -v4 04/21] telit: add telit_sap_disable() Denis Kenzior
0 siblings, 2 replies; 24+ messages in thread
From: Gustavo F. Padovan @ 2011-09-27 21:04 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 1914 bytes --]
From: "Gustavo F. Padovan" <padovan@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 6cde7bc..96e3215 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);
};
struct server;
diff --git a/plugins/telit.c b/plugins/telit.c
index a5f9941..b9a5b23 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()
{
const char *device = "/dev/ttyUSB4";
@@ -191,9 +205,25 @@ static int telit_sap_enable(struct ofono_modem *modem)
return fd;
}
+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,
};
static int telit_probe(struct ofono_modem *modem)
--
1.7.6.2
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH -v4 05/21] sap: add support to the disable the SAP client
2011-09-27 21:04 ` [PATCH -v4 04/21] telit: add telit_sap_disable() Gustavo F. Padovan
@ 2011-09-27 21:04 ` Gustavo F. Padovan
2011-09-27 21:04 ` [PATCH -v4 06/21] telit: add aux GAtChat Gustavo F. Padovan
2011-09-28 4:34 ` [PATCH -v4 04/21] telit: add telit_sap_disable() Denis Kenzior
1 sibling, 1 reply; 24+ messages in thread
From: Gustavo F. Padovan @ 2011-09-27 21:04 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 556 bytes --]
From: "Gustavo F. Padovan" <padovan@profusion.mobi>
---
plugins/sap.c | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/plugins/sap.c b/plugins/sap.c
index f0965f1..abff14c 100644
--- a/plugins/sap.c
+++ b/plugins/sap.c
@@ -283,8 +283,12 @@ static int sap_enable(struct ofono_modem *modem)
static int sap_disable(struct ofono_modem *modem)
{
+ struct sap_data *data = ofono_modem_get_data(modem);
+
DBG("%p", modem);
+ data->sap_driver->disable(data->hw_modem);
+
return 0;
}
--
1.7.6.2
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH -v4 06/21] telit: add aux GAtChat
2011-09-27 21:04 ` [PATCH -v4 05/21] sap: add support to the disable the SAP client Gustavo F. Padovan
@ 2011-09-27 21:04 ` Gustavo F. Padovan
2011-09-27 21:04 ` [PATCH -v4 07/21] sap: enable modem only when #RSEN is 1 Gustavo F. Padovan
0 siblings, 1 reply; 24+ messages in thread
From: Gustavo F. Padovan @ 2011-09-27 21:04 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 1942 bytes --]
From: "Gustavo F. Padovan" <padovan@profusion.mobi>
---
plugins/telit.c | 19 ++++++++++---------
1 files changed, 10 insertions(+), 9 deletions(-)
diff --git a/plugins/telit.c b/plugins/telit.c
index b9a5b23..d5db39f 100644
--- a/plugins/telit.c
+++ b/plugins/telit.c
@@ -65,6 +65,7 @@ static const char *rsen_prefix[]= { "#RSEN:", NULL };
struct telit_data {
GAtChat *chat;
+ GAtChat *aux;
struct ofono_sim *sim;
guint sim_inserted_source;
};
@@ -132,8 +133,8 @@ static void rsen_enable_cb(gboolean ok, GAtResult *result, gpointer user_data)
DBG("%p", modem);
if (!ok) {
- g_at_chat_unref(data->chat);
- data->chat = NULL;
+ g_at_chat_unref(data->aux);
+ data->aux = NULL;
ofono_modem_set_powered(modem, FALSE);
return;
}
@@ -146,8 +147,8 @@ static void rsen_disable_cb(gboolean ok, GAtResult *result, gpointer user_data)
DBG("%p", modem);
- g_at_chat_unref(data->chat);
- data->chat = NULL;
+ g_at_chat_unref(data->aux);
+ data->aux = NULL;
if (ok)
ofono_modem_set_powered(modem, FALSE);
@@ -185,21 +186,21 @@ static int telit_sap_enable(struct ofono_modem *modem)
DBG("%p", modem);
- data->chat = open_device(modem, "Data", "Aux: ");
- if (data->chat == NULL)
+ data->aux = open_device(modem, "Data", "Aux: ");
+ if (data->aux == NULL)
return -EINVAL;
fd = telit_sap_open();
if (fd < 0)
return fd;
- g_at_chat_register(data->chat, "#RSEN:", telit_rsen_notify,
+ g_at_chat_register(data->aux, "#RSEN:", telit_rsen_notify,
FALSE, modem, NULL);
- g_at_chat_send(data->chat, "AT#NOPT=3", NULL, NULL, NULL, NULL);
+ g_at_chat_send(data->aux, "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,
+ g_at_chat_send(data->aux, "AT#RSEN=1,1,0,2,0", rsen_prefix,
rsen_enable_cb, modem, NULL);
return fd;
--
1.7.6.2
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH -v4 07/21] sap: enable modem only when #RSEN is 1
2011-09-27 21:04 ` [PATCH -v4 06/21] telit: add aux GAtChat Gustavo F. Padovan
@ 2011-09-27 21:04 ` Gustavo F. Padovan
2011-09-27 21:04 ` [PATCH -v4 08/21] telit: enable the telit modem when SAP is enabled Gustavo F. Padovan
0 siblings, 1 reply; 24+ messages in thread
From: Gustavo F. Padovan @ 2011-09-27 21:04 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 3529 bytes --]
From: "Gustavo F. Padovan" <padovan@profusion.mobi>
Only put modem powered when Remote SAP Server is enabled
---
plugins/bluetooth.h | 2 +-
plugins/sap.c | 4 +---
plugins/telit.c | 18 +++++++++++++++---
3 files changed, 17 insertions(+), 7 deletions(-)
diff --git a/plugins/bluetooth.h b/plugins/bluetooth.h
index 96e3215..e66e179 100644
--- a/plugins/bluetooth.h
+++ b/plugins/bluetooth.h
@@ -45,7 +45,7 @@ struct bluetooth_profile {
struct bluetooth_sap_driver {
const char *name;
- int (*enable) (struct ofono_modem *modem);
+ int (*enable) (struct ofono_modem *modem, struct ofono_modem *sap_modem);
int (*disable) (struct ofono_modem *modem);
};
diff --git a/plugins/sap.c b/plugins/sap.c
index abff14c..31b5f06 100644
--- a/plugins/sap.c
+++ b/plugins/sap.c
@@ -235,7 +235,7 @@ static void sap_connect_reply(DBusPendingCall *call, gpointer user_data)
data->hw_modem = sap_hw_modem;
data->sap_driver = sap_hw_driver;
- fd = data->sap_driver->enable(data->hw_modem);
+ fd = data->sap_driver->enable(data->hw_modem, modem);
if (fd < 0)
return;
@@ -254,8 +254,6 @@ static void sap_connect_reply(DBusPendingCall *call, gpointer user_data)
G_IO_HUP | G_IO_ERR | G_IO_NVAL | G_IO_IN,
hw_event_cb, modem, hw_watch_remove);
- ofono_modem_set_powered(modem, TRUE);
-
done:
dbus_message_unref(reply);
}
diff --git a/plugins/telit.c b/plugins/telit.c
index d5db39f..c2a5650 100644
--- a/plugins/telit.c
+++ b/plugins/telit.c
@@ -68,6 +68,7 @@ struct telit_data {
GAtChat *aux;
struct ofono_sim *sim;
guint sim_inserted_source;
+ struct ofono_modem *sap_modem;
};
static void telit_debug(const char *str, void *user_data)
@@ -112,6 +113,7 @@ static GAtChat *open_device(struct ofono_modem *modem,
static void telit_rsen_notify(GAtResult *result, gpointer user_data)
{
struct ofono_modem *modem = user_data;
+ struct telit_data *data = ofono_modem_get_data(modem);
int status;
GAtResultIter iter;
@@ -123,6 +125,13 @@ static void telit_rsen_notify(GAtResult *result, gpointer user_data)
return;
g_at_result_iter_next_number(&iter, &status);
+
+ if (status == 0) {
+ ofono_modem_set_powered(data->sap_modem, FALSE);
+ return;
+ }
+
+ ofono_modem_set_powered(data->sap_modem, TRUE);
}
static void rsen_enable_cb(gboolean ok, GAtResult *result, gpointer user_data)
@@ -135,7 +144,7 @@ static void rsen_enable_cb(gboolean ok, GAtResult *result, gpointer user_data)
if (!ok) {
g_at_chat_unref(data->aux);
data->aux = NULL;
- ofono_modem_set_powered(modem, FALSE);
+ ofono_modem_set_powered(data->sap_modem, FALSE);
return;
}
}
@@ -151,7 +160,7 @@ static void rsen_disable_cb(gboolean ok, GAtResult *result, gpointer user_data)
data->aux = NULL;
if (ok)
- ofono_modem_set_powered(modem, FALSE);
+ ofono_modem_set_powered(data->sap_modem, FALSE);
}
static int telit_sap_open()
@@ -179,7 +188,8 @@ static int telit_sap_open()
return fd;
}
-static int telit_sap_enable(struct ofono_modem *modem)
+static int telit_sap_enable(struct ofono_modem *modem,
+ struct ofono_modem *sap_modem)
{
struct telit_data *data = ofono_modem_get_data(modem);
int fd;
@@ -194,6 +204,8 @@ static int telit_sap_enable(struct ofono_modem *modem)
if (fd < 0)
return fd;
+ data->sap_modem = sap_modem;
+
g_at_chat_register(data->aux, "#RSEN:", telit_rsen_notify,
FALSE, modem, NULL);
--
1.7.6.2
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH -v4 08/21] telit: enable the telit modem when SAP is enabled.
2011-09-27 21:04 ` [PATCH -v4 07/21] sap: enable modem only when #RSEN is 1 Gustavo F. Padovan
@ 2011-09-27 21:04 ` Gustavo F. Padovan
2011-09-27 21:04 ` [PATCH -v4 09/21] sap: add pre_sim handling Gustavo F. Padovan
0 siblings, 1 reply; 24+ messages in thread
From: Gustavo F. Padovan @ 2011-09-27 21:04 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 7946 bytes --]
From: "Gustavo F. Padovan" <padovan@profusion.mobi>
---
plugins/telit.c | 265 ++++++++++++++++++++++++++++---------------------------
1 files changed, 133 insertions(+), 132 deletions(-)
diff --git a/plugins/telit.c b/plugins/telit.c
index c2a5650..55d01d6 100644
--- a/plugins/telit.c
+++ b/plugins/telit.c
@@ -110,6 +110,137 @@ static GAtChat *open_device(struct ofono_modem *modem,
return chat;
}
+static gboolean sim_inserted_timeout_cb(gpointer user_data)
+{
+ struct ofono_modem *modem = user_data;
+ struct telit_data *data = ofono_modem_get_data(modem);
+
+ DBG("%p", modem);
+
+ data->sim_inserted_source = 0;
+
+ ofono_sim_inserted_notify(data->sim, TRUE);
+
+ return FALSE;
+}
+
+static void switch_sim_state_status(struct ofono_modem *modem, int status)
+{
+ struct telit_data *data = ofono_modem_get_data(modem);
+
+ DBG("%p", modem);
+
+ switch (status) {
+ case 0:
+ DBG("SIM not inserted");
+ ofono_sim_inserted_notify(data->sim, FALSE);
+ break;
+ case 1:
+ DBG("SIM inserted");
+ /* We need to sleep a bit */
+ data->sim_inserted_source = g_timeout_add_seconds(1,
+ sim_inserted_timeout_cb,
+ modem);
+ break;
+ case 2:
+ DBG("SIM inserted and PIN unlocked");
+ break;
+ case 3:
+ DBG("SIM inserted and ready");
+ break;
+ }
+}
+
+static void telit_qss_notify(GAtResult *result, gpointer user_data)
+{
+ struct ofono_modem *modem = user_data;
+ int status;
+ GAtResultIter iter;
+
+ DBG("%p", modem);
+
+ g_at_result_iter_init(&iter, result);
+
+ if (!g_at_result_iter_next(&iter, "#QSS:"))
+ return;
+
+ g_at_result_iter_next_number(&iter, &status);
+
+ switch_sim_state_status(modem, status);
+}
+
+static void telit_qss_cb(gboolean ok, GAtResult *result, gpointer user_data)
+{
+ struct ofono_modem *modem = user_data;
+ int mode;
+ int status;
+ GAtResultIter iter;
+ g_at_result_iter_init(&iter, result);
+
+ DBG("%p", modem);
+
+ if (!g_at_result_iter_next(&iter, "#QSS:"))
+ return;
+
+ g_at_result_iter_next_number(&iter, &mode);
+ g_at_result_iter_next_number(&iter, &status);
+
+ switch_sim_state_status(modem, status);
+}
+
+static void cfun_enable_cb(gboolean ok, GAtResult *result, gpointer user_data)
+{
+ struct ofono_modem *modem = user_data;
+ struct telit_data *data = ofono_modem_get_data(modem);
+ struct ofono_modem *m = data->sap_modem ? : modem;
+
+ DBG("%p", modem);
+
+ if (!ok) {
+ g_at_chat_unref(data->chat);
+ data->chat = NULL;
+ ofono_modem_set_powered(m, FALSE);
+ return;
+ }
+
+ ofono_modem_set_powered(m, TRUE);
+
+ /* Enable sim state notification */
+ g_at_chat_send(data->chat, "AT#QSS=1", none_prefix, NULL, NULL, NULL);
+
+ /* Follow sim state */
+ g_at_chat_register(data->chat, "#QSS:", telit_qss_notify,
+ FALSE, modem, NULL);
+
+ /* Query current sim state */
+ g_at_chat_send(data->chat, "AT#QSS?", qss_prefix,
+ telit_qss_cb, modem, NULL);
+}
+
+static int telit_enable(struct ofono_modem *modem)
+{
+ struct telit_data *data = ofono_modem_get_data(modem);
+
+ DBG("%p", modem);
+
+ data->chat = open_device(modem, "Modem", "Modem: ");
+ if (data->chat == NULL)
+ return -EINVAL;
+
+ /*
+ * Disable command echo and
+ * enable the Extended Error Result Codes
+ */
+ g_at_chat_send(data->chat, "ATE0 +CMEE=1", none_prefix,
+ NULL, NULL, NULL);
+
+ /* Set phone functionality */
+ g_at_chat_send(data->chat, "AT+CFUN=4", none_prefix,
+ cfun_enable_cb, modem, NULL);
+
+ return -EINPROGRESS;
+}
+
static void telit_rsen_notify(GAtResult *result, gpointer user_data)
{
struct ofono_modem *modem = user_data;
@@ -131,7 +262,7 @@ static void telit_rsen_notify(GAtResult *result, gpointer user_data)
return;
}
- ofono_modem_set_powered(data->sap_modem, TRUE);
+ telit_enable(modem);
}
static void rsen_enable_cb(gboolean ok, GAtResult *result, gpointer user_data)
@@ -209,7 +340,7 @@ static int telit_sap_enable(struct ofono_modem *modem,
g_at_chat_register(data->aux, "#RSEN:", telit_rsen_notify,
FALSE, modem, NULL);
- g_at_chat_send(data->aux, "AT#NOPT=3", NULL, NULL, NULL, NULL);
+ g_at_chat_send(data->aux, "AT#NOPT=0", NULL, NULL, NULL, NULL);
/* Set SAP functionality */
g_at_chat_send(data->aux, "AT#RSEN=1,1,0,2,0", rsen_prefix,
@@ -272,112 +403,6 @@ static void telit_remove(struct ofono_modem *modem)
g_free(data);
}
-static gboolean sim_inserted_timeout_cb(gpointer user_data)
-{
- struct ofono_modem *modem = user_data;
- struct telit_data *data = ofono_modem_get_data(modem);
-
- DBG("%p", modem);
-
- data->sim_inserted_source = 0;
-
- ofono_sim_inserted_notify(data->sim, TRUE);
-
- return FALSE;
-}
-
-static void switch_sim_state_status(struct ofono_modem *modem, int status)
-{
- struct telit_data *data = ofono_modem_get_data(modem);
-
- DBG("%p", modem);
-
- switch (status) {
- case 0:
- DBG("SIM not inserted");
- ofono_sim_inserted_notify(data->sim, FALSE);
- break;
- case 1:
- DBG("SIM inserted");
- /* We need to sleep a bit */
- data->sim_inserted_source = g_timeout_add_seconds(1,
- sim_inserted_timeout_cb,
- modem);
- break;
- case 2:
- DBG("SIM inserted and PIN unlocked");
- break;
- case 3:
- DBG("SIM inserted and ready");
- break;
- }
-}
-
-static void telit_qss_notify(GAtResult *result, gpointer user_data)
-{
- struct ofono_modem *modem = user_data;
- int status;
- GAtResultIter iter;
-
- DBG("%p", modem);
-
- g_at_result_iter_init(&iter, result);
-
- if (!g_at_result_iter_next(&iter, "#QSS:"))
- return;
-
- g_at_result_iter_next_number(&iter, &status);
-
- switch_sim_state_status(modem, status);
-}
-
-static void telit_qss_cb(gboolean ok, GAtResult *result, gpointer user_data)
-{
- struct ofono_modem *modem = user_data;
- int mode;
- int status;
- GAtResultIter iter;
- g_at_result_iter_init(&iter, result);
-
- DBG("%p", modem);
-
- if (!g_at_result_iter_next(&iter, "#QSS:"))
- return;
-
- g_at_result_iter_next_number(&iter, &mode);
- g_at_result_iter_next_number(&iter, &status);
-
- switch_sim_state_status(modem, status);
-}
-
-static void cfun_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;
- }
-
- ofono_modem_set_powered(modem, TRUE);
-
- /* Enable sim state notification */
- g_at_chat_send(data->chat, "AT#QSS=1", none_prefix, NULL, NULL, NULL);
-
- /* Follow sim state */
- g_at_chat_register(data->chat, "#QSS:", telit_qss_notify,
- FALSE, modem, NULL);
-
- /* Query current sim state */
- g_at_chat_send(data->chat, "AT#QSS?", qss_prefix,
- telit_qss_cb, modem, NULL);
-}
-
static void cfun_disable_cb(gboolean ok, GAtResult *result, gpointer user_data)
{
struct ofono_modem *modem = user_data;
@@ -395,30 +420,6 @@ static void cfun_disable_cb(gboolean ok, GAtResult *result, gpointer user_data)
ofono_modem_set_powered(modem, FALSE);
}
-static int telit_enable(struct ofono_modem *modem)
-{
- struct telit_data *data = ofono_modem_get_data(modem);
-
- DBG("%p", modem);
-
- data->chat = open_device(modem, "Modem", "Modem: ");
- if (data->chat == NULL)
- return -EINVAL;
-
- /*
- * Disable command echo and
- * enable the Extended Error Result Codes
- */
- g_at_chat_send(data->chat, "ATE0 +CMEE=1", none_prefix,
- NULL, NULL, NULL);
-
- /* Set phone functionality */
- g_at_chat_send(data->chat, "AT+CFUN=4", none_prefix,
- cfun_enable_cb, modem, NULL);
-
- return -EINPROGRESS;
-}
-
static int telit_disable(struct ofono_modem *modem)
{
struct telit_data *data = ofono_modem_get_data(modem);
--
1.7.6.2
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH -v4 09/21] sap: add pre_sim handling
2011-09-27 21:04 ` [PATCH -v4 08/21] telit: enable the telit modem when SAP is enabled Gustavo F. Padovan
@ 2011-09-27 21:04 ` Gustavo F. Padovan
2011-09-27 21:04 ` [PATCH -v4 10/21] sap: add set_online handling Gustavo F. Padovan
0 siblings, 1 reply; 24+ messages in thread
From: Gustavo F. Padovan @ 2011-09-27 21:04 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 2479 bytes --]
From: "Gustavo F. Padovan" <padovan@profusion.mobi>
---
plugins/bluetooth.h | 1 +
plugins/sap.c | 4 ++++
plugins/telit.c | 26 +++++++++++++++-----------
3 files changed, 20 insertions(+), 11 deletions(-)
diff --git a/plugins/bluetooth.h b/plugins/bluetooth.h
index e66e179..740ecce 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, struct ofono_modem *sap_modem);
+ void (*pre_sim) (struct ofono_modem *modem);
int (*disable) (struct ofono_modem *modem);
};
diff --git a/plugins/sap.c b/plugins/sap.c
index 31b5f06..2a8b618 100644
--- a/plugins/sap.c
+++ b/plugins/sap.c
@@ -292,7 +292,11 @@ static int sap_disable(struct ofono_modem *modem)
static void sap_pre_sim(struct ofono_modem *modem)
{
+ struct sap_data *data = ofono_modem_get_data(modem);
+
DBG("%p", modem);
+
+ data->sap_driver->pre_sim(data->hw_modem);
}
static void sap_post_sim(struct ofono_modem *modem)
diff --git a/plugins/telit.c b/plugins/telit.c
index 55d01d6..6791c6e 100644
--- a/plugins/telit.c
+++ b/plugins/telit.c
@@ -364,9 +364,24 @@ static int telit_sap_disable(struct ofono_modem *modem)
return 0;
}
+static void telit_pre_sim(struct ofono_modem *modem)
+{
+ struct telit_data *data = ofono_modem_get_data(modem);
+
+ if (data->sap_modem)
+ modem = data->sap_modem;
+
+ DBG("%p", modem);
+
+ ofono_devinfo_create(modem, 0, "atmodem", data->chat);
+ data->sim = ofono_sim_create(modem, 0, "atmodem", data->chat);
+ ofono_voicecall_create(modem, 0, "atmodem", data->chat);
+}
+
static struct bluetooth_sap_driver sap_driver = {
.name = "telit",
.enable = telit_sap_enable,
+ .pre_sim = telit_pre_sim,
.disable = telit_sap_disable,
};
@@ -458,17 +473,6 @@ static void telit_set_online(struct ofono_modem *modem, ofono_bool_t online,
cbd, g_free);
}
-static void telit_pre_sim(struct ofono_modem *modem)
-{
- struct telit_data *data = ofono_modem_get_data(modem);
-
- DBG("%p", modem);
-
- ofono_devinfo_create(modem, 0, "atmodem", data->chat);
- data->sim = ofono_sim_create(modem, 0, "atmodem", data->chat);
- ofono_voicecall_create(modem, 0, "atmodem", data->chat);
-}
-
static void telit_post_sim(struct ofono_modem *modem)
{
struct telit_data *data = ofono_modem_get_data(modem);
--
1.7.6.2
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH -v4 10/21] sap: add set_online handling
2011-09-27 21:04 ` [PATCH -v4 09/21] sap: add pre_sim handling Gustavo F. Padovan
@ 2011-09-27 21:04 ` Gustavo F. Padovan
2011-09-27 21:04 ` [PATCH -v4 11/21] sap: add post_sim handling Gustavo F. Padovan
0 siblings, 1 reply; 24+ messages in thread
From: Gustavo F. Padovan @ 2011-09-27 21:04 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 4100 bytes --]
From: "Gustavo F. Padovan" <padovan@profusion.mobi>
---
plugins/bluetooth.h | 2 +
plugins/sap.c | 11 ++++++++++
plugins/telit.c | 56 +++++++++++++++++++++-----------------------------
3 files changed, 37 insertions(+), 32 deletions(-)
diff --git a/plugins/bluetooth.h b/plugins/bluetooth.h
index 740ecce..257f092 100644
--- a/plugins/bluetooth.h
+++ b/plugins/bluetooth.h
@@ -47,6 +47,8 @@ struct bluetooth_sap_driver {
const char *name;
int (*enable) (struct ofono_modem *modem, struct ofono_modem *sap_modem);
void (*pre_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/sap.c b/plugins/sap.c
index 2a8b618..1713d4c 100644
--- a/plugins/sap.c
+++ b/plugins/sap.c
@@ -304,6 +304,16 @@ static void sap_post_sim(struct ofono_modem *modem)
DBG("%p", modem);
}
+static void sap_set_online(struct ofono_modem *modem, ofono_bool_t online,
+ ofono_modem_online_cb_t cb, void *user_data)
+{
+ struct sap_data *data = ofono_modem_get_data(modem);
+
+ DBG("%p", modem);
+
+ data->sap_driver->set_online(data->hw_modem, online, cb, user_data);
+}
+
static int bluetooth_sap_probe(const char *device, const char *dev_addr,
const char *adapter_addr, const char *alias)
{
@@ -395,6 +405,7 @@ static struct ofono_modem_driver sap_driver = {
.disable = sap_disable,
.pre_sim = sap_pre_sim,
.post_sim = sap_post_sim,
+ .set_online = sap_set_online,
};
static struct bluetooth_profile sap = {
diff --git a/plugins/telit.c b/plugins/telit.c
index 6791c6e..da89b1c 100644
--- a/plugins/telit.c
+++ b/plugins/telit.c
@@ -378,10 +378,34 @@ static void telit_pre_sim(struct ofono_modem *modem)
ofono_voicecall_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,
+ .set_online = telit_set_online,
.disable = telit_sap_disable,
};
@@ -450,38 +474,6 @@ static int telit_disable(struct ofono_modem *modem)
return -EINPROGRESS;
}
-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_sim(struct ofono_modem *modem)
-{
- struct telit_data *data = ofono_modem_get_data(modem);
-
- DBG("%p", modem);
-
- ofono_sms_create(modem, 0, "atmodem", data->chat);
-}
-
static void telit_post_online(struct ofono_modem *modem)
{
struct telit_data *data = ofono_modem_get_data(modem);
--
1.7.6.2
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH -v4 11/21] sap: add post_sim handling
2011-09-27 21:04 ` [PATCH -v4 10/21] sap: add set_online handling Gustavo F. Padovan
@ 2011-09-27 21:04 ` Gustavo F. Padovan
2011-09-27 21:04 ` [PATCH -v4 12/21] sap: add post_online handling Gustavo F. Padovan
0 siblings, 1 reply; 24+ messages in thread
From: Gustavo F. Padovan @ 2011-09-27 21:04 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 2162 bytes --]
From: "Gustavo F. Padovan" <padovan@profusion.mobi>
---
plugins/bluetooth.h | 1 +
plugins/sap.c | 4 ++++
plugins/telit.c | 13 +++++++++++++
3 files changed, 18 insertions(+), 0 deletions(-)
diff --git a/plugins/bluetooth.h b/plugins/bluetooth.h
index 257f092..8fe4093 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);
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/sap.c b/plugins/sap.c
index 1713d4c..309028b 100644
--- a/plugins/sap.c
+++ b/plugins/sap.c
@@ -301,7 +301,11 @@ static void sap_pre_sim(struct ofono_modem *modem)
static void sap_post_sim(struct ofono_modem *modem)
{
+ struct sap_data *data = ofono_modem_get_data(modem);
+
DBG("%p", modem);
+
+ data->sap_driver->post_sim(data->hw_modem);
}
static void sap_set_online(struct ofono_modem *modem, ofono_bool_t online,
diff --git a/plugins/telit.c b/plugins/telit.c
index da89b1c..7687162 100644
--- a/plugins/telit.c
+++ b/plugins/telit.c
@@ -378,6 +378,18 @@ static void telit_pre_sim(struct ofono_modem *modem)
ofono_voicecall_create(modem, 0, "atmodem", data->chat);
}
+static void telit_post_sim(struct ofono_modem *modem)
+{
+ struct telit_data *data = ofono_modem_get_data(modem);
+
+ if (data->sap_modem)
+ modem = data->sap_modem;
+
+ DBG("%p", 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;
@@ -405,6 +417,7 @@ 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,
};
--
1.7.6.2
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH -v4 12/21] sap: add post_online handling
2011-09-27 21:04 ` [PATCH -v4 11/21] sap: add post_sim handling Gustavo F. Padovan
@ 2011-09-27 21:04 ` Gustavo F. Padovan
2011-09-27 21:04 ` [PATCH -v4 13/21] telit: improve sap disable Gustavo F. Padovan
0 siblings, 1 reply; 24+ messages in thread
From: Gustavo F. Padovan @ 2011-09-27 21:04 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 4263 bytes --]
From: "Gustavo F. Padovan" <padovan@profusion.mobi>
---
plugins/bluetooth.h | 1 +
plugins/sap.c | 10 ++++++++
plugins/telit.c | 58 +++++++++++++++++++++++++++-----------------------
3 files changed, 42 insertions(+), 27 deletions(-)
diff --git a/plugins/bluetooth.h b/plugins/bluetooth.h
index 8fe4093..5e25518 100644
--- a/plugins/bluetooth.h
+++ b/plugins/bluetooth.h
@@ -50,6 +50,7 @@ struct bluetooth_sap_driver {
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);
+ void (*post_online) (struct ofono_modem *modem);
int (*disable) (struct ofono_modem *modem);
};
diff --git a/plugins/sap.c b/plugins/sap.c
index 309028b..b0abda8 100644
--- a/plugins/sap.c
+++ b/plugins/sap.c
@@ -318,6 +318,15 @@ static void sap_set_online(struct ofono_modem *modem, ofono_bool_t online,
data->sap_driver->set_online(data->hw_modem, online, cb, user_data);
}
+static void sap_post_online(struct ofono_modem *modem)
+{
+ struct sap_data *data = ofono_modem_get_data(modem);
+
+ DBG("%p", modem);
+
+ data->sap_driver->post_online(data->hw_modem);
+}
+
static int bluetooth_sap_probe(const char *device, const char *dev_addr,
const char *adapter_addr, const char *alias)
{
@@ -410,6 +419,7 @@ static struct ofono_modem_driver sap_driver = {
.pre_sim = sap_pre_sim,
.post_sim = sap_post_sim,
.set_online = sap_set_online,
+ .post_online = sap_post_online,
};
static struct bluetooth_profile sap = {
diff --git a/plugins/telit.c b/plugins/telit.c
index 7687162..0ae769d 100644
--- a/plugins/telit.c
+++ b/plugins/telit.c
@@ -413,12 +413,43 @@ static void telit_set_online(struct ofono_modem *modem, ofono_bool_t online,
cbd, g_free);
}
+static void telit_post_online(struct ofono_modem *modem)
+{
+ struct telit_data *data = ofono_modem_get_data(modem);
+ struct ofono_message_waiting *mw;
+ struct ofono_gprs *gprs;
+ struct ofono_gprs_context *gc;
+
+ if(data->sap_modem)
+ modem = data->sap_modem;
+
+ DBG("%p", modem);
+
+ ofono_netreg_create(modem, OFONO_VENDOR_TELIT, "atmodem", data->chat);
+ ofono_ussd_create(modem, 0, "atmodem", data->chat);
+ ofono_call_forwarding_create(modem, 0, "atmodem", data->chat);
+ ofono_call_settings_create(modem, 0, "atmodem", data->chat);
+ ofono_call_meter_create(modem, 0, "atmodem", data->chat);
+ ofono_call_barring_create(modem, 0, "atmodem", data->chat);
+
+ gprs = ofono_gprs_create(modem, 0, "atmodem", data->chat);
+ gc = ofono_gprs_context_create(modem, 0, "atmodem", data->chat);
+
+ if (gprs && gc)
+ ofono_gprs_add_context(gprs, gc);
+
+ mw = ofono_message_waiting_create(modem);
+ if (mw)
+ ofono_message_waiting_register(mw);
+}
+
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,
+ .post_online = telit_post_online,
.disable = telit_sap_disable,
};
@@ -487,33 +518,6 @@ static int telit_disable(struct ofono_modem *modem)
return -EINPROGRESS;
}
-static void telit_post_online(struct ofono_modem *modem)
-{
- struct telit_data *data = ofono_modem_get_data(modem);
- struct ofono_message_waiting *mw;
- struct ofono_gprs *gprs;
- struct ofono_gprs_context *gc;
-
- DBG("%p", modem);
-
- ofono_netreg_create(modem, OFONO_VENDOR_TELIT, "atmodem", data->chat);
- ofono_ussd_create(modem, 0, "atmodem", data->chat);
- ofono_call_forwarding_create(modem, 0, "atmodem", data->chat);
- ofono_call_settings_create(modem, 0, "atmodem", data->chat);
- ofono_call_meter_create(modem, 0, "atmodem", data->chat);
- ofono_call_barring_create(modem, 0, "atmodem", data->chat);
-
- gprs = ofono_gprs_create(modem, 0, "atmodem", data->chat);
- gc = ofono_gprs_context_create(modem, 0, "atmodem", data->chat);
-
- if (gprs && gc)
- ofono_gprs_add_context(gprs, gc);
-
- mw = ofono_message_waiting_create(modem);
- if (mw)
- ofono_message_waiting_register(mw);
-}
-
static struct ofono_modem_driver telit_driver = {
.name = "telit",
.probe = telit_probe,
--
1.7.6.2
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH -v4 13/21] telit: improve sap disable
2011-09-27 21:04 ` [PATCH -v4 12/21] sap: add post_online handling Gustavo F. Padovan
@ 2011-09-27 21:04 ` Gustavo F. Padovan
2011-09-27 21:04 ` [PATCH -v4 14/21] sap: disconnect link if enable() fails Gustavo F. Padovan
0 siblings, 1 reply; 24+ messages in thread
From: Gustavo F. Padovan @ 2011-09-27 21:04 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 3157 bytes --]
From: "Gustavo F. Padovan" <padovan@profusion.mobi>
---
plugins/telit.c | 78 +++++++++++++++++++++++++++++--------------------------
1 files changed, 41 insertions(+), 37 deletions(-)
diff --git a/plugins/telit.c b/plugins/telit.c
index 0ae769d..6ceff57 100644
--- a/plugins/telit.c
+++ b/plugins/telit.c
@@ -280,6 +280,43 @@ 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;
@@ -290,8 +327,7 @@ static void rsen_disable_cb(gboolean ok, GAtResult *result, gpointer user_data)
g_at_chat_unref(data->aux);
data->aux = NULL;
- if (ok)
- ofono_modem_set_powered(data->sap_modem, FALSE);
+ telit_disable(modem);
}
static int telit_sap_open()
@@ -355,10 +391,10 @@ static int telit_sap_disable(struct ofono_modem *modem)
DBG("%p", modem);
- g_at_chat_cancel_all(data->chat);
- g_at_chat_unregister_all(data->chat);
+ g_at_chat_cancel_all(data->aux);
+ g_at_chat_unregister_all(data->aux);
- g_at_chat_send(data->chat, "AT#RSEN=0", rsen_prefix,
+ g_at_chat_send(data->aux, "AT#RSEN=0", rsen_prefix,
rsen_disable_cb, modem, NULL);
return 0;
@@ -486,38 +522,6 @@ static void telit_remove(struct ofono_modem *modem)
g_free(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);
-
- 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_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 struct ofono_modem_driver telit_driver = {
.name = "telit",
.probe = telit_probe,
--
1.7.6.2
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH -v4 14/21] sap: disconnect link if enable() fails
2011-09-27 21:04 ` [PATCH -v4 13/21] telit: improve sap disable Gustavo F. Padovan
@ 2011-09-27 21:04 ` Gustavo F. Padovan
2011-09-27 21:04 ` [PATCH -v4 15/21] sap: do a proper shutdown of the channels Gustavo F. Padovan
0 siblings, 1 reply; 24+ messages in thread
From: Gustavo F. Padovan @ 2011-09-27 21:04 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 3360 bytes --]
From: "Gustavo F. Padovan" <padovan@profusion.mobi>
We should disconnect the bluetooh link if sap_modem enabling fails.
---
plugins/bluetooth.h | 5 ++++-
plugins/sap.c | 7 ++++++-
plugins/telit.c | 9 ++++++++-
3 files changed, 18 insertions(+), 3 deletions(-)
diff --git a/plugins/bluetooth.h b/plugins/bluetooth.h
index 5e25518..5457c0b 100644
--- a/plugins/bluetooth.h
+++ b/plugins/bluetooth.h
@@ -43,9 +43,12 @@ struct bluetooth_profile {
void (*set_alias)(const char *device, const char *);
};
+typedef void (*ConnectFailed)(struct ofono_modem *modem);
+
struct bluetooth_sap_driver {
const char *name;
- int (*enable) (struct ofono_modem *modem, struct ofono_modem *sap_modem);
+ int (*enable) (struct ofono_modem *modem, struct ofono_modem *sap_modem,
+ ConnectFailed cb);
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,
diff --git a/plugins/sap.c b/plugins/sap.c
index b0abda8..4f29477 100644
--- a/plugins/sap.c
+++ b/plugins/sap.c
@@ -190,6 +190,11 @@ static void sap_remove(struct ofono_modem *modem)
DBG("%p", modem);
}
+static void sap_failed_cb(struct ofono_modem *modem)
+{
+ DBG("%p", modem);
+}
+
static void sap_connect_reply(DBusPendingCall *call, gpointer user_data)
{
struct ofono_modem *modem = user_data;
@@ -235,7 +240,7 @@ static void sap_connect_reply(DBusPendingCall *call, gpointer user_data)
data->hw_modem = sap_hw_modem;
data->sap_driver = sap_hw_driver;
- fd = data->sap_driver->enable(data->hw_modem, modem);
+ fd = data->sap_driver->enable(data->hw_modem, modem, sap_failed_cb);
if (fd < 0)
return;
diff --git a/plugins/telit.c b/plugins/telit.c
index 6ceff57..7674b09 100644
--- a/plugins/telit.c
+++ b/plugins/telit.c
@@ -69,6 +69,7 @@ struct telit_data {
struct ofono_sim *sim;
guint sim_inserted_source;
struct ofono_modem *sap_modem;
+ ConnectFailed cb;
};
static void telit_debug(const char *str, void *user_data)
@@ -200,6 +201,7 @@ static void cfun_enable_cb(gboolean ok, GAtResult *result, gpointer user_data)
g_at_chat_unref(data->chat);
data->chat = NULL;
ofono_modem_set_powered(m, FALSE);
+ data->cb(data->sap_modem);
return;
}
@@ -259,6 +261,7 @@ static void telit_rsen_notify(GAtResult *result, gpointer user_data)
if (status == 0) {
ofono_modem_set_powered(data->sap_modem, FALSE);
+ data->cb(data->sap_modem);
return;
}
@@ -276,6 +279,7 @@ static void rsen_enable_cb(gboolean ok, GAtResult *result, gpointer user_data)
g_at_chat_unref(data->aux);
data->aux = NULL;
ofono_modem_set_powered(data->sap_modem, FALSE);
+ data->cb(data->sap_modem);
return;
}
}
@@ -356,7 +360,8 @@ static int telit_sap_open()
}
static int telit_sap_enable(struct ofono_modem *modem,
- struct ofono_modem *sap_modem)
+ struct ofono_modem *sap_modem,
+ ConnectFailed cb)
{
struct telit_data *data = ofono_modem_get_data(modem);
int fd;
@@ -373,6 +378,8 @@ static int telit_sap_enable(struct ofono_modem *modem,
data->sap_modem = sap_modem;
+ data->cb = cb;
+
g_at_chat_register(data->aux, "#RSEN:", telit_rsen_notify,
FALSE, modem, NULL);
--
1.7.6.2
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH -v4 15/21] sap: do a proper shutdown of the channels
2011-09-27 21:04 ` [PATCH -v4 14/21] sap: disconnect link if enable() fails Gustavo F. Padovan
@ 2011-09-27 21:04 ` Gustavo F. Padovan
2011-09-27 21:04 ` [PATCH -v4 16/21] sap: retrigger bluetooth GetProperties call Gustavo F. Padovan
0 siblings, 1 reply; 24+ messages in thread
From: Gustavo F. Padovan @ 2011-09-27 21:04 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 2221 bytes --]
From: "Gustavo F. Padovan" <padovan@profusion.mobi>
---
plugins/sap.c | 37 +++++++++++++++++++++++++++++++++++--
1 files changed, 35 insertions(+), 2 deletions(-)
diff --git a/plugins/sap.c b/plugins/sap.c
index 4f29477..c8b0ef5 100644
--- a/plugins/sap.c
+++ b/plugins/sap.c
@@ -28,6 +28,7 @@
#include <stdio.h>
#include <errno.h>
#include <unistd.h>
+#include <sys/socket.h>
#include <glib.h>
#include <gdbus.h>
#include <ofono.h>
@@ -73,10 +74,36 @@ int bluetooth_sap_client_register(struct bluetooth_sap_driver *sap,
return 0;
}
+static void sap_close_io(struct ofono_modem *modem)
+{
+ struct sap_data *data = ofono_modem_get_data(modem);
+
+ if (data->bt_io != NULL) {
+ int sk = g_io_channel_unix_get_fd(data->bt_io);
+ shutdown(sk, SHUT_RDWR);
+
+ g_io_channel_unref(data->bt_io);
+ data->bt_io = NULL;
+ }
+
+ if (data->bt_watch > 0)
+ g_source_remove(data->bt_watch);
+
+ if (data->hw_io != NULL) {
+ g_io_channel_unref(data->hw_io);
+ data->hw_io = NULL;
+ }
+
+ if (data->hw_watch > 0)
+ g_source_remove(data->hw_watch);
+}
+
static void sap_remove_modem(struct ofono_modem *modem)
{
struct sap_data *data = ofono_modem_get_data(modem);
+ sap_close_io(modem);
+
g_free(data->server_path);
g_free(data);
@@ -193,6 +220,8 @@ static void sap_remove(struct ofono_modem *modem)
static void sap_failed_cb(struct ofono_modem *modem)
{
DBG("%p", modem);
+
+ sap_close_io(modem);
}
static void sap_connect_reply(DBusPendingCall *call, gpointer user_data)
@@ -241,12 +270,14 @@ static void sap_connect_reply(DBusPendingCall *call, gpointer user_data)
data->sap_driver = sap_hw_driver;
fd = data->sap_driver->enable(data->hw_modem, modem, sap_failed_cb);
- if (fd < 0)
+ if (!fd) {
+ sap_close_io(modem);
return;
+ }
data->hw_io = g_io_channel_unix_new(fd);
if (data->hw_io == NULL) {
- g_io_channel_unref(data->bt_io);
+ sap_close_io(modem);
close(fd);
return;
}
@@ -290,6 +321,8 @@ static int sap_disable(struct ofono_modem *modem)
DBG("%p", modem);
+ sap_close_io(modem);
+
data->sap_driver->disable(data->hw_modem);
return 0;
--
1.7.6.2
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH -v4 16/21] sap: retrigger bluetooth GetProperties call
2011-09-27 21:04 ` [PATCH -v4 15/21] sap: do a proper shutdown of the channels Gustavo F. Padovan
@ 2011-09-27 21:04 ` Gustavo F. Padovan
2011-09-27 21:04 ` [PATCH -v4 17/21] telit: add needed flags to proper connect the serial port Gustavo F. Padovan
2011-09-28 4:37 ` [PATCH -v4 16/21] sap: retrigger bluetooth GetProperties call Denis Kenzior
0 siblings, 2 replies; 24+ messages in thread
From: Gustavo F. Padovan @ 2011-09-27 21:04 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 1590 bytes --]
From: "Gustavo F. Padovan" <padovan@profusion.mobi>
When plugging a SAP capable modem, GetProperties need to be called again
to fetch the SAP Server devices from BlueZ.
---
plugins/bluetooth.c | 6 ++++++
plugins/bluetooth.h | 1 +
plugins/sap.c | 2 ++
3 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/plugins/bluetooth.c b/plugins/bluetooth.c
index 274d25b..573c7c8 100644
--- a/plugins/bluetooth.c
+++ b/plugins/bluetooth.c
@@ -900,6 +900,12 @@ static void bluetooth_unref(void)
g_hash_table_destroy(adapter_address_hash);
}
+void bluetooth_get_properties()
+{
+ g_hash_table_foreach(adapter_address_hash,
+ (GHFunc) get_adapter_properties, NULL);
+}
+
int bluetooth_register_uuid(const char *uuid, struct bluetooth_profile *profile)
{
bluetooth_ref();
diff --git a/plugins/bluetooth.h b/plugins/bluetooth.h
index 5457c0b..723f79b 100644
--- a/plugins/bluetooth.h
+++ b/plugins/bluetooth.h
@@ -61,6 +61,7 @@ struct server;
typedef void (*ConnectFunc)(GIOChannel *io, GError *err, gpointer user_data);
+void bluetooth_get_properties();
int bluetooth_register_uuid(const char *uuid,
struct bluetooth_profile *profile);
void bluetooth_unregister_uuid(const char *uuid);
diff --git a/plugins/sap.c b/plugins/sap.c
index c8b0ef5..fbca3d8 100644
--- a/plugins/sap.c
+++ b/plugins/sap.c
@@ -71,6 +71,8 @@ int bluetooth_sap_client_register(struct bluetooth_sap_driver *sap,
sap_hw_modem = modem;
sap_hw_driver = sap;
+ bluetooth_get_properties();
+
return 0;
}
--
1.7.6.2
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH -v4 17/21] telit: add needed flags to proper connect the serial port
2011-09-27 21:04 ` [PATCH -v4 16/21] sap: retrigger bluetooth GetProperties call Gustavo F. Padovan
@ 2011-09-27 21:04 ` Gustavo F. Padovan
2011-09-27 21:04 ` [PATCH -v4 18/21] sap: de-register DBus callback if BlueZ goes down Gustavo F. Padovan
2011-09-28 4:37 ` [PATCH -v4 16/21] sap: retrigger bluetooth GetProperties call Denis Kenzior
1 sibling, 1 reply; 24+ messages in thread
From: Gustavo F. Padovan @ 2011-09-27 21:04 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 516 bytes --]
From: "Gustavo F. Padovan" <padovan@profusion.mobi>
---
plugins/telit.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/plugins/telit.c b/plugins/telit.c
index 7674b09..404f74e 100644
--- a/plugins/telit.c
+++ b/plugins/telit.c
@@ -350,6 +350,8 @@ static int telit_sap_open()
memset(&ti, 0, sizeof(ti));
cfmakeraw(&ti);
+ ti.c_cflag |= (B115200 | CLOCAL | CREAD);
+
tcflush(fd, TCIOFLUSH);
if (tcsetattr(fd, TCSANOW, &ti) < 0) {
close(fd);
--
1.7.6.2
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH -v4 18/21] sap: de-register DBus callback if BlueZ goes down
2011-09-27 21:04 ` [PATCH -v4 17/21] telit: add needed flags to proper connect the serial port Gustavo F. Padovan
@ 2011-09-27 21:04 ` Gustavo F. Padovan
2011-09-27 21:04 ` [PATCH -v4 19/21] sap: remove server_path Gustavo F. Padovan
0 siblings, 1 reply; 24+ messages in thread
From: Gustavo F. Padovan @ 2011-09-27 21:04 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 1592 bytes --]
From: "Gustavo F. Padovan" <padovan@profusion.mobi>
---
plugins/sap.c | 11 ++++++++++-
1 files changed, 10 insertions(+), 1 deletions(-)
diff --git a/plugins/sap.c b/plugins/sap.c
index fbca3d8..9b8e670 100644
--- a/plugins/sap.c
+++ b/plugins/sap.c
@@ -60,6 +60,7 @@ struct sap_data {
GIOChannel *hw_io;
guint bt_watch;
guint hw_watch;
+ DBusPendingCall *call;
};
int bluetooth_sap_client_register(struct bluetooth_sap_driver *sap,
@@ -106,6 +107,9 @@ static void sap_remove_modem(struct ofono_modem *modem)
sap_close_io(modem);
+ if (data->call != NULL)
+ dbus_pending_call_cancel(data->call);
+
g_free(data->server_path);
g_free(data);
@@ -238,6 +242,8 @@ static void sap_connect_reply(DBusPendingCall *call, gpointer user_data)
reply = dbus_pending_call_steal_reply(call);
+ data->call = NULL;
+
if (ofono_modem_get_powered(modem))
goto done;
@@ -300,6 +306,7 @@ done:
static int sap_enable(struct ofono_modem *modem)
{
struct sap_data *data = ofono_modem_get_data(modem);
+ DBusPendingCall *call;
int status;
const char *str = "sap";
@@ -307,13 +314,15 @@ static int sap_enable(struct ofono_modem *modem)
status = bluetooth_send_with_reply(data->server_path,
BLUEZ_SERIAL_INTERFACE, "ConnectFD",
- NULL, sap_connect_reply, modem, NULL,
+ &call, sap_connect_reply, modem, NULL,
DBUS_TIMEOUT, DBUS_TYPE_STRING,
&str, DBUS_TYPE_INVALID);
if (status < 0)
return -EINVAL;
+ data->call = call;
+
return -EINPROGRESS;
}
--
1.7.6.2
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH -v4 19/21] sap: remove server_path
2011-09-27 21:04 ` [PATCH -v4 18/21] sap: de-register DBus callback if BlueZ goes down Gustavo F. Padovan
@ 2011-09-27 21:04 ` Gustavo F. Padovan
2011-09-27 21:04 ` [PATCH -v4 20/21] sap: clean up sap modem destruction Gustavo F. Padovan
0 siblings, 1 reply; 24+ messages in thread
From: Gustavo F. Padovan @ 2011-09-27 21:04 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 2974 bytes --]
From: "Gustavo F. Padovan" <gustavo@padovan.org>
We use ofono_modem_set_string() instead to store it.
This also remove the need to have sap_data allocation on
bluetooth_sap_probe().
---
plugins/sap.c | 38 +++++++++++++++-----------------------
1 files changed, 15 insertions(+), 23 deletions(-)
diff --git a/plugins/sap.c b/plugins/sap.c
index 9b8e670..ce5886d 100644
--- a/plugins/sap.c
+++ b/plugins/sap.c
@@ -53,7 +53,6 @@ static struct ofono_modem *sap_hw_modem = NULL;
static struct bluetooth_sap_driver *sap_hw_driver = NULL;
struct sap_data {
- char *server_path;
struct ofono_modem *hw_modem;
struct bluetooth_sap_driver *sap_driver;
GIOChannel *bt_io;
@@ -110,7 +109,6 @@ static void sap_remove_modem(struct ofono_modem *modem)
if (data->call != NULL)
dbus_pending_call_cancel(data->call);
- g_free(data->server_path);
g_free(data);
ofono_modem_set_data(modem, NULL);
@@ -213,8 +211,16 @@ static gboolean hw_event_cb(GIOChannel *hw_io, GIOCondition condition,
static int sap_probe(struct ofono_modem *modem)
{
+ struct sap_data *data;
+
DBG("%p", modem);
+ data = g_try_new0(struct sap_data, 1);
+ if (data == NULL)
+ return -ENOMEM;
+
+ ofono_modem_set_data(modem, data);
+
return 0;
}
@@ -309,14 +315,15 @@ static int sap_enable(struct ofono_modem *modem)
DBusPendingCall *call;
int status;
const char *str = "sap";
+ const char *server_path = ofono_modem_get_string(modem, "ServerPath");
DBG("%p", modem);
- status = bluetooth_send_with_reply(data->server_path,
- BLUEZ_SERIAL_INTERFACE, "ConnectFD",
- &call, sap_connect_reply, modem, NULL,
- DBUS_TIMEOUT, DBUS_TYPE_STRING,
- &str, DBUS_TYPE_INVALID);
+ status = bluetooth_send_with_reply(server_path, BLUEZ_SERIAL_INTERFACE,
+ "ConnectFD", &call, sap_connect_reply,
+ modem, NULL, DBUS_TIMEOUT,
+ DBUS_TYPE_STRING, &str,
+ DBUS_TYPE_INVALID);
if (status < 0)
return -EINVAL;
@@ -380,7 +387,6 @@ static int bluetooth_sap_probe(const char *device, const char *dev_addr,
const char *adapter_addr, const char *alias)
{
struct ofono_modem *modem;
- struct sap_data *data;
char buf[256];
if (sap_hw_modem == NULL)
@@ -401,27 +407,13 @@ static int bluetooth_sap_probe(const char *device, const char *dev_addr,
if (modem == NULL)
return -ENOMEM;
- data = g_try_new0(struct sap_data, 1);
- if (data == NULL)
- goto free;
-
- data->server_path = g_strdup(device);
- if (data->server_path == NULL)
- goto free;
-
- ofono_modem_set_data(modem, data);
+ ofono_modem_set_string(modem, "ServerPath", device);
ofono_modem_set_name(modem, alias);
ofono_modem_register(modem);
g_hash_table_insert(modem_hash, g_strdup(device), modem);
return 0;
-
-free:
- g_free(data);
- ofono_modem_remove(modem);
-
- return -ENOMEM;
}
static void bluetooth_sap_remove(const char *prefix)
--
1.7.6.2
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH -v4 20/21] sap: clean up sap modem destruction
2011-09-27 21:04 ` [PATCH -v4 19/21] sap: remove server_path Gustavo F. Padovan
@ 2011-09-27 21:04 ` Gustavo F. Padovan
2011-09-27 21:04 ` [PATCH -v4 21/21] sap: fix sap modem remove Gustavo F. Padovan
0 siblings, 1 reply; 24+ messages in thread
From: Gustavo F. Padovan @ 2011-09-27 21:04 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 1744 bytes --]
From: "Gustavo F. Padovan" <gustavo@padovan.org>
---
plugins/sap.c | 33 +++++++++++++++------------------
1 files changed, 15 insertions(+), 18 deletions(-)
diff --git a/plugins/sap.c b/plugins/sap.c
index ce5886d..b128517 100644
--- a/plugins/sap.c
+++ b/plugins/sap.c
@@ -100,22 +100,6 @@ static void sap_close_io(struct ofono_modem *modem)
g_source_remove(data->hw_watch);
}
-static void sap_remove_modem(struct ofono_modem *modem)
-{
- struct sap_data *data = ofono_modem_get_data(modem);
-
- sap_close_io(modem);
-
- if (data->call != NULL)
- dbus_pending_call_cancel(data->call);
-
- g_free(data);
-
- ofono_modem_set_data(modem, NULL);
-
- ofono_modem_remove(modem);
-}
-
void bluetooth_sap_client_unregister(struct ofono_modem *modem)
{
GHashTableIter iter;
@@ -128,7 +112,8 @@ void bluetooth_sap_client_unregister(struct ofono_modem *modem)
while (g_hash_table_iter_next(&iter, &key, &value)) {
g_hash_table_iter_remove(&iter);
- sap_remove_modem(value);
+
+ ofono_modem_remove(modem);
}
sap_hw_modem = NULL;
@@ -226,7 +211,18 @@ static int sap_probe(struct ofono_modem *modem)
static void sap_remove(struct ofono_modem *modem)
{
+ struct sap_data *data = ofono_modem_get_data(modem);
+
DBG("%p", modem);
+
+ sap_close_io(modem);
+
+ if (data->call != NULL)
+ dbus_pending_call_cancel(data->call);
+
+ g_free(data);
+
+ ofono_modem_set_data(modem, NULL);
}
static void sap_failed_cb(struct ofono_modem *modem)
@@ -433,7 +429,8 @@ static void bluetooth_sap_remove(const char *prefix)
continue;
g_hash_table_iter_remove(&iter);
- sap_remove_modem(value);
+
+ ofono_modem_remove(value);
}
}
--
1.7.6.2
^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH -v4 21/21] sap: fix sap modem remove
2011-09-27 21:04 ` [PATCH -v4 20/21] sap: clean up sap modem destruction Gustavo F. Padovan
@ 2011-09-27 21:04 ` Gustavo F. Padovan
2011-09-28 4:45 ` Denis Kenzior
0 siblings, 1 reply; 24+ messages in thread
From: Gustavo F. Padovan @ 2011-09-27 21:04 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 799 bytes --]
From: "Gustavo F. Padovan" <gustavo@padovan.org>
prefix NULL means that the modem needs to be removed
---
plugins/sap.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/plugins/sap.c b/plugins/sap.c
index b128517..6a140b3 100644
--- a/plugins/sap.c
+++ b/plugins/sap.c
@@ -419,13 +419,13 @@ static void bluetooth_sap_remove(const char *prefix)
DBG("%s", prefix);
- if (modem_hash == NULL || prefix == NULL)
+ if (modem_hash == NULL)
return;
g_hash_table_iter_init(&iter, modem_hash);
while (g_hash_table_iter_next(&iter, &key, &value)) {
- if (g_str_has_prefix((char *)key, prefix) == FALSE)
+ if (prefix && g_str_has_prefix((char *)key, prefix) == FALSE)
continue;
g_hash_table_iter_remove(&iter);
--
1.7.6.2
^ permalink raw reply related [flat|nested] 24+ messages in thread
* Re: [PATCH -v4 04/21] telit: add telit_sap_disable()
2011-09-27 21:04 ` [PATCH -v4 04/21] telit: add telit_sap_disable() Gustavo F. Padovan
2011-09-27 21:04 ` [PATCH -v4 05/21] sap: add support to the disable the SAP client Gustavo F. Padovan
@ 2011-09-28 4:34 ` Denis Kenzior
1 sibling, 0 replies; 24+ messages in thread
From: Denis Kenzior @ 2011-09-28 4:34 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 2172 bytes --]
Hi Gustavo,
On 09/27/2011 04:04 PM, Gustavo F. Padovan wrote:
> From: "Gustavo F. Padovan" <padovan@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 6cde7bc..96e3215 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);
> };
>
> struct server;
> diff --git a/plugins/telit.c b/plugins/telit.c
> index a5f9941..b9a5b23 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()
> {
> const char *device = "/dev/ttyUSB4";
> @@ -191,9 +205,25 @@ static int telit_sap_enable(struct ofono_modem *modem)
> return fd;
> }
>
> +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;
Do you mean to return -EINPROGRESS here?
> +}
> +
> 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)
Regards,
-Denis
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH -v4 16/21] sap: retrigger bluetooth GetProperties call
2011-09-27 21:04 ` [PATCH -v4 16/21] sap: retrigger bluetooth GetProperties call Gustavo F. Padovan
2011-09-27 21:04 ` [PATCH -v4 17/21] telit: add needed flags to proper connect the serial port Gustavo F. Padovan
@ 2011-09-28 4:37 ` Denis Kenzior
1 sibling, 0 replies; 24+ messages in thread
From: Denis Kenzior @ 2011-09-28 4:37 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 472 bytes --]
Hi Gustavo,
On 09/27/2011 04:04 PM, Gustavo F. Padovan wrote:
> From: "Gustavo F. Padovan" <padovan@profusion.mobi>
>
> When plugging a SAP capable modem, GetProperties need to be called again
> to fetch the SAP Server devices from BlueZ.
> ---
> plugins/bluetooth.c | 6 ++++++
> plugins/bluetooth.h | 1 +
> plugins/sap.c | 2 ++
> 3 files changed, 9 insertions(+), 0 deletions(-)
>
Patch has been applied, thanks.
Regards,
-Denis
^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH -v4 21/21] sap: fix sap modem remove
2011-09-27 21:04 ` [PATCH -v4 21/21] sap: fix sap modem remove Gustavo F. Padovan
@ 2011-09-28 4:45 ` Denis Kenzior
0 siblings, 0 replies; 24+ messages in thread
From: Denis Kenzior @ 2011-09-28 4:45 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 327 bytes --]
Hi Gustavo,
On 09/27/2011 04:04 PM, Gustavo F. Padovan wrote:
> From: "Gustavo F. Padovan" <gustavo@padovan.org>
>
> prefix NULL means that the modem needs to be removed
> ---
> plugins/sap.c | 4 ++--
> 1 files changed, 2 insertions(+), 2 deletions(-)
>
Patch has been applied, thanks.
Regards,
-Denis
^ permalink raw reply [flat|nested] 24+ messages in thread
end of thread, other threads:[~2011-09-28 4:45 UTC | newest]
Thread overview: 24+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-09-27 21:04 [PATCH -v4 01/21] udevng: look also to VID Gustavo F. Padovan
2011-09-27 21:04 ` [PATCH -v4 02/21] sap: add watch for the Bluetooth Link Gustavo F. Padovan
2011-09-27 21:04 ` [PATCH -v4 03/21] sap: add support to enable SAP Gustavo F. Padovan
2011-09-27 21:04 ` [PATCH -v4 04/21] telit: add telit_sap_disable() Gustavo F. Padovan
2011-09-27 21:04 ` [PATCH -v4 05/21] sap: add support to the disable the SAP client Gustavo F. Padovan
2011-09-27 21:04 ` [PATCH -v4 06/21] telit: add aux GAtChat Gustavo F. Padovan
2011-09-27 21:04 ` [PATCH -v4 07/21] sap: enable modem only when #RSEN is 1 Gustavo F. Padovan
2011-09-27 21:04 ` [PATCH -v4 08/21] telit: enable the telit modem when SAP is enabled Gustavo F. Padovan
2011-09-27 21:04 ` [PATCH -v4 09/21] sap: add pre_sim handling Gustavo F. Padovan
2011-09-27 21:04 ` [PATCH -v4 10/21] sap: add set_online handling Gustavo F. Padovan
2011-09-27 21:04 ` [PATCH -v4 11/21] sap: add post_sim handling Gustavo F. Padovan
2011-09-27 21:04 ` [PATCH -v4 12/21] sap: add post_online handling Gustavo F. Padovan
2011-09-27 21:04 ` [PATCH -v4 13/21] telit: improve sap disable Gustavo F. Padovan
2011-09-27 21:04 ` [PATCH -v4 14/21] sap: disconnect link if enable() fails Gustavo F. Padovan
2011-09-27 21:04 ` [PATCH -v4 15/21] sap: do a proper shutdown of the channels Gustavo F. Padovan
2011-09-27 21:04 ` [PATCH -v4 16/21] sap: retrigger bluetooth GetProperties call Gustavo F. Padovan
2011-09-27 21:04 ` [PATCH -v4 17/21] telit: add needed flags to proper connect the serial port Gustavo F. Padovan
2011-09-27 21:04 ` [PATCH -v4 18/21] sap: de-register DBus callback if BlueZ goes down Gustavo F. Padovan
2011-09-27 21:04 ` [PATCH -v4 19/21] sap: remove server_path Gustavo F. Padovan
2011-09-27 21:04 ` [PATCH -v4 20/21] sap: clean up sap modem destruction Gustavo F. Padovan
2011-09-27 21:04 ` [PATCH -v4 21/21] sap: fix sap modem remove Gustavo F. Padovan
2011-09-28 4:45 ` Denis Kenzior
2011-09-28 4:37 ` [PATCH -v4 16/21] sap: retrigger bluetooth GetProperties call Denis Kenzior
2011-09-28 4:34 ` [PATCH -v4 04/21] telit: add telit_sap_disable() Denis Kenzior
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.