* [PATCH -v5 01/13] udevng: look also to VID @ 2011-09-28 21:24 Gustavo F. Padovan 2011-09-28 21:24 ` [PATCH -v5 02/13] sap: remove connect callback if enable fails Gustavo F. Padovan 0 siblings, 1 reply; 24+ messages in thread From: Gustavo F. Padovan @ 2011-09-28 21:24 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 -v5 02/13] sap: remove connect callback if enable fails 2011-09-28 21:24 [PATCH -v5 01/13] udevng: look also to VID Gustavo F. Padovan @ 2011-09-28 21:24 ` Gustavo F. Padovan 2011-09-28 21:24 ` [PATCH -v5 03/13] telit: add support the enable the SAP client modem Gustavo F. Padovan 2011-09-29 15:50 ` [PATCH -v5 02/13] sap: remove connect callback if enable fails Denis Kenzior 0 siblings, 2 replies; 24+ messages in thread From: Gustavo F. Padovan @ 2011-09-28 21:24 UTC (permalink / raw) To: ofono [-- Attachment #1: Type: text/plain, Size: 2140 bytes --] From: "Gustavo F. Padovan" <padovan@profusion.mobi> --- plugins/sap.c | 13 ++++++++++++- 1 files changed, 12 insertions(+), 1 deletions(-) diff --git a/plugins/sap.c b/plugins/sap.c index 1c0d9ce..28b07e7 100644 --- a/plugins/sap.c +++ b/plugins/sap.c @@ -54,6 +54,7 @@ static struct bluetooth_sap_driver *sap_hw_driver = NULL; struct sap_data { struct ofono_modem *hw_modem; struct bluetooth_sap_driver *sap_driver; + DBusPendingCall *call; }; int bluetooth_sap_client_register(struct bluetooth_sap_driver *sap, @@ -112,6 +113,9 @@ static void sap_remove(struct ofono_modem *modem) DBG("%p", modem); + if (data->call != NULL) + dbus_pending_call_cancel(data->call); + g_free(data); ofono_modem_set_data(modem, NULL); @@ -120,6 +124,7 @@ 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; @@ -127,6 +132,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; @@ -147,6 +154,8 @@ done: /* power up hardware */ 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"; const char *server_path = ofono_modem_get_string(modem, "ServerPath"); @@ -154,7 +163,7 @@ static int sap_enable(struct ofono_modem *modem) DBG("%p", modem); status = bluetooth_send_with_reply(server_path, BLUEZ_SERIAL_INTERFACE, - "ConnectFD", NULL, sap_connect_reply, + "ConnectFD", &call, sap_connect_reply, modem, NULL, DBUS_TIMEOUT, DBUS_TYPE_STRING, &str, DBUS_TYPE_INVALID); @@ -162,6 +171,8 @@ static int sap_enable(struct ofono_modem *modem) 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 -v5 03/13] telit: add support the enable the SAP client modem 2011-09-28 21:24 ` [PATCH -v5 02/13] sap: remove connect callback if enable fails Gustavo F. Padovan @ 2011-09-28 21:24 ` Gustavo F. Padovan 2011-09-28 21:24 ` [PATCH -v5 04/13] sap: enable SAP modem, when BlueZ replies Gustavo F. Padovan 2011-09-29 15:53 ` [PATCH -v5 03/13] telit: add support the enable the SAP client modem Denis Kenzior 2011-09-29 15:50 ` [PATCH -v5 02/13] sap: remove connect callback if enable fails Denis Kenzior 1 sibling, 2 replies; 24+ messages in thread From: Gustavo F. Padovan @ 2011-09-28 21:24 UTC (permalink / raw) To: ofono [-- Attachment #1: Type: text/plain, Size: 6781 bytes --] From: "Gustavo F. Padovan" <padovan@profusion.mobi> --- plugins/bluetooth.h | 3 +- plugins/telit.c | 191 ++++++++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 184 insertions(+), 10 deletions(-) diff --git a/plugins/bluetooth.h b/plugins/bluetooth.h index 936659c..7e94f96 100644 --- a/plugins/bluetooth.h +++ b/plugins/bluetooth.h @@ -45,7 +45,8 @@ 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 bt_fd); }; struct server; diff --git a/plugins/telit.c b/plugins/telit.c index 1f950aa..2e422e7 100644 --- a/plugins/telit.c +++ b/plugins/telit.c @@ -27,6 +27,10 @@ #include <stdlib.h> #include <stdio.h> #include <unistd.h> +#include <fcntl.h> +#include <termios.h> +#include <string.h> +#include <sys/socket.h> #include <glib.h> #include <gatchat.h> @@ -62,8 +66,14 @@ static const char *rsen_prefix[]= { "#RSEN:", NULL }; struct telit_data { GAtChat *chat; + GAtChat *aux; struct ofono_sim *sim; guint sim_inserted_source; + struct ofono_modem *sap_modem; + GIOChannel *bt_io; + GIOChannel *hw_io; + guint bt_watch; + guint hw_watch; }; static void telit_debug(const char *str, void *user_data) @@ -73,6 +83,104 @@ static void telit_debug(const char *str, void *user_data) ofono_info("%s%s", prefix, str); } +static void sap_close_io(struct ofono_modem *modem) +{ + struct telit_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 bt_watch_remove(gpointer userdata) +{ + struct ofono_modem *modem = userdata; + struct telit_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 userdata) +{ + struct ofono_modem *modem = userdata; + struct telit_data *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(bt_io, buf, 300, + &bytes_read, NULL); + + if (bytes_read > 0) + g_io_channel_write_chars(data->hw_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 telit_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 userdata) +{ + struct ofono_modem *modem = userdata; + struct telit_data *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(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 GAtChat *open_device(struct ofono_modem *modem, const char *key, char *debug) { @@ -129,31 +237,96 @@ 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; - ofono_modem_set_powered(modem, FALSE); + g_at_chat_unref(data->aux); + data->aux = NULL; + ofono_modem_set_powered(data->sap_modem, FALSE); + sap_close_io(modem); 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); + + ti.c_cflag |= (B115200 | CLOCAL | CREAD); + + tcflush(fd, TCIOFLUSH); + if (tcsetattr(fd, TCSANOW, &ti) < 0) { + close(fd); + return -EBADF; + } + + 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, + int bt_fd) { struct telit_data *data = ofono_modem_get_data(modem); + int fd; 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; - g_at_chat_register(data->chat, "#RSEN:", telit_rsen_notify, + fd = telit_sap_open(); + if (fd < 0) + return fd; + + data->hw_io = g_io_channel_unix_new(fd); + if (data->hw_io == NULL) { + close(fd); + return -ENOMEM; + } + + 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); + + data->bt_io = g_io_channel_unix_new(bt_fd); + if (data->bt_io == NULL) { + sap_close_io(modem); + return -ENOMEM; + } + + 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); + + 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); + + + data->sap_modem = sap_modem; + + 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=0", 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 -EINPROGRESS; -- 1.7.6.2 ^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH -v5 04/13] sap: enable SAP modem, when BlueZ replies 2011-09-28 21:24 ` [PATCH -v5 03/13] telit: add support the enable the SAP client modem Gustavo F. Padovan @ 2011-09-28 21:24 ` Gustavo F. Padovan 2011-09-28 21:24 ` [PATCH -v5 05/13] telit: add suport the disable SAP client Gustavo F. Padovan 2011-09-29 15:54 ` [PATCH -v5 04/13] sap: enable SAP modem, when BlueZ replies Denis Kenzior 2011-09-29 15:53 ` [PATCH -v5 03/13] telit: add support the enable the SAP client modem Denis Kenzior 1 sibling, 2 replies; 24+ messages in thread From: Gustavo F. Padovan @ 2011-09-28 21:24 UTC (permalink / raw) To: ofono [-- Attachment #1: Type: text/plain, Size: 1391 bytes --] From: "Gustavo F. Padovan" <padovan@profusion.mobi> --- plugins/sap.c | 22 ++++++++++++++++++---- 1 files changed, 18 insertions(+), 4 deletions(-) diff --git a/plugins/sap.c b/plugins/sap.c index 28b07e7..850ed2f 100644 --- a/plugins/sap.c +++ b/plugins/sap.c @@ -127,6 +127,7 @@ static void sap_connect_reply(DBusPendingCall *call, gpointer user_data) struct sap_data *data = ofono_modem_get_data(modem); DBusError derr; DBusMessage *reply; + int fd, err; DBG(""); @@ -138,16 +139,29 @@ 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); + + dbus_error_free(&derr); goto done; + } - DBG("Connect reply: %s", derr.message); + if (!dbus_message_get_args(reply, NULL, DBUS_TYPE_UNIX_FD, &fd, + DBUS_TYPE_INVALID)) + goto done; - ofono_modem_set_powered(modem, FALSE); + data->hw_modem = sap_hw_modem; + data->sap_driver = sap_hw_driver; - dbus_error_free(&derr); + err = data->sap_driver->enable(data->hw_modem, modem, fd); + if (err == -EINPROGRESS) { + dbus_message_unref(reply); + return; + } done: + ofono_modem_set_powered(modem, FALSE); dbus_message_unref(reply); } -- 1.7.6.2 ^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH -v5 05/13] telit: add suport the disable SAP client 2011-09-28 21:24 ` [PATCH -v5 04/13] sap: enable SAP modem, when BlueZ replies Gustavo F. Padovan @ 2011-09-28 21:24 ` Gustavo F. Padovan 2011-09-28 21:24 ` [PATCH -v5 06/13] sap: add sap modem disable() support Gustavo F. Padovan 2011-09-29 16:15 ` [PATCH -v5 05/13] telit: add suport the disable " Denis Kenzior 2011-09-29 15:54 ` [PATCH -v5 04/13] sap: enable SAP modem, when BlueZ replies Denis Kenzior 1 sibling, 2 replies; 24+ messages in thread From: Gustavo F. Padovan @ 2011-09-28 21:24 UTC (permalink / raw) To: ofono [-- Attachment #1: Type: text/plain, Size: 4072 bytes --] From: "Gustavo F. Padovan" <padovan@profusion.mobi> --- plugins/bluetooth.h | 1 + plugins/telit.c | 100 ++++++++++++++++++++++++++++++++++---------------- 2 files changed, 69 insertions(+), 32 deletions(-) diff --git a/plugins/bluetooth.h b/plugins/bluetooth.h index 7e94f96..d38e72e 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 2e422e7..f39a7c4 100644 --- a/plugins/telit.c +++ b/plugins/telit.c @@ -245,6 +245,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"; @@ -332,9 +384,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->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) @@ -476,23 +544,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); @@ -517,21 +568,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; -- 1.7.6.2 ^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH -v5 06/13] sap: add sap modem disable() support 2011-09-28 21:24 ` [PATCH -v5 05/13] telit: add suport the disable SAP client Gustavo F. Padovan @ 2011-09-28 21:24 ` Gustavo F. Padovan 2011-09-28 21:24 ` [PATCH -v5 07/13] telit: enable the telit modem after enable SAP client Gustavo F. Padovan 2011-09-29 16:15 ` [PATCH -v5 05/13] telit: add suport the disable " Denis Kenzior 1 sibling, 1 reply; 24+ messages in thread From: Gustavo F. Padovan @ 2011-09-28 21:24 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 850ed2f..7bb776a 100644 --- a/plugins/sap.c +++ b/plugins/sap.c @@ -192,8 +192,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 -v5 07/13] telit: enable the telit modem after enable SAP client 2011-09-28 21:24 ` [PATCH -v5 06/13] sap: add sap modem disable() support Gustavo F. Padovan @ 2011-09-28 21:24 ` Gustavo F. Padovan 2011-09-28 21:24 ` [PATCH -v5 08/13] telit: add pre_sim support to SAP Client Gustavo F. Padovan 2011-09-29 16:19 ` [PATCH -v5 07/13] telit: enable the telit modem after enable SAP client Denis Kenzior 0 siblings, 2 replies; 24+ messages in thread From: Gustavo F. Padovan @ 2011-09-28 21:24 UTC (permalink / raw) To: ofono [-- Attachment #1: Type: text/plain, Size: 7512 bytes --] From: "Gustavo F. Padovan" <padovan@profusion.mobi> --- plugins/telit.c | 271 +++++++++++++++++++++++++++++-------------------------- 1 files changed, 141 insertions(+), 130 deletions(-) diff --git a/plugins/telit.c b/plugins/telit.c index f39a7c4..f15a787 100644 --- a/plugins/telit.c +++ b/plugins/telit.c @@ -213,9 +213,142 @@ 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); + sap_close_io(modem); + 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; + struct telit_data *data = ofono_modem_get_data(modem); int status; GAtResultIter iter; @@ -227,6 +360,14 @@ 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); + sap_close_io(modem); + return; + } + + telit_enable(modem); } static void rsen_enable_cb(gboolean ok, GAtResult *result, gpointer user_data) @@ -438,136 +579,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 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 set_online_cb(gboolean ok, GAtResult *result, gpointer user_data) { struct cb_data *cbd = user_data; -- 1.7.6.2 ^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH -v5 08/13] telit: add pre_sim support to SAP Client 2011-09-28 21:24 ` [PATCH -v5 07/13] telit: enable the telit modem after enable SAP client Gustavo F. Padovan @ 2011-09-28 21:24 ` Gustavo F. Padovan 2011-09-28 21:24 ` [PATCH -v5 09/13] telit: add post_sim " Gustavo F. Padovan 2011-09-29 16:20 ` [PATCH -v5 08/13] telit: add pre_sim support " Denis Kenzior 2011-09-29 16:19 ` [PATCH -v5 07/13] telit: enable the telit modem after enable SAP client Denis Kenzior 1 sibling, 2 replies; 24+ messages in thread From: Gustavo F. Padovan @ 2011-09-28 21:24 UTC (permalink / raw) To: ofono [-- Attachment #1: Type: text/plain, Size: 2009 bytes --] From: "Gustavo F. Padovan" <padovan@profusion.mobi> --- plugins/bluetooth.h | 1 + plugins/telit.c | 26 +++++++++++++++----------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/plugins/bluetooth.h b/plugins/bluetooth.h index d38e72e..8e3fadd 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); + void (*pre_sim) (struct ofono_modem *modem); int (*disable) (struct ofono_modem *modem); }; diff --git a/plugins/telit.c b/plugins/telit.c index f15a787..0d93a89 100644 --- a/plugins/telit.c +++ b/plugins/telit.c @@ -540,9 +540,24 @@ static int telit_sap_disable(struct ofono_modem *modem) return -EINPROGRESS; } +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, }; @@ -602,17 +617,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 -v5 09/13] telit: add post_sim to SAP Client 2011-09-28 21:24 ` [PATCH -v5 08/13] telit: add pre_sim support to SAP Client Gustavo F. Padovan @ 2011-09-28 21:24 ` Gustavo F. Padovan 2011-09-28 21:24 ` [PATCH -v5 10/13] telit: add set_online " Gustavo F. Padovan 2011-09-29 16:20 ` [PATCH -v5 09/13] telit: add post_sim " Denis Kenzior 2011-09-29 16:20 ` [PATCH -v5 08/13] telit: add pre_sim support " Denis Kenzior 1 sibling, 2 replies; 24+ messages in thread From: Gustavo F. Padovan @ 2011-09-28 21:24 UTC (permalink / raw) To: ofono [-- Attachment #1: Type: text/plain, Size: 1842 bytes --] From: "Gustavo F. Padovan" <padovan@profusion.mobi> --- plugins/bluetooth.h | 1 + plugins/telit.c | 22 +++++++++++++--------- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/plugins/bluetooth.h b/plugins/bluetooth.h index 8e3fadd..a9d3683 100644 --- a/plugins/bluetooth.h +++ b/plugins/bluetooth.h @@ -48,6 +48,7 @@ struct bluetooth_sap_driver { int (*enable) (struct ofono_modem *modem, struct ofono_modem *sap_modem, int bt_fd); void (*pre_sim) (struct ofono_modem *modem); + void (*post_sim) (struct ofono_modem *modem); int (*disable) (struct ofono_modem *modem); }; diff --git a/plugins/telit.c b/plugins/telit.c index 0d93a89..8fe421f 100644 --- a/plugins/telit.c +++ b/plugins/telit.c @@ -554,10 +554,23 @@ 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 struct bluetooth_sap_driver sap_driver = { .name = "telit", .enable = telit_sap_enable, .pre_sim = telit_pre_sim, + .post_sim = telit_post_sim, .disable = telit_sap_disable, }; @@ -617,15 +630,6 @@ static void telit_set_online(struct ofono_modem *modem, ofono_bool_t online, 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 -v5 10/13] telit: add set_online to SAP Client 2011-09-28 21:24 ` [PATCH -v5 09/13] telit: add post_sim " Gustavo F. Padovan @ 2011-09-28 21:24 ` Gustavo F. Padovan 2011-09-28 21:24 ` [PATCH -v5 11/13] telit: add post_online " Gustavo F. Padovan 2011-09-29 16:20 ` [PATCH -v5 10/13] telit: add set_online " Denis Kenzior 2011-09-29 16:20 ` [PATCH -v5 09/13] telit: add post_sim " Denis Kenzior 1 sibling, 2 replies; 24+ messages in thread From: Gustavo F. Padovan @ 2011-09-28 21:24 UTC (permalink / raw) To: ofono [-- Attachment #1: Type: text/plain, Size: 2966 bytes --] From: "Gustavo F. Padovan" <padovan@profusion.mobi> --- 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 a9d3683..89733a1 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 8fe421f..dc6850f 100644 --- a/plugins/telit.c +++ b/plugins/telit.c @@ -566,11 +566,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, }; @@ -607,29 +631,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); -- 1.7.6.2 ^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH -v5 11/13] telit: add post_online to SAP Client 2011-09-28 21:24 ` [PATCH -v5 10/13] telit: add set_online " Gustavo F. Padovan @ 2011-09-28 21:24 ` Gustavo F. Padovan 2011-09-28 21:24 ` [PATCH -v5 12/13] sap: add full support to SAP modem Gustavo F. Padovan 2011-09-29 16:21 ` [PATCH -v5 11/13] telit: add post_online to SAP Client Denis Kenzior 2011-09-29 16:20 ` [PATCH -v5 10/13] telit: add set_online " Denis Kenzior 1 sibling, 2 replies; 24+ messages in thread From: Gustavo F. Padovan @ 2011-09-28 21:24 UTC (permalink / raw) To: ofono [-- Attachment #1: Type: text/plain, Size: 3351 bytes --] From: "Gustavo F. Padovan" <padovan@profusion.mobi> --- plugins/bluetooth.h | 1 + plugins/telit.c | 58 +++++++++++++++++++++++++++----------------------- 2 files changed, 32 insertions(+), 27 deletions(-) diff --git a/plugins/bluetooth.h b/plugins/bluetooth.h index 89733a1..ad78921 100644 --- a/plugins/bluetooth.h +++ b/plugins/bluetooth.h @@ -51,6 +51,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/telit.c b/plugins/telit.c index dc6850f..8a2f6af 100644 --- a/plugins/telit.c +++ b/plugins/telit.c @@ -589,12 +589,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, }; @@ -631,33 +662,6 @@ static void telit_remove(struct ofono_modem *modem) g_free(data); } -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 -v5 12/13] sap: add full support to SAP modem 2011-09-28 21:24 ` [PATCH -v5 11/13] telit: add post_online " Gustavo F. Padovan @ 2011-09-28 21:24 ` Gustavo F. Padovan 2011-09-28 21:24 ` [PATCH -v5 13/13] sap: clean up extra blank line Gustavo F. Padovan 2011-09-29 16:22 ` [PATCH -v5 12/13] sap: add full support to SAP modem Denis Kenzior 2011-09-29 16:21 ` [PATCH -v5 11/13] telit: add post_online to SAP Client Denis Kenzior 1 sibling, 2 replies; 24+ messages in thread From: Gustavo F. Padovan @ 2011-09-28 21:24 UTC (permalink / raw) To: ofono [-- Attachment #1: Type: text/plain, Size: 1661 bytes --] From: "Gustavo F. Padovan" <padovan@profusion.mobi> Add pre_sim, post_sim, set_online and post_online calls --- plugins/sap.c | 29 +++++++++++++++++++++++++++++ 1 files changed, 29 insertions(+), 0 deletions(-) diff --git a/plugins/sap.c b/plugins/sap.c index 7bb776a..1f760be 100644 --- a/plugins/sap.c +++ b/plugins/sap.c @@ -203,12 +203,39 @@ 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) { + 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, + 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 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, @@ -288,6 +315,8 @@ 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, + .post_online = sap_post_online, }; static struct bluetooth_profile sap = { -- 1.7.6.2 ^ permalink raw reply related [flat|nested] 24+ messages in thread
* [PATCH -v5 13/13] sap: clean up extra blank line 2011-09-28 21:24 ` [PATCH -v5 12/13] sap: add full support to SAP modem Gustavo F. Padovan @ 2011-09-28 21:24 ` Gustavo F. Padovan 2011-09-29 16:22 ` Denis Kenzior 2011-09-29 16:22 ` [PATCH -v5 12/13] sap: add full support to SAP modem Denis Kenzior 1 sibling, 1 reply; 24+ messages in thread From: Gustavo F. Padovan @ 2011-09-28 21:24 UTC (permalink / raw) To: ofono [-- Attachment #1: Type: text/plain, Size: 475 bytes --] From: "Gustavo F. Padovan" <padovan@profusion.mobi> --- plugins/sap.c | 1 - 1 files changed, 0 insertions(+), 1 deletions(-) diff --git a/plugins/sap.c b/plugins/sap.c index 1f760be..bad995d 100644 --- a/plugins/sap.c +++ b/plugins/sap.c @@ -71,7 +71,6 @@ int bluetooth_sap_client_register(struct bluetooth_sap_driver *sap, return 0; } - void bluetooth_sap_client_unregister(struct ofono_modem *modem) { GHashTableIter iter; -- 1.7.6.2 ^ permalink raw reply related [flat|nested] 24+ messages in thread
* Re: [PATCH -v5 13/13] sap: clean up extra blank line 2011-09-28 21:24 ` [PATCH -v5 13/13] sap: clean up extra blank line Gustavo F. Padovan @ 2011-09-29 16:22 ` Denis Kenzior 0 siblings, 0 replies; 24+ messages in thread From: Denis Kenzior @ 2011-09-29 16:22 UTC (permalink / raw) To: ofono [-- Attachment #1: Type: text/plain, Size: 271 bytes --] Hi Gustavo, On 09/28/2011 04:24 PM, Gustavo F. Padovan wrote: > From: "Gustavo F. Padovan" <padovan@profusion.mobi> > > --- > plugins/sap.c | 1 - > 1 files changed, 0 insertions(+), 1 deletions(-) > Patch has been applied, thanks. Regards, -Denis ^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH -v5 12/13] sap: add full support to SAP modem 2011-09-28 21:24 ` [PATCH -v5 12/13] sap: add full support to SAP modem Gustavo F. Padovan 2011-09-28 21:24 ` [PATCH -v5 13/13] sap: clean up extra blank line Gustavo F. Padovan @ 2011-09-29 16:22 ` Denis Kenzior 1 sibling, 0 replies; 24+ messages in thread From: Denis Kenzior @ 2011-09-29 16:22 UTC (permalink / raw) To: ofono [-- Attachment #1: Type: text/plain, Size: 355 bytes --] Hi Gustavo, On 09/28/2011 04:24 PM, Gustavo F. Padovan wrote: > From: "Gustavo F. Padovan" <padovan@profusion.mobi> > > Add pre_sim, post_sim, set_online and post_online calls > --- > plugins/sap.c | 29 +++++++++++++++++++++++++++++ > 1 files changed, 29 insertions(+), 0 deletions(-) Patch has been applied, thanks. Regards, -Denis ^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH -v5 11/13] telit: add post_online to SAP Client 2011-09-28 21:24 ` [PATCH -v5 11/13] telit: add post_online " Gustavo F. Padovan 2011-09-28 21:24 ` [PATCH -v5 12/13] sap: add full support to SAP modem Gustavo F. Padovan @ 2011-09-29 16:21 ` Denis Kenzior 1 sibling, 0 replies; 24+ messages in thread From: Denis Kenzior @ 2011-09-29 16:21 UTC (permalink / raw) To: ofono [-- Attachment #1: Type: text/plain, Size: 357 bytes --] Hi Gustavo, On 09/28/2011 04:24 PM, Gustavo F. Padovan wrote: > From: "Gustavo F. Padovan" <padovan@profusion.mobi> > > --- > plugins/bluetooth.h | 1 + > plugins/telit.c | 58 +++++++++++++++++++++++++++----------------------- > 2 files changed, 32 insertions(+), 27 deletions(-) Patch has been applied, thanks. Regards, -Denis ^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH -v5 10/13] telit: add set_online to SAP Client 2011-09-28 21:24 ` [PATCH -v5 10/13] telit: add set_online " Gustavo F. Padovan 2011-09-28 21:24 ` [PATCH -v5 11/13] telit: add post_online " Gustavo F. Padovan @ 2011-09-29 16:20 ` Denis Kenzior 1 sibling, 0 replies; 24+ messages in thread From: Denis Kenzior @ 2011-09-29 16:20 UTC (permalink / raw) To: ofono [-- Attachment #1: Type: text/plain, Size: 359 bytes --] Hi Gustavo, On 09/28/2011 04:24 PM, Gustavo F. Padovan wrote: > From: "Gustavo F. Padovan" <padovan@profusion.mobi> > > --- > plugins/bluetooth.h | 2 ++ > plugins/telit.c | 47 ++++++++++++++++++++++++----------------------- > 2 files changed, 26 insertions(+), 23 deletions(-) > Patch has been applied, thanks. Regards, -Denis ^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH -v5 09/13] telit: add post_sim to SAP Client 2011-09-28 21:24 ` [PATCH -v5 09/13] telit: add post_sim " Gustavo F. Padovan 2011-09-28 21:24 ` [PATCH -v5 10/13] telit: add set_online " Gustavo F. Padovan @ 2011-09-29 16:20 ` Denis Kenzior 1 sibling, 0 replies; 24+ messages in thread From: Denis Kenzior @ 2011-09-29 16:20 UTC (permalink / raw) To: ofono [-- Attachment #1: Type: text/plain, Size: 328 bytes --] Hi Gustavo, On 09/28/2011 04:24 PM, Gustavo F. Padovan wrote: > From: "Gustavo F. Padovan" <padovan@profusion.mobi> > > --- > plugins/bluetooth.h | 1 + > plugins/telit.c | 22 +++++++++++++--------- > 2 files changed, 14 insertions(+), 9 deletions(-) Patch has been applied, thanks. Regards, -Denis ^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH -v5 08/13] telit: add pre_sim support to SAP Client 2011-09-28 21:24 ` [PATCH -v5 08/13] telit: add pre_sim support to SAP Client Gustavo F. Padovan 2011-09-28 21:24 ` [PATCH -v5 09/13] telit: add post_sim " Gustavo F. Padovan @ 2011-09-29 16:20 ` Denis Kenzior 1 sibling, 0 replies; 24+ messages in thread From: Denis Kenzior @ 2011-09-29 16:20 UTC (permalink / raw) To: ofono [-- Attachment #1: Type: text/plain, Size: 333 bytes --] Hi Gustavo, On 09/28/2011 04:24 PM, Gustavo F. Padovan wrote: > From: "Gustavo F. Padovan" <padovan@profusion.mobi> > > --- > plugins/bluetooth.h | 1 + > plugins/telit.c | 26 +++++++++++++++----------- > 2 files changed, 16 insertions(+), 11 deletions(-) Patch has been applied, thanks. Regards, -Denis ^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH -v5 07/13] telit: enable the telit modem after enable SAP client 2011-09-28 21:24 ` [PATCH -v5 07/13] telit: enable the telit modem after enable SAP client Gustavo F. Padovan 2011-09-28 21:24 ` [PATCH -v5 08/13] telit: add pre_sim support to SAP Client Gustavo F. Padovan @ 2011-09-29 16:19 ` Denis Kenzior 1 sibling, 0 replies; 24+ messages in thread From: Denis Kenzior @ 2011-09-29 16:19 UTC (permalink / raw) To: ofono [-- Attachment #1: Type: text/plain, Size: 331 bytes --] Hi Gustavo, On 09/28/2011 04:24 PM, Gustavo F. Padovan wrote: > From: "Gustavo F. Padovan" <padovan@profusion.mobi> > > --- > plugins/telit.c | 271 +++++++++++++++++++++++++++++-------------------------- > 1 files changed, 141 insertions(+), 130 deletions(-) > Patch has been applied, thanks. Regards, -Denis ^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH -v5 05/13] telit: add suport the disable SAP client 2011-09-28 21:24 ` [PATCH -v5 05/13] telit: add suport the disable SAP client Gustavo F. Padovan 2011-09-28 21:24 ` [PATCH -v5 06/13] sap: add sap modem disable() support Gustavo F. Padovan @ 2011-09-29 16:15 ` Denis Kenzior 1 sibling, 0 replies; 24+ messages in thread From: Denis Kenzior @ 2011-09-29 16:15 UTC (permalink / raw) To: ofono [-- Attachment #1: Type: text/plain, Size: 361 bytes --] Hi Gustavo, On 09/28/2011 04:24 PM, Gustavo F. Padovan wrote: > From: "Gustavo F. Padovan" <padovan@profusion.mobi> > > --- > plugins/bluetooth.h | 1 + > plugins/telit.c | 100 ++++++++++++++++++++++++++++++++++---------------- > 2 files changed, 69 insertions(+), 32 deletions(-) > Patch has been applied, thanks. Regards, -Denis ^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH -v5 04/13] sap: enable SAP modem, when BlueZ replies 2011-09-28 21:24 ` [PATCH -v5 04/13] sap: enable SAP modem, when BlueZ replies Gustavo F. Padovan 2011-09-28 21:24 ` [PATCH -v5 05/13] telit: add suport the disable SAP client Gustavo F. Padovan @ 2011-09-29 15:54 ` Denis Kenzior 1 sibling, 0 replies; 24+ messages in thread From: Denis Kenzior @ 2011-09-29 15:54 UTC (permalink / raw) To: ofono [-- Attachment #1: Type: text/plain, Size: 1681 bytes --] Hi Gustavo, On 09/28/2011 04:24 PM, Gustavo F. Padovan wrote: > From: "Gustavo F. Padovan" <padovan@profusion.mobi> > > --- > plugins/sap.c | 22 ++++++++++++++++++---- > 1 files changed, 18 insertions(+), 4 deletions(-) > Patch has been applied, one thing: > diff --git a/plugins/sap.c b/plugins/sap.c > index 28b07e7..850ed2f 100644 > --- a/plugins/sap.c > +++ b/plugins/sap.c > @@ -127,6 +127,7 @@ static void sap_connect_reply(DBusPendingCall *call, gpointer user_data) > struct sap_data *data = ofono_modem_get_data(modem); > DBusError derr; > DBusMessage *reply; > + int fd, err; > > DBG(""); > > @@ -138,16 +139,29 @@ 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); > + > + dbus_error_free(&derr); > goto done; > + } > > - DBG("Connect reply: %s", derr.message); > + if (!dbus_message_get_args(reply, NULL, DBUS_TYPE_UNIX_FD, &fd, > + DBUS_TYPE_INVALID)) > + goto done; > > - ofono_modem_set_powered(modem, FALSE); > + data->hw_modem = sap_hw_modem; > + data->sap_driver = sap_hw_driver; > > - dbus_error_free(&derr); > + err = data->sap_driver->enable(data->hw_modem, modem, fd); > + if (err == -EINPROGRESS) { > + dbus_message_unref(reply); > + return; > + } If enable fails, what should be done to the fd we got from bluetoothd? > > done: > + ofono_modem_set_powered(modem, FALSE); > dbus_message_unref(reply); > } > Regards, -Denis ^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH -v5 03/13] telit: add support the enable the SAP client modem 2011-09-28 21:24 ` [PATCH -v5 03/13] telit: add support the enable the SAP client modem Gustavo F. Padovan 2011-09-28 21:24 ` [PATCH -v5 04/13] sap: enable SAP modem, when BlueZ replies Gustavo F. Padovan @ 2011-09-29 15:53 ` Denis Kenzior 1 sibling, 0 replies; 24+ messages in thread From: Denis Kenzior @ 2011-09-29 15:53 UTC (permalink / raw) To: ofono [-- Attachment #1: Type: text/plain, Size: 3287 bytes --] Hi Gustavo, On 09/28/2011 04:24 PM, Gustavo F. Padovan wrote: > From: "Gustavo F. Padovan" <padovan@profusion.mobi> > > --- > plugins/bluetooth.h | 3 +- > plugins/telit.c | 191 ++++++++++++++++++++++++++++++++++++++++++++++++--- > 2 files changed, 184 insertions(+), 10 deletions(-) Patch has been applied, see below: > +static int telit_sap_open() > +{ > + const char *device = "/dev/ttyUSB4"; This part should probably come from udev or a config file somewhere. Worst case /etc/ofono/telitsap.conf or something like that. > + 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); > + > + ti.c_cflag |= (B115200 | CLOCAL | CREAD); > + > + tcflush(fd, TCIOFLUSH); > + if (tcsetattr(fd, TCSANOW, &ti) < 0) { > + close(fd); > + return -EBADF; > + } > + > + 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, > + int bt_fd) > { > struct telit_data *data = ofono_modem_get_data(modem); > + int fd; > > 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; > > - g_at_chat_register(data->chat, "#RSEN:", telit_rsen_notify, > + fd = telit_sap_open(); > + if (fd < 0) > + return fd; > + > + data->hw_io = g_io_channel_unix_new(fd); > + if (data->hw_io == NULL) { > + close(fd); You weren't closing the aux channel here > + return -ENOMEM; > + } > + > + 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); > + > + data->bt_io = g_io_channel_unix_new(bt_fd); > + if (data->bt_io == NULL) { > + sap_close_io(modem); > + return -ENOMEM; > + } > + > + 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); > + > + 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); > + > + > + data->sap_modem = sap_modem; > + > + 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=0", 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 -EINPROGRESS; So I reflowed this function in a follow on patch, please double check it for correctness. Regards, -Denis ^ permalink raw reply [flat|nested] 24+ messages in thread
* Re: [PATCH -v5 02/13] sap: remove connect callback if enable fails 2011-09-28 21:24 ` [PATCH -v5 02/13] sap: remove connect callback if enable fails Gustavo F. Padovan 2011-09-28 21:24 ` [PATCH -v5 03/13] telit: add support the enable the SAP client modem Gustavo F. Padovan @ 2011-09-29 15:50 ` Denis Kenzior 1 sibling, 0 replies; 24+ messages in thread From: Denis Kenzior @ 2011-09-29 15:50 UTC (permalink / raw) To: ofono [-- Attachment #1: Type: text/plain, Size: 284 bytes --] Hi Gustavo, On 09/28/2011 04:24 PM, Gustavo F. Padovan wrote: > From: "Gustavo F. Padovan" <padovan@profusion.mobi> > > --- > plugins/sap.c | 13 ++++++++++++- > 1 files changed, 12 insertions(+), 1 deletions(-) > Patch has been applied, thanks. Regards, -Denis ^ permalink raw reply [flat|nested] 24+ messages in thread
end of thread, other threads:[~2011-09-29 16:22 UTC | newest] Thread overview: 24+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2011-09-28 21:24 [PATCH -v5 01/13] udevng: look also to VID Gustavo F. Padovan 2011-09-28 21:24 ` [PATCH -v5 02/13] sap: remove connect callback if enable fails Gustavo F. Padovan 2011-09-28 21:24 ` [PATCH -v5 03/13] telit: add support the enable the SAP client modem Gustavo F. Padovan 2011-09-28 21:24 ` [PATCH -v5 04/13] sap: enable SAP modem, when BlueZ replies Gustavo F. Padovan 2011-09-28 21:24 ` [PATCH -v5 05/13] telit: add suport the disable SAP client Gustavo F. Padovan 2011-09-28 21:24 ` [PATCH -v5 06/13] sap: add sap modem disable() support Gustavo F. Padovan 2011-09-28 21:24 ` [PATCH -v5 07/13] telit: enable the telit modem after enable SAP client Gustavo F. Padovan 2011-09-28 21:24 ` [PATCH -v5 08/13] telit: add pre_sim support to SAP Client Gustavo F. Padovan 2011-09-28 21:24 ` [PATCH -v5 09/13] telit: add post_sim " Gustavo F. Padovan 2011-09-28 21:24 ` [PATCH -v5 10/13] telit: add set_online " Gustavo F. Padovan 2011-09-28 21:24 ` [PATCH -v5 11/13] telit: add post_online " Gustavo F. Padovan 2011-09-28 21:24 ` [PATCH -v5 12/13] sap: add full support to SAP modem Gustavo F. Padovan 2011-09-28 21:24 ` [PATCH -v5 13/13] sap: clean up extra blank line Gustavo F. Padovan 2011-09-29 16:22 ` Denis Kenzior 2011-09-29 16:22 ` [PATCH -v5 12/13] sap: add full support to SAP modem Denis Kenzior 2011-09-29 16:21 ` [PATCH -v5 11/13] telit: add post_online to SAP Client Denis Kenzior 2011-09-29 16:20 ` [PATCH -v5 10/13] telit: add set_online " Denis Kenzior 2011-09-29 16:20 ` [PATCH -v5 09/13] telit: add post_sim " Denis Kenzior 2011-09-29 16:20 ` [PATCH -v5 08/13] telit: add pre_sim support " Denis Kenzior 2011-09-29 16:19 ` [PATCH -v5 07/13] telit: enable the telit modem after enable SAP client Denis Kenzior 2011-09-29 16:15 ` [PATCH -v5 05/13] telit: add suport the disable " Denis Kenzior 2011-09-29 15:54 ` [PATCH -v5 04/13] sap: enable SAP modem, when BlueZ replies Denis Kenzior 2011-09-29 15:53 ` [PATCH -v5 03/13] telit: add support the enable the SAP client modem Denis Kenzior 2011-09-29 15:50 ` [PATCH -v5 02/13] sap: remove connect callback if enable fails Denis Kenzior
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox