* Re: [PATCH -v2 23/24] bluetooth: track DBus call pending
2011-09-13 18:58 ` [PATCH -v2 23/24] bluetooth: track DBus call pending Gustavo F. Padovan
@ 2011-09-13 5:15 ` Denis Kenzior
2011-09-13 18:58 ` [PATCH -v2 24/24] sap: de-register DBus callback if BlueZ goes down Gustavo F. Padovan
1 sibling, 0 replies; 25+ messages in thread
From: Denis Kenzior @ 2011-09-13 5:15 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 390 bytes --]
Hi Gustavo,
On 09/13/2011 01:58 PM, Gustavo F. Padovan wrote:
> From: "Gustavo F. Padovan" <padovan@profusion.mobi>
>
> ---
> plugins/bluetooth.c | 42 +++++++++++++++++++++++-------------------
> plugins/bluetooth.h | 2 +-
> plugins/hfp_hf.c | 4 ++--
> 3 files changed, 26 insertions(+), 22 deletions(-)
>
Patch has been applied, thanks.
Regards,
-Denis
^ permalink raw reply [flat|nested] 25+ messages in thread
* [PATCH -v2 01/24] udevng: look also to VID
@ 2011-09-13 18:58 Gustavo F. Padovan
2011-09-13 18:58 ` [PATCH -v2 02/24] sap: add basic SAP plugin Gustavo F. Padovan
0 siblings, 1 reply; 25+ messages in thread
From: Gustavo F. Padovan @ 2011-09-13 18:58 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] 25+ messages in thread
* [PATCH -v2 02/24] sap: add basic SAP plugin
2011-09-13 18:58 [PATCH -v2 01/24] udevng: look also to VID Gustavo F. Padovan
@ 2011-09-13 18:58 ` Gustavo F. Padovan
2011-09-13 18:58 ` [PATCH -v2 03/24] telit: add support to enable SAP client Gustavo F. Padovan
0 siblings, 1 reply; 25+ messages in thread
From: Gustavo F. Padovan @ 2011-09-13 18:58 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 10858 bytes --]
From: "Gustavo F. Padovan" <padovan@profusion.mobi>
---
Makefile.am | 3 +
plugins/bluetooth.c | 1 -
plugins/bluetooth.h | 12 ++
plugins/hfp_hf.c | 2 -
plugins/sap.c | 296 +++++++++++++++++++++++++++++++++++++++++++++++++++
plugins/telit.c | 10 ++
6 files changed, 321 insertions(+), 3 deletions(-)
create mode 100644 plugins/sap.c
diff --git a/Makefile.am b/Makefile.am
index 9baab0c..2457e2b 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -366,6 +366,9 @@ builtin_sources += plugins/hfp_ag.c plugins/bluetooth.h
builtin_modules += dun_gw
builtin_sources += plugins/dun_gw.c plugins/bluetooth.h
+builtin_modules += sap
+builtin_sources += plugins/sap.c plugins/bluetooth.h
+
builtin_modules += connman
builtin_sources += plugins/connman.c
diff --git a/plugins/bluetooth.c b/plugins/bluetooth.c
index 1fdb579..9ac558e 100644
--- a/plugins/bluetooth.c
+++ b/plugins/bluetooth.c
@@ -33,7 +33,6 @@
#include <gdbus.h>
#define OFONO_API_SUBJECT_TO_CHANGE
-#include <ofono/dbus.h>
#include <ofono/plugin.h>
#include <ofono/log.h>
diff --git a/plugins/bluetooth.h b/plugins/bluetooth.h
index 6b3fef2..f980ebe 100644
--- a/plugins/bluetooth.h
+++ b/plugins/bluetooth.h
@@ -19,6 +19,9 @@
*
*/
+#include <ofono/modem.h>
+#include <ofono/dbus.h>
+
#define BLUEZ_SERVICE "org.bluez"
#define BLUEZ_MANAGER_INTERFACE BLUEZ_SERVICE ".Manager"
#define BLUEZ_ADAPTER_INTERFACE BLUEZ_SERVICE ".Adapter"
@@ -30,6 +33,7 @@
#define DUN_GW_UUID "00001103-0000-1000-8000-00805f9b34fb"
#define HFP_AG_UUID "0000111f-0000-1000-8000-00805f9b34fb"
#define HFP_HS_UUID "0000111e-0000-1000-8000-00805f9b34fb"
+#define SAP_UUID "0000112d-0000-1000-8000-00805f9b34fb"
struct bluetooth_profile {
const char *name;
@@ -39,6 +43,10 @@ struct bluetooth_profile {
void (*set_alias)(const char *device, const char *);
};
+struct bluetooth_sap_driver {
+ const char *name;
+};
+
struct server;
typedef void (*ConnectFunc)(GIOChannel *io, GError *err, gpointer user_data);
@@ -60,3 +68,7 @@ int bluetooth_send_with_reply(const char *path, const char *interface,
void *user_data, DBusFreeFunction free_func,
int timeout, int type, ...);
void bluetooth_parse_properties(DBusMessage *reply, const char *property, ...);
+
+int bluetooth_sap_client_register(struct bluetooth_sap_driver *sap,
+ struct ofono_modem *modem);
+void bluetooth_sap_client_unregister(struct ofono_modem *modem);
diff --git a/plugins/hfp_hf.c b/plugins/hfp_hf.c
index 6516e75..717891b 100644
--- a/plugins/hfp_hf.c
+++ b/plugins/hfp_hf.c
@@ -44,8 +44,6 @@
#include <drivers/hfpmodem/slc.h>
-#include <ofono/dbus.h>
-
#include "bluetooth.h"
#define BLUEZ_GATEWAY_INTERFACE BLUEZ_SERVICE ".HandsfreeGateway"
diff --git a/plugins/sap.c b/plugins/sap.c
new file mode 100644
index 0000000..88663c2
--- /dev/null
+++ b/plugins/sap.c
@@ -0,0 +1,296 @@
+/*
+ *
+ * oFono - Open Source Telephony
+ *
+ * Copyright (C) 2008-2010 Intel Corporation. All rights reserved.
+ * Copyright (C) 2010-2011 ProFUSION embedded systems
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <errno.h>
+#include <unistd.h>
+#include <glib.h>
+#include <gdbus.h>
+#include <ofono.h>
+
+#define OFONO_API_SUBJECT_TO_CHANGE
+#include <ofono/plugin.h>
+#include <ofono/log.h>
+#include <ofono/modem.h>
+
+#include "bluetooth.h"
+
+#ifndef DBUS_TYPE_UNIX_FD
+#define DBUS_TYPE_UNIX_FD -1
+#endif
+
+static DBusConnection *connection;
+static GHashTable *modem_hash = NULL;
+static GHashTable *sap_hw_hash = NULL;
+
+struct sap_data {
+ char *server_path;
+ struct ofono_modem *hw_modem;
+ struct bluetooth_sap_driver *sap_driver;
+};
+
+int bluetooth_sap_client_register(struct bluetooth_sap_driver *sap,
+ struct ofono_modem *modem)
+{
+ if (g_hash_table_lookup(sap_hw_hash, modem) != NULL)
+ return -EALREADY;
+
+ g_hash_table_insert(sap_hw_hash, modem, sap);
+
+ return 0;
+}
+
+static gboolean _remove_modem(gpointer data)
+{
+ struct ofono_modem *modem = data;
+
+ ofono_modem_remove(modem);
+
+ return FALSE;
+}
+
+void bluetooth_sap_client_unregister(struct ofono_modem *modem)
+{
+ GHashTableIter iter;
+ gpointer key, value;
+
+ if (modem_hash == NULL)
+ return;
+
+ g_hash_table_iter_init(&iter, modem_hash);
+
+ while (g_hash_table_iter_next(&iter, &key, &value)) {
+ struct ofono_modem *sap_modem = value;
+ struct sap_data *sap_data = ofono_modem_get_data(sap_modem);
+
+ if (sap_data->hw_modem == modem)
+ g_idle_add(_remove_modem, sap_modem);
+ }
+
+ g_hash_table_remove(sap_hw_hash, modem);
+
+}
+
+static int sap_probe(struct ofono_modem *modem)
+{
+ DBG("%p", modem);
+
+ return 0;
+}
+
+static void sap_remove(struct ofono_modem *modem)
+{
+ struct sap_data *data = ofono_modem_get_data(modem);
+
+ g_hash_table_remove(modem_hash, data->server_path);
+
+ g_free(data->server_path);
+ g_free(data);
+
+ ofono_modem_set_data(modem, NULL);
+}
+
+/* power up hardware */
+static int sap_enable(struct ofono_modem *modem)
+{
+ DBG("%p", modem);
+
+ return 0;
+}
+
+static int sap_disable(struct ofono_modem *modem)
+{
+ DBG("%p", modem);
+
+ return 0;
+}
+
+static void sap_pre_sim(struct ofono_modem *modem)
+{
+ DBG("%p", modem);
+}
+
+static void sap_post_sim(struct ofono_modem *modem)
+{
+ DBG("%p", modem);
+}
+
+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];
+ GHashTableIter iter;
+ gpointer key, value;
+
+ /* We already have this device in our hash, ignore */
+ if (g_hash_table_lookup(modem_hash, device) != NULL)
+ return -EALREADY;
+
+ g_hash_table_iter_init(&iter, sap_hw_hash);
+ while(g_hash_table_iter_next(&iter, &key, &value)) {
+
+ ofono_info("Using device: %s, devaddr: %s, adapter: %s",
+ device, dev_addr, adapter_addr);
+
+ strcpy(buf, "sap/");
+ bluetooth_create_path(dev_addr, adapter_addr, buf + 4,
+ sizeof(buf) - 4);
+
+ modem = ofono_modem_create(buf, "sap");
+ 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;
+
+ data->hw_modem = key;
+ data->sap_driver = value;
+
+ ofono_modem_set_data(modem, data);
+ ofono_modem_set_name(modem, alias);
+ ofono_modem_register(modem);
+
+ g_hash_table_insert(modem_hash, g_strdup(device), modem);
+
+ break;
+
+ }
+
+ return 0;
+
+free:
+ g_free(data);
+ ofono_modem_remove(modem);
+
+ return -ENOMEM;
+}
+
+static gboolean sap_remove_modem(gpointer key, gpointer value,
+ gpointer user_data)
+{
+ struct ofono_modem *modem = value;
+ const char *device = key;
+ const char *prefix = user_data;
+
+ if (prefix && g_str_has_prefix(device, prefix) == FALSE)
+ return FALSE;
+
+ ofono_modem_remove(modem);
+
+ return TRUE;
+}
+
+static void bluetooth_sap_remove(const char *prefix)
+{
+ DBG("%s", prefix);
+
+ if (modem_hash == NULL)
+ return;
+
+ g_hash_table_foreach_remove(modem_hash, sap_remove_modem,
+ (gpointer) prefix);
+}
+
+static void bluetooth_sap_set_alias(const char *device, const char *alias)
+{
+ struct ofono_modem *modem;
+
+ if (device == NULL || alias == NULL)
+ return;
+
+ modem = g_hash_table_lookup(modem_hash, device);
+ if (modem == NULL)
+ return;
+
+ ofono_modem_set_name(modem, alias);
+}
+
+static struct ofono_modem_driver sap_driver = {
+ .name = "sap",
+ .probe = sap_probe,
+ .remove = sap_remove,
+ .enable = sap_enable,
+ .disable = sap_disable,
+ .pre_sim = sap_pre_sim,
+ .post_sim = sap_post_sim,
+};
+
+static struct bluetooth_profile sap = {
+ .name = "sap",
+ .probe = bluetooth_sap_probe,
+ .remove = bluetooth_sap_remove,
+ .set_alias = bluetooth_sap_set_alias,
+};
+
+static int sap_init(void)
+{
+ int err;
+
+ if (DBUS_TYPE_UNIX_FD < 0)
+ return -EBADF;
+
+ connection = ofono_dbus_get_connection();
+
+ err = ofono_modem_driver_register(&sap_driver);
+ if (err < 0)
+ return err;
+
+ err = bluetooth_register_uuid(SAP_UUID, &sap);
+ if (err < 0) {
+ ofono_modem_driver_unregister(&sap_driver);
+ return err;
+ }
+
+ modem_hash = g_hash_table_new_full(g_str_hash, g_str_equal,
+ g_free, NULL);
+
+ sap_hw_hash = g_hash_table_new_full(g_str_hash, g_str_equal,
+ NULL, NULL);
+
+ return 0;
+}
+
+static void sap_exit(void)
+{
+ DBG("");
+
+ bluetooth_unregister_uuid(SAP_UUID);
+ ofono_modem_driver_unregister(&sap_driver);
+ g_hash_table_destroy(sap_hw_hash);
+ g_hash_table_destroy(modem_hash);
+ modem_hash = NULL;
+}
+
+OFONO_PLUGIN_DEFINE(sap, "Sim Access Profile Plugins", VERSION,
+ OFONO_PLUGIN_PRIORITY_DEFAULT, sap_init, sap_exit)
diff --git a/plugins/telit.c b/plugins/telit.c
index 9c8eb0d..18cf0c4 100644
--- a/plugins/telit.c
+++ b/plugins/telit.c
@@ -54,6 +54,8 @@
#include <drivers/atmodem/atutil.h>
#include <drivers/atmodem/vendor.h>
+#include "bluetooth.h"
+
static const char *none_prefix[] = { NULL };
static const char *qss_prefix[] = { "#QSS:", NULL };
@@ -63,6 +65,10 @@ struct telit_data {
guint sim_inserted_source;
};
+static struct bluetooth_sap_driver sap_driver = {
+ .name = "telit",
+};
+
static void telit_debug(const char *str, void *user_data)
{
const char *prefix = user_data;
@@ -82,6 +88,8 @@ static int telit_probe(struct ofono_modem *modem)
ofono_modem_set_data(modem, data);
+ bluetooth_sap_client_register(&sap_driver, modem);
+
return 0;
}
@@ -91,6 +99,8 @@ static void telit_remove(struct ofono_modem *modem)
DBG("%p", modem);
+ bluetooth_sap_client_unregister(modem);
+
ofono_modem_set_data(modem, NULL);
if (data->sim_inserted_source > 0)
--
1.7.6.2
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH -v2 03/24] telit: add support to enable SAP client
2011-09-13 18:58 ` [PATCH -v2 02/24] sap: add basic SAP plugin Gustavo F. Padovan
@ 2011-09-13 18:58 ` Gustavo F. Padovan
2011-09-13 18:58 ` [PATCH -v2 04/24] sap: add support to connect the RFCOMM link Gustavo F. Padovan
0 siblings, 1 reply; 25+ messages in thread
From: Gustavo F. Padovan @ 2011-09-13 18:58 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 4471 bytes --]
From: "Gustavo F. Padovan" <padovan@profusion.mobi>
---
plugins/bluetooth.h | 1 +
plugins/sap.c | 4 +-
plugins/telit.c | 109 ++++++++++++++++++++++++++++++++++-----------------
3 files changed, 76 insertions(+), 38 deletions(-)
diff --git a/plugins/bluetooth.h b/plugins/bluetooth.h
index f980ebe..1658b75 100644
--- a/plugins/bluetooth.h
+++ b/plugins/bluetooth.h
@@ -45,6 +45,7 @@ struct bluetooth_profile {
struct bluetooth_sap_driver {
const char *name;
+ int (*enable) (struct ofono_modem *modem);
};
struct server;
diff --git a/plugins/sap.c b/plugins/sap.c
index 88663c2..2a5db74 100644
--- a/plugins/sap.c
+++ b/plugins/sap.c
@@ -117,9 +117,9 @@ static void sap_remove(struct ofono_modem *modem)
/* power up hardware */
static int sap_enable(struct ofono_modem *modem)
{
- DBG("%p", modem);
+ struct sap_data *data = ofono_modem_get_data(modem);
- return 0;
+ return data->sap_driver->enable(data->hw_modem);
}
static int sap_disable(struct ofono_modem *modem)
diff --git a/plugins/telit.c b/plugins/telit.c
index 18cf0c4..cc10668 100644
--- a/plugins/telit.c
+++ b/plugins/telit.c
@@ -58,6 +58,7 @@
static const char *none_prefix[] = { NULL };
static const char *qss_prefix[] = { "#QSS:", NULL };
+static const char *rsen_prefix[]= { "#RSEN:", NULL };
struct telit_data {
GAtChat *chat;
@@ -65,10 +66,6 @@ struct telit_data {
guint sim_inserted_source;
};
-static struct bluetooth_sap_driver sap_driver = {
- .name = "telit",
-};
-
static void telit_debug(const char *str, void *user_data)
{
const char *prefix = user_data;
@@ -76,6 +73,78 @@ static void telit_debug(const char *str, void *user_data)
ofono_info("%s%s", prefix, str);
}
+static GAtChat *open_device(struct ofono_modem *modem,
+ const char *key, char *debug)
+{
+ const char *device;
+ GAtSyntax *syntax;
+ GIOChannel *channel;
+ GAtChat *chat;
+
+ device = ofono_modem_get_string(modem, key);
+ if (device == NULL)
+ return NULL;
+
+ DBG("%s %s", key, device);
+
+ channel = g_at_tty_open(device, NULL);
+ if (channel == NULL)
+ return NULL;
+
+ syntax = g_at_syntax_new_gsmv1();
+ chat = g_at_chat_new(channel, syntax);
+ g_at_syntax_unref(syntax);
+ g_io_channel_unref(channel);
+
+ if (chat == NULL)
+ return NULL;
+
+ if (getenv("OFONO_AT_DEBUG"))
+ g_at_chat_set_debug(chat, telit_debug, debug);
+
+ return chat;
+}
+
+static void rsen_enable_cb(gboolean ok, GAtResult *result, gpointer user_data)
+{
+ struct ofono_modem *modem = user_data;
+ struct telit_data *data = ofono_modem_get_data(modem);
+
+ DBG("%p", modem);
+
+ if (!ok) {
+ g_at_chat_unref(data->chat);
+ data->chat = NULL;
+ ofono_modem_set_powered(modem, FALSE);
+ return;
+ }
+
+}
+
+static int telit_sap_enable(struct ofono_modem *modem)
+{
+ struct telit_data *data = ofono_modem_get_data(modem);
+
+ DBG("%p", modem);
+
+ data->chat = open_device(modem, "Data", "Aux: ");
+ if (data->chat == NULL)
+ return -EINVAL;
+
+ g_at_chat_send(data->chat, "AT#NOPT=3", NULL, NULL, NULL, NULL);
+
+ /* Set SAP functionality */
+ g_at_chat_send(data->chat, "AT#RSEN=1,1,0,2,0", rsen_prefix,
+ rsen_enable_cb, modem, NULL);
+
+ return -EINPROGRESS;
+}
+
+static struct bluetooth_sap_driver sap_driver = {
+ .name = "telit",
+ .enable = telit_sap_enable,
+};
+
static int telit_probe(struct ofono_modem *modem)
{
struct telit_data *data;
@@ -232,38 +301,6 @@ static void cfun_disable_cb(gboolean ok, GAtResult *result, gpointer user_data)
ofono_modem_set_powered(modem, FALSE);
}
-static GAtChat *open_device(struct ofono_modem *modem,
- const char *key, char *debug)
-{
- const char *device;
- GAtSyntax *syntax;
- GIOChannel *channel;
- GAtChat *chat;
-
- device = ofono_modem_get_string(modem, key);
- if (device == NULL)
- return NULL;
-
- DBG("%s %s", key, device);
-
- channel = g_at_tty_open(device, NULL);
- if (channel == NULL)
- return NULL;
-
- syntax = g_at_syntax_new_gsmv1();
- chat = g_at_chat_new(channel, syntax);
- g_at_syntax_unref(syntax);
- g_io_channel_unref(channel);
-
- if (chat == NULL)
- return NULL;
-
- if (getenv("OFONO_AT_DEBUG"))
- g_at_chat_set_debug(chat, telit_debug, debug);
-
- return chat;
-}
-
static int telit_enable(struct ofono_modem *modem)
{
struct telit_data *data = ofono_modem_get_data(modem);
--
1.7.6.2
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH -v2 04/24] sap: add support to connect the RFCOMM link
2011-09-13 18:58 ` [PATCH -v2 03/24] telit: add support to enable SAP client Gustavo F. Padovan
@ 2011-09-13 18:58 ` Gustavo F. Padovan
2011-09-13 18:58 ` [PATCH -v2 05/24] telit: add #RSEN notify Gustavo F. Padovan
0 siblings, 1 reply; 25+ messages in thread
From: Gustavo F. Padovan @ 2011-09-13 18:58 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 1932 bytes --]
From: "Gustavo F. Padovan" <padovan@profusion.mobi>
---
plugins/sap.c | 45 ++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 44 insertions(+), 1 deletions(-)
diff --git a/plugins/sap.c b/plugins/sap.c
index 2a5db74..9f464e7 100644
--- a/plugins/sap.c
+++ b/plugins/sap.c
@@ -38,11 +38,14 @@
#include <ofono/modem.h>
#include "bluetooth.h"
+#include "util.h"
#ifndef DBUS_TYPE_UNIX_FD
#define DBUS_TYPE_UNIX_FD -1
#endif
+#define BLUEZ_SERIAL_INTERFACE BLUEZ_SERVICE ".Serial"
+
static DBusConnection *connection;
static GHashTable *modem_hash = NULL;
static GHashTable *sap_hw_hash = NULL;
@@ -114,12 +117,52 @@ static void sap_remove(struct ofono_modem *modem)
ofono_modem_set_data(modem, NULL);
}
+static void sap_connect_reply(DBusPendingCall *call, gpointer user_data)
+{
+ struct ofono_modem *modem = user_data;
+ DBusError derr;
+ DBusMessage *reply;
+
+ DBG("");
+
+ reply = dbus_pending_call_steal_reply(call);
+
+ if (ofono_modem_get_powered(modem))
+ goto done;
+
+ dbus_error_init(&derr);
+ if (!dbus_set_error_from_message(&derr, reply))
+ goto done;
+
+ DBG("Connect reply: %s", derr.message);
+
+ ofono_modem_set_powered(modem, FALSE);
+
+ dbus_error_free(&derr);
+
+done:
+ dbus_message_unref(reply);
+}
+
/* power up hardware */
static int sap_enable(struct ofono_modem *modem)
{
struct sap_data *data = ofono_modem_get_data(modem);
+ int status;
+ const char *str = "sap";
+
+ DBG("%p", modem);
+
+ status = bluetooth_send_with_reply(data->server_path,
+ BLUEZ_SERIAL_INTERFACE, "ConnectFD",
+ sap_connect_reply, modem, NULL,
+ DBUS_TIMEOUT, DBUS_TYPE_STRING,
+ &str, DBUS_TYPE_INVALID);
+
+ if (status < 0)
+ return -EINVAL;
- return data->sap_driver->enable(data->hw_modem);
+ return -EINPROGRESS;
}
static int sap_disable(struct ofono_modem *modem)
--
1.7.6.2
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH -v2 05/24] telit: add #RSEN notify
2011-09-13 18:58 ` [PATCH -v2 04/24] sap: add support to connect the RFCOMM link Gustavo F. Padovan
@ 2011-09-13 18:58 ` Gustavo F. Padovan
2011-09-13 18:58 ` [PATCH -v2 06/24] sap: add watch for the Bluetooth Link Gustavo F. Padovan
0 siblings, 1 reply; 25+ messages in thread
From: Gustavo F. Padovan @ 2011-09-13 18:58 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 1246 bytes --]
From: "Gustavo F. Padovan" <padovan@profusion.mobi>
RSEN URC tells if the SAP Client was enabled or not
---
plugins/telit.c | 19 +++++++++++++++++++
1 files changed, 19 insertions(+), 0 deletions(-)
diff --git a/plugins/telit.c b/plugins/telit.c
index cc10668..1f950aa 100644
--- a/plugins/telit.c
+++ b/plugins/telit.c
@@ -105,6 +105,22 @@ static GAtChat *open_device(struct ofono_modem *modem,
return chat;
}
+static void telit_rsen_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, "#RSEN:"))
+ return;
+
+ g_at_result_iter_next_number(&iter, &status);
+}
+
static void rsen_enable_cb(gboolean ok, GAtResult *result, gpointer user_data)
{
struct ofono_modem *modem = user_data;
@@ -131,6 +147,9 @@ static int telit_sap_enable(struct ofono_modem *modem)
if (data->chat == NULL)
return -EINVAL;
+ g_at_chat_register(data->chat, "#RSEN:", telit_rsen_notify,
+ FALSE, modem, NULL);
+
g_at_chat_send(data->chat, "AT#NOPT=3", NULL, NULL, NULL, NULL);
/* Set SAP functionality */
--
1.7.6.2
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH -v2 06/24] sap: add watch for the Bluetooth Link
2011-09-13 18:58 ` [PATCH -v2 05/24] telit: add #RSEN notify Gustavo F. Padovan
@ 2011-09-13 18:58 ` Gustavo F. Padovan
2011-09-13 18:58 ` [PATCH -v2 07/24] sap: add support to open the channel for SAP data Gustavo F. Padovan
0 siblings, 1 reply; 25+ messages in thread
From: Gustavo F. Padovan @ 2011-09-13 18:58 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 3173 bytes --]
From: "Gustavo F. Padovan" <padovan@profusion.mobi>
---
plugins/sap.c | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++----
1 files changed, 65 insertions(+), 5 deletions(-)
diff --git a/plugins/sap.c b/plugins/sap.c
index 9f464e7..6ff52d2 100644
--- a/plugins/sap.c
+++ b/plugins/sap.c
@@ -54,6 +54,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,
@@ -95,7 +97,33 @@ void bluetooth_sap_client_unregister(struct ofono_modem *modem)
}
g_hash_table_remove(sap_hw_hash, modem);
+}
+
+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;
+ 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;
+ }
+
+ ofono_modem_set_powered(modem, FALSE);
+
+ sap_data->bt_watch = 0;
+
+ return FALSE;
}
static int sap_probe(struct ofono_modem *modem)
@@ -120,8 +148,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;
+ DBusMessage *reply, *msg;
+ int fd;
DBG("");
@@ -131,14 +161,44 @@ 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);
+
+ if (dbus_error_has_name(&derr, DBUS_ERROR_NO_REPLY)) {
+ const char *str = "sap";
+
+ msg = dbus_message_new_method_call(BLUEZ_SERVICE,
+ data->server_path,
+ BLUEZ_SERIAL_INTERFACE, "Disconnect");
+ dbus_message_append_args(msg, DBUS_TYPE_STRING,
+ &str, DBUS_TYPE_INVALID);
+ if (msg == NULL)
+ ofono_error("Disconnect failed");
+ else
+ g_dbus_send_message(connection, msg);
+ }
+
+ 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(data->bt_io, G_IO_HUP | G_IO_ERR
+ | G_IO_NVAL | G_IO_IN, bt_event_cb, modem);
done:
dbus_message_unref(reply);
--
1.7.6.2
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH -v2 07/24] sap: add support to open the channel for SAP data
2011-09-13 18:58 ` [PATCH -v2 06/24] sap: add watch for the Bluetooth Link Gustavo F. Padovan
@ 2011-09-13 18:58 ` Gustavo F. Padovan
2011-09-13 18:58 ` [PATCH -v2 08/24] sap: connect the hw and the bluetooth link Gustavo F. Padovan
0 siblings, 1 reply; 25+ messages in thread
From: Gustavo F. Padovan @ 2011-09-13 18:58 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 1850 bytes --]
From: "Gustavo F. Padovan" <padovan@profusion.mobi>
---
plugins/bluetooth.h | 1 +
plugins/telit.c | 28 ++++++++++++++++++++++++++++
2 files changed, 29 insertions(+), 0 deletions(-)
diff --git a/plugins/bluetooth.h b/plugins/bluetooth.h
index 1658b75..20df890 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 (*open) (struct ofono_modem *modem);
};
struct server;
diff --git a/plugins/telit.c b/plugins/telit.c
index 1f950aa..69f9eed 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,7 +137,31 @@ static void rsen_enable_cb(gboolean ok, GAtResult *result, gpointer user_data)
ofono_modem_set_powered(modem, FALSE);
return;
}
+}
+
+static int telit_sap_open(struct ofono_modem *modem)
+{
+ 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 -1;
+
+ /* 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)
@@ -162,6 +189,7 @@ static int telit_sap_enable(struct ofono_modem *modem)
static struct bluetooth_sap_driver sap_driver = {
.name = "telit",
.enable = telit_sap_enable,
+ .open = telit_sap_open,
};
static int telit_probe(struct ofono_modem *modem)
--
1.7.6.2
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH -v2 08/24] sap: connect the hw and the bluetooth link
2011-09-13 18:58 ` [PATCH -v2 07/24] sap: add support to open the channel for SAP data Gustavo F. Padovan
@ 2011-09-13 18:58 ` Gustavo F. Padovan
2011-09-13 18:58 ` [PATCH -v2 09/24] telit: add telit_sap_disable() Gustavo F. Padovan
0 siblings, 1 reply; 25+ messages in thread
From: Gustavo F. Padovan @ 2011-09-13 18:58 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 3003 bytes --]
From: "Gustavo F. Padovan" <padovan@profusion.mobi>
data is now passed from one side to another
---
plugins/sap.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 62 insertions(+), 1 deletions(-)
diff --git a/plugins/sap.c b/plugins/sap.c
index 6ff52d2..043fb6c 100644
--- a/plugins/sap.c
+++ b/plugins/sap.c
@@ -55,7 +55,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,
@@ -107,12 +109,16 @@ static gboolean bt_event_cb(GIOChannel *bt_io, GIOCondition condition,
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;
@@ -126,6 +132,37 @@ static gboolean bt_event_cb(GIOChannel *bt_io, GIOCondition condition,
return FALSE;
}
+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;
+
+ return TRUE;
+ }
+
+ ofono_modem_set_powered(modem, FALSE);
+
+ sap_data->hw_watch = 0;
+
+ return FALSE;
+}
+
static int sap_probe(struct ofono_modem *modem)
{
DBG("%p", modem);
@@ -200,6 +237,30 @@ static void sap_connect_reply(DBusPendingCall *call, gpointer user_data)
data->bt_watch = g_io_add_watch(data->bt_io, G_IO_HUP | G_IO_ERR
| G_IO_NVAL | G_IO_IN, bt_event_cb, modem);
+ fd = data->sap_driver->open(data->hw_modem);
+ if (!fd) {
+ g_io_channel_unref(data->bt_io);
+ 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(data->hw_io, G_IO_HUP | G_IO_ERR
+ | G_IO_NVAL | G_IO_IN, hw_event_cb, modem);
+
+ data->sap_driver->enable(data->hw_modem);
+
+ ofono_modem_set_powered(modem, TRUE);
+
done:
dbus_message_unref(reply);
}
--
1.7.6.2
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH -v2 09/24] telit: add telit_sap_disable()
2011-09-13 18:58 ` [PATCH -v2 08/24] sap: connect the hw and the bluetooth link Gustavo F. Padovan
@ 2011-09-13 18:58 ` Gustavo F. Padovan
2011-09-13 18:58 ` [PATCH -v2 10/24] sap: add support to the disable the SAP client Gustavo F. Padovan
0 siblings, 1 reply; 25+ messages in thread
From: Gustavo F. Padovan @ 2011-09-13 18:58 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 1951 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 20df890..d2ccb21 100644
--- a/plugins/bluetooth.h
+++ b/plugins/bluetooth.h
@@ -46,6 +46,7 @@ struct bluetooth_profile {
struct bluetooth_sap_driver {
const char *name;
int (*enable) (struct ofono_modem *modem);
+ int (*disable) (struct ofono_modem *modem);
int (*open) (struct ofono_modem *modem);
};
diff --git a/plugins/telit.c b/plugins/telit.c
index 69f9eed..4626c4b 100644
--- a/plugins/telit.c
+++ b/plugins/telit.c
@@ -139,6 +139,20 @@ static void rsen_enable_cb(gboolean ok, GAtResult *result, gpointer user_data)
}
}
+static void rsen_disable_cb(gboolean ok, GAtResult *result, gpointer user_data)
+{
+ struct ofono_modem *modem = user_data;
+ struct telit_data *data = ofono_modem_get_data(modem);
+
+ DBG("%p", modem);
+
+ g_at_chat_unref(data->chat);
+ data->chat = NULL;
+
+ if (ok)
+ ofono_modem_set_powered(modem, FALSE);
+}
+
static int telit_sap_open(struct ofono_modem *modem)
{
const char *device = "/dev/ttyUSB4";
@@ -186,9 +200,25 @@ static int telit_sap_enable(struct ofono_modem *modem)
return -EINPROGRESS;
}
+static int telit_sap_disable(struct ofono_modem *modem)
+{
+ struct telit_data *data = ofono_modem_get_data(modem);
+
+ DBG("%p", modem);
+
+ g_at_chat_cancel_all(data->chat);
+ g_at_chat_unregister_all(data->chat);
+
+ g_at_chat_send(data->chat, "AT#RSEN=0", rsen_prefix,
+ rsen_disable_cb, modem, NULL);
+
+ return 0;
+}
+
static struct bluetooth_sap_driver sap_driver = {
.name = "telit",
.enable = telit_sap_enable,
+ .disable = telit_sap_disable,
.open = telit_sap_open,
};
--
1.7.6.2
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH -v2 10/24] sap: add support to the disable the SAP client
2011-09-13 18:58 ` [PATCH -v2 09/24] telit: add telit_sap_disable() Gustavo F. Padovan
@ 2011-09-13 18:58 ` Gustavo F. Padovan
2011-09-13 18:58 ` [PATCH -v2 11/24] telit: add aux GAtChat Gustavo F. Padovan
0 siblings, 1 reply; 25+ messages in thread
From: Gustavo F. Padovan @ 2011-09-13 18:58 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 043fb6c..3e8847a 100644
--- a/plugins/sap.c
+++ b/plugins/sap.c
@@ -288,8 +288,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] 25+ messages in thread
* [PATCH -v2 11/24] telit: add aux GAtChat
2011-09-13 18:58 ` [PATCH -v2 10/24] sap: add support to the disable the SAP client Gustavo F. Padovan
@ 2011-09-13 18:58 ` Gustavo F. Padovan
2011-09-13 18:58 ` [PATCH -v2 12/24] sap: enable modem only when #RSEN is 1 Gustavo F. Padovan
0 siblings, 1 reply; 25+ messages in thread
From: Gustavo F. Padovan @ 2011-09-13 18:58 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 1893 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 4626c4b..b6d408f 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);
@@ -184,17 +185,17 @@ 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;
- 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 -EINPROGRESS;
--
1.7.6.2
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH -v2 12/24] sap: enable modem only when #RSEN is 1
2011-09-13 18:58 ` [PATCH -v2 11/24] telit: add aux GAtChat Gustavo F. Padovan
@ 2011-09-13 18:58 ` Gustavo F. Padovan
2011-09-13 18:58 ` [PATCH -v2 13/24] telit: enable the telit modem when SAP is enabled Gustavo F. Padovan
0 siblings, 1 reply; 25+ messages in thread
From: Gustavo F. Padovan @ 2011-09-13 18:58 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 3444 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 d2ccb21..26767b7 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);
int (*open) (struct ofono_modem *modem);
};
diff --git a/plugins/sap.c b/plugins/sap.c
index 3e8847a..14c496f 100644
--- a/plugins/sap.c
+++ b/plugins/sap.c
@@ -257,9 +257,7 @@ static void sap_connect_reply(DBusPendingCall *call, gpointer user_data)
data->hw_watch = g_io_add_watch(data->hw_io, G_IO_HUP | G_IO_ERR
| G_IO_NVAL | G_IO_IN, hw_event_cb, modem);
- data->sap_driver->enable(data->hw_modem);
-
- ofono_modem_set_powered(modem, TRUE);
+ data->sap_driver->enable(data->hw_modem, modem);
done:
dbus_message_unref(reply);
diff --git a/plugins/telit.c b/plugins/telit.c
index b6d408f..a89fce1 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(struct ofono_modem *modem)
@@ -179,7 +188,8 @@ static int telit_sap_open(struct ofono_modem *modem)
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);
@@ -189,6 +199,8 @@ static int telit_sap_enable(struct ofono_modem *modem)
if (data->aux == NULL)
return -EINVAL;
+ 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] 25+ messages in thread
* [PATCH -v2 13/24] telit: enable the telit modem when SAP is enabled.
2011-09-13 18:58 ` [PATCH -v2 12/24] sap: enable modem only when #RSEN is 1 Gustavo F. Padovan
@ 2011-09-13 18:58 ` Gustavo F. Padovan
2011-09-13 18:58 ` [PATCH -v2 14/24] sap: add pre_sim handling Gustavo F. Padovan
0 siblings, 1 reply; 25+ messages in thread
From: Gustavo F. Padovan @ 2011-09-13 18:58 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 a89fce1..856230f 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)
@@ -204,7 +335,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,
@@ -268,112 +399,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;
@@ -391,30 +416,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] 25+ messages in thread
* [PATCH -v2 14/24] sap: add pre_sim handling
2011-09-13 18:58 ` [PATCH -v2 13/24] telit: enable the telit modem when SAP is enabled Gustavo F. Padovan
@ 2011-09-13 18:58 ` Gustavo F. Padovan
2011-09-13 18:58 ` [PATCH -v2 15/24] sap: add set_online handling Gustavo F. Padovan
0 siblings, 1 reply; 25+ messages in thread
From: Gustavo F. Padovan @ 2011-09-13 18:58 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 2544 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 26767b7..9850864 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);
int (*open) (struct ofono_modem *modem);
};
diff --git a/plugins/sap.c b/plugins/sap.c
index 14c496f..2935552 100644
--- a/plugins/sap.c
+++ b/plugins/sap.c
@@ -297,7 +297,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 856230f..c116606 100644
--- a/plugins/telit.c
+++ b/plugins/telit.c
@@ -359,9 +359,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,
.open = telit_sap_open,
};
@@ -454,17 +469,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] 25+ messages in thread
* [PATCH -v2 15/24] sap: add set_online handling
2011-09-13 18:58 ` [PATCH -v2 14/24] sap: add pre_sim handling Gustavo F. Padovan
@ 2011-09-13 18:58 ` Gustavo F. Padovan
2011-09-13 18:58 ` [PATCH -v2 16/24] sap: add post_sim handling Gustavo F. Padovan
0 siblings, 1 reply; 25+ messages in thread
From: Gustavo F. Padovan @ 2011-09-13 18:58 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 5070 bytes --]
From: "Gustavo F. Padovan" <padovan@profusion.mobi>
---
plugins/bluetooth.h | 2 +
plugins/sap.c | 11 +++++++
plugins/telit.c | 83 +++++++++++++++------------------------------------
3 files changed, 37 insertions(+), 59 deletions(-)
diff --git a/plugins/bluetooth.h b/plugins/bluetooth.h
index 9850864..b26b4f7 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);
int (*open) (struct ofono_modem *modem);
};
diff --git a/plugins/sap.c b/plugins/sap.c
index 2935552..ef805cc 100644
--- a/plugins/sap.c
+++ b/plugins/sap.c
@@ -309,6 +309,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)
{
@@ -414,6 +424,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 c116606..1098420 100644
--- a/plugins/telit.c
+++ b/plugins/telit.c
@@ -373,10 +373,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,
.open = telit_sap_open,
};
@@ -446,65 +470,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);
- 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] 25+ messages in thread
* [PATCH -v2 16/24] sap: add post_sim handling
2011-09-13 18:58 ` [PATCH -v2 15/24] sap: add set_online handling Gustavo F. Padovan
@ 2011-09-13 18:58 ` Gustavo F. Padovan
2011-09-13 18:58 ` [PATCH -v2 17/24] sap: add post_online handling Gustavo F. Padovan
0 siblings, 1 reply; 25+ messages in thread
From: Gustavo F. Padovan @ 2011-09-13 18:58 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 3344 bytes --]
From: "Gustavo F. Padovan" <padovan@profusion.mobi>
---
plugins/bluetooth.h | 1 +
plugins/sap.c | 4 ++++
plugins/telit.c | 40 ++++++++++++++++++++++++++++++++++++++++
3 files changed, 45 insertions(+), 0 deletions(-)
diff --git a/plugins/bluetooth.h b/plugins/bluetooth.h
index b26b4f7..2f02c39 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 ef805cc..43218c7 100644
--- a/plugins/sap.c
+++ b/plugins/sap.c
@@ -306,7 +306,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 1098420..7bdbd8c 100644
--- a/plugins/telit.c
+++ b/plugins/telit.c
@@ -373,6 +373,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;
@@ -400,6 +412,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,
.open = telit_sap_open,
@@ -470,6 +483,33 @@ 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] 25+ messages in thread
* [PATCH -v2 17/24] sap: add post_online handling
2011-09-13 18:58 ` [PATCH -v2 16/24] sap: add post_sim handling Gustavo F. Padovan
@ 2011-09-13 18:58 ` Gustavo F. Padovan
2011-09-13 18:58 ` [PATCH -v2 18/24] telit: improve sap disable Gustavo F. Padovan
0 siblings, 1 reply; 25+ messages in thread
From: Gustavo F. Padovan @ 2011-09-13 18:58 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 4328 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 2f02c39..78b93e2 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);
int (*open) (struct ofono_modem *modem);
};
diff --git a/plugins/sap.c b/plugins/sap.c
index 43218c7..e165095 100644
--- a/plugins/sap.c
+++ b/plugins/sap.c
@@ -323,6 +323,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)
{
@@ -429,6 +438,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 7bdbd8c..5d72b79 100644
--- a/plugins/telit.c
+++ b/plugins/telit.c
@@ -408,12 +408,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,
.open = telit_sap_open,
};
@@ -483,33 +514,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] 25+ messages in thread
* [PATCH -v2 18/24] telit: improve sap disable
2011-09-13 18:58 ` [PATCH -v2 17/24] sap: add post_online handling Gustavo F. Padovan
@ 2011-09-13 18:58 ` Gustavo F. Padovan
2011-09-13 18:58 ` [PATCH -v2 19/24] sap: disconnect link if enable() fails Gustavo F. Padovan
0 siblings, 1 reply; 25+ messages in thread
From: Gustavo F. Padovan @ 2011-09-13 18:58 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 3182 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 5d72b79..47a82d9 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(struct ofono_modem *modem)
@@ -350,10 +386,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;
@@ -482,38 +518,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] 25+ messages in thread
* [PATCH -v2 19/24] sap: disconnect link if enable() fails
2011-09-13 18:58 ` [PATCH -v2 18/24] telit: improve sap disable Gustavo F. Padovan
@ 2011-09-13 18:58 ` Gustavo F. Padovan
2011-09-13 18:58 ` [PATCH -v2 20/24] sap: do a proper shutdown of the channels Gustavo F. Padovan
0 siblings, 1 reply; 25+ messages in thread
From: Gustavo F. Padovan @ 2011-09-13 18:58 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 3442 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 78b93e2..089c32f 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 e165095..c2a2281 100644
--- a/plugins/sap.c
+++ b/plugins/sap.c
@@ -182,6 +182,11 @@ static void sap_remove(struct ofono_modem *modem)
ofono_modem_set_data(modem, NULL);
}
+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;
@@ -257,7 +262,7 @@ static void sap_connect_reply(DBusPendingCall *call, gpointer user_data)
data->hw_watch = g_io_add_watch(data->hw_io, G_IO_HUP | G_IO_ERR
| G_IO_NVAL | G_IO_IN, hw_event_cb, modem);
- data->sap_driver->enable(data->hw_modem, modem);
+ data->sap_driver->enable(data->hw_modem, modem, sap_failed_cb);
done:
dbus_message_unref(reply);
diff --git a/plugins/telit.c b/plugins/telit.c
index 47a82d9..0c8061f 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(struct ofono_modem *modem)
}
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);
@@ -368,6 +373,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] 25+ messages in thread
* [PATCH -v2 20/24] sap: do a proper shutdown of the channels
2011-09-13 18:58 ` [PATCH -v2 19/24] sap: disconnect link if enable() fails Gustavo F. Padovan
@ 2011-09-13 18:58 ` Gustavo F. Padovan
2011-09-13 18:58 ` [PATCH -v2 21/24] sap: retrigger bluetooth GetProperties call Gustavo F. Padovan
0 siblings, 1 reply; 25+ messages in thread
From: Gustavo F. Padovan @ 2011-09-13 18:58 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 1983 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 c2a2281..10b2386 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>
@@ -182,9 +183,39 @@ static void sap_remove(struct ofono_modem *modem)
ofono_modem_set_data(modem, NULL);
}
+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);
+ data->bt_watch = 0;
+ }
+
+ 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);
+ data->hw_watch = 0;
+ }
+}
+
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)
@@ -244,13 +275,13 @@ static void sap_connect_reply(DBusPendingCall *call, gpointer user_data)
fd = data->sap_driver->open(data->hw_modem);
if (!fd) {
- g_io_channel_unref(data->bt_io);
+ 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;
}
@@ -295,6 +326,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] 25+ messages in thread
* [PATCH -v2 21/24] sap: retrigger bluetooth GetProperties call
2011-09-13 18:58 ` [PATCH -v2 20/24] sap: do a proper shutdown of the channels Gustavo F. Padovan
@ 2011-09-13 18:58 ` Gustavo F. Padovan
2011-09-13 18:58 ` [PATCH -v2 22/24] telit: add needed flags to proper connect the serial port Gustavo F. Padovan
0 siblings, 1 reply; 25+ messages in thread
From: Gustavo F. Padovan @ 2011-09-13 18:58 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 1593 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 9ac558e..73b8d59 100644
--- a/plugins/bluetooth.c
+++ b/plugins/bluetooth.c
@@ -896,6 +896,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 089c32f..c26a969 100644
--- a/plugins/bluetooth.h
+++ b/plugins/bluetooth.h
@@ -62,6 +62,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 10b2386..81e4e32 100644
--- a/plugins/sap.c
+++ b/plugins/sap.c
@@ -69,6 +69,8 @@ int bluetooth_sap_client_register(struct bluetooth_sap_driver *sap,
g_hash_table_insert(sap_hw_hash, modem, sap);
+ bluetooth_get_properties();
+
return 0;
}
--
1.7.6.2
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH -v2 22/24] telit: add needed flags to proper connect the serial port
2011-09-13 18:58 ` [PATCH -v2 21/24] sap: retrigger bluetooth GetProperties call Gustavo F. Padovan
@ 2011-09-13 18:58 ` Gustavo F. Padovan
2011-09-13 18:58 ` [PATCH -v2 23/24] bluetooth: track DBus call pending Gustavo F. Padovan
0 siblings, 1 reply; 25+ messages in thread
From: Gustavo F. Padovan @ 2011-09-13 18:58 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 541 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 0c8061f..467a7b6 100644
--- a/plugins/telit.c
+++ b/plugins/telit.c
@@ -350,6 +350,8 @@ static int telit_sap_open(struct ofono_modem *modem)
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] 25+ messages in thread
* [PATCH -v2 23/24] bluetooth: track DBus call pending
2011-09-13 18:58 ` [PATCH -v2 22/24] telit: add needed flags to proper connect the serial port Gustavo F. Padovan
@ 2011-09-13 18:58 ` Gustavo F. Padovan
2011-09-13 5:15 ` Denis Kenzior
2011-09-13 18:58 ` [PATCH -v2 24/24] sap: de-register DBus callback if BlueZ goes down Gustavo F. Padovan
0 siblings, 2 replies; 25+ messages in thread
From: Gustavo F. Padovan @ 2011-09-13 18:58 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 6272 bytes --]
From: "Gustavo F. Padovan" <padovan@profusion.mobi>
---
plugins/bluetooth.c | 42 +++++++++++++++++++++++-------------------
plugins/bluetooth.h | 2 +-
plugins/hfp_hf.c | 4 ++--
3 files changed, 26 insertions(+), 22 deletions(-)
diff --git a/plugins/bluetooth.c b/plugins/bluetooth.c
index 73b8d59..573c7c8 100644
--- a/plugins/bluetooth.c
+++ b/plugins/bluetooth.c
@@ -89,13 +89,13 @@ void bluetooth_create_path(const char *dev_addr, const char *adapter_addr,
}
int bluetooth_send_with_reply(const char *path, const char *interface,
- const char *method,
+ const char *method, DBusPendingCall **call,
DBusPendingCallNotifyFunction cb,
void *user_data, DBusFreeFunction free_func,
int timeout, int type, ...)
{
DBusMessage *msg;
- DBusPendingCall *call;
+ DBusPendingCall *c;
va_list args;
int err;
@@ -120,14 +120,18 @@ int bluetooth_send_with_reply(const char *path, const char *interface,
if (timeout > 0)
timeout *= 1000;
- if (!dbus_connection_send_with_reply(connection, msg, &call, timeout)) {
+ if (!dbus_connection_send_with_reply(connection, msg, &c, timeout)) {
ofono_error("Sending %s failed", method);
err = -EIO;
goto fail;
}
- dbus_pending_call_set_notify(call, cb, user_data, free_func);
- dbus_pending_call_unref(call);
+ if (call != NULL)
+ *call = c;
+
+ dbus_pending_call_set_notify(c, cb, user_data, free_func);
+ dbus_pending_call_unref(c);
+
dbus_message_unref(msg);
return 0;
@@ -379,9 +383,9 @@ static gboolean property_changed(DBusConnection *connection, DBusMessage *msg,
*/
if (uuids)
bluetooth_send_with_reply(path, BLUEZ_DEVICE_INTERFACE,
- "GetProperties", device_properties_cb,
- g_strdup(path), g_free, -1,
- DBUS_TYPE_INVALID);
+ "GetProperties", NULL,
+ device_properties_cb, g_strdup(path),
+ g_free, -1, DBUS_TYPE_INVALID);
} else if (g_str_equal(property, "Alias") == TRUE) {
const char *path = dbus_message_get_path(msg);
struct bluetooth_profile *profile;
@@ -446,9 +450,9 @@ static void adapter_properties_cb(DBusPendingCall *call, gpointer user_data)
const char *device = l->data;
bluetooth_send_with_reply(device, BLUEZ_DEVICE_INTERFACE,
- "GetProperties", device_properties_cb,
- g_strdup(device), g_free, -1,
- DBUS_TYPE_INVALID);
+ "GetProperties", NULL,
+ device_properties_cb, g_strdup(device),
+ g_free, -1, DBUS_TYPE_INVALID);
}
done:
@@ -460,7 +464,7 @@ static void get_adapter_properties(const char *path, const char *handle,
gpointer user_data)
{
bluetooth_send_with_reply(path, BLUEZ_ADAPTER_INTERFACE,
- "GetProperties", adapter_properties_cb,
+ "GetProperties", NULL, adapter_properties_cb,
g_strdup(path), g_free, -1, DBUS_TYPE_INVALID);
}
@@ -607,7 +611,7 @@ static void new_connection(GIOChannel *io, gpointer user_data)
addr = raddress;
if (bluetooth_send_with_reply(path, BLUEZ_SERVICE_INTERFACE,
- "RequestAuthorization",
+ "RequestAuthorization", NULL,
auth_cb, cbd, cb_data_destroy,
TIMEOUT, DBUS_TYPE_STRING, &addr,
DBUS_TYPE_UINT32, &server->handle,
@@ -663,7 +667,7 @@ static void add_record(gpointer data, gpointer user_data)
bluetooth_send_with_reply(adapter_any_path,
BLUEZ_SERVICE_INTERFACE, "AddRecord",
- add_record_cb, server, NULL, -1,
+ NULL, add_record_cb, server, NULL, -1,
DBUS_TYPE_STRING, &server->sdp_record,
DBUS_TYPE_INVALID);
}
@@ -703,8 +707,8 @@ static gboolean adapter_added(DBusConnection *connection, DBusMessage *message,
DBUS_TYPE_INVALID);
bluetooth_send_with_reply(path, BLUEZ_ADAPTER_INTERFACE,
- "GetProperties", adapter_properties_cb, g_strdup(path),
- g_free, -1, DBUS_TYPE_INVALID);
+ "GetProperties", NULL, adapter_properties_cb,
+ g_strdup(path), g_free, -1, DBUS_TYPE_INVALID);
return TRUE;
}
@@ -765,7 +769,7 @@ static void parse_adapters(DBusMessageIter *array, gpointer user_data)
DBG("Calling GetProperties on %s", path);
bluetooth_send_with_reply(path, BLUEZ_ADAPTER_INTERFACE,
- "GetProperties", adapter_properties_cb,
+ "GetProperties", NULL, adapter_properties_cb,
g_strdup(path), g_free, -1, DBUS_TYPE_INVALID);
dbus_message_iter_next(&value);
@@ -800,11 +804,11 @@ done:
static void bluetooth_connect(DBusConnection *connection, void *user_data)
{
bluetooth_send_with_reply("/", BLUEZ_MANAGER_INTERFACE, "GetProperties",
- manager_properties_cb, NULL, NULL, -1,
+ NULL, manager_properties_cb, NULL, NULL, -1,
DBUS_TYPE_INVALID);
bluetooth_send_with_reply("/", BLUEZ_MANAGER_INTERFACE, "FindAdapter",
- find_adapter_cb, NULL, NULL, -1,
+ NULL, find_adapter_cb, NULL, NULL, -1,
DBUS_TYPE_STRING, &adapter_any_name,
DBUS_TYPE_INVALID);
}
diff --git a/plugins/bluetooth.h b/plugins/bluetooth.h
index c26a969..c723b6e 100644
--- a/plugins/bluetooth.h
+++ b/plugins/bluetooth.h
@@ -75,7 +75,7 @@ void bluetooth_create_path(const char *dev_addr, const char *adapter_addr,
char *buf, int size);
int bluetooth_send_with_reply(const char *path, const char *interface,
- const char *method,
+ const char *method, DBusPendingCall **call,
DBusPendingCallNotifyFunction cb,
void *user_data, DBusFreeFunction free_func,
int timeout, int type, ...);
diff --git a/plugins/hfp_hf.c b/plugins/hfp_hf.c
index 717891b..3081d35 100644
--- a/plugins/hfp_hf.c
+++ b/plugins/hfp_hf.c
@@ -405,7 +405,7 @@ static int hfp_enable(struct ofono_modem *modem)
status = bluetooth_send_with_reply(data->handsfree_path,
BLUEZ_GATEWAY_INTERFACE, "Connect",
- hfp_connect_reply, modem, NULL,
+ NULL, hfp_connect_reply, modem, NULL,
DBUS_TIMEOUT, DBUS_TYPE_INVALID);
if (status < 0)
@@ -448,7 +448,7 @@ static int hfp_disable(struct ofono_modem *modem)
if (data->agent_registered) {
status = bluetooth_send_with_reply(data->handsfree_path,
BLUEZ_GATEWAY_INTERFACE, "Disconnect",
- hfp_power_down, modem, NULL,
+ NULL, hfp_power_down, modem, NULL,
DBUS_TIMEOUT, DBUS_TYPE_INVALID);
if (status < 0)
--
1.7.6.2
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH -v2 24/24] sap: de-register DBus callback if BlueZ goes down
2011-09-13 18:58 ` [PATCH -v2 23/24] bluetooth: track DBus call pending Gustavo F. Padovan
2011-09-13 5:15 ` Denis Kenzior
@ 2011-09-13 18:58 ` Gustavo F. Padovan
1 sibling, 0 replies; 25+ messages in thread
From: Gustavo F. Padovan @ 2011-09-13 18:58 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 1651 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 81e4e32..cbec028 100644
--- a/plugins/sap.c
+++ b/plugins/sap.c
@@ -59,6 +59,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,
@@ -177,6 +178,9 @@ static void sap_remove(struct ofono_modem *modem)
{
struct sap_data *data = ofono_modem_get_data(modem);
+ if (data->call != NULL)
+ dbus_pending_call_cancel(data->call);
+
g_hash_table_remove(modem_hash, data->server_path);
g_free(data->server_path);
@@ -232,6 +236,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;
@@ -305,6 +311,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";
@@ -312,13 +319,15 @@ static int sap_enable(struct ofono_modem *modem)
status = bluetooth_send_with_reply(data->server_path,
BLUEZ_SERIAL_INTERFACE, "ConnectFD",
- 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] 25+ messages in thread
end of thread, other threads:[~2011-09-13 18:58 UTC | newest]
Thread overview: 25+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-09-13 18:58 [PATCH -v2 01/24] udevng: look also to VID Gustavo F. Padovan
2011-09-13 18:58 ` [PATCH -v2 02/24] sap: add basic SAP plugin Gustavo F. Padovan
2011-09-13 18:58 ` [PATCH -v2 03/24] telit: add support to enable SAP client Gustavo F. Padovan
2011-09-13 18:58 ` [PATCH -v2 04/24] sap: add support to connect the RFCOMM link Gustavo F. Padovan
2011-09-13 18:58 ` [PATCH -v2 05/24] telit: add #RSEN notify Gustavo F. Padovan
2011-09-13 18:58 ` [PATCH -v2 06/24] sap: add watch for the Bluetooth Link Gustavo F. Padovan
2011-09-13 18:58 ` [PATCH -v2 07/24] sap: add support to open the channel for SAP data Gustavo F. Padovan
2011-09-13 18:58 ` [PATCH -v2 08/24] sap: connect the hw and the bluetooth link Gustavo F. Padovan
2011-09-13 18:58 ` [PATCH -v2 09/24] telit: add telit_sap_disable() Gustavo F. Padovan
2011-09-13 18:58 ` [PATCH -v2 10/24] sap: add support to the disable the SAP client Gustavo F. Padovan
2011-09-13 18:58 ` [PATCH -v2 11/24] telit: add aux GAtChat Gustavo F. Padovan
2011-09-13 18:58 ` [PATCH -v2 12/24] sap: enable modem only when #RSEN is 1 Gustavo F. Padovan
2011-09-13 18:58 ` [PATCH -v2 13/24] telit: enable the telit modem when SAP is enabled Gustavo F. Padovan
2011-09-13 18:58 ` [PATCH -v2 14/24] sap: add pre_sim handling Gustavo F. Padovan
2011-09-13 18:58 ` [PATCH -v2 15/24] sap: add set_online handling Gustavo F. Padovan
2011-09-13 18:58 ` [PATCH -v2 16/24] sap: add post_sim handling Gustavo F. Padovan
2011-09-13 18:58 ` [PATCH -v2 17/24] sap: add post_online handling Gustavo F. Padovan
2011-09-13 18:58 ` [PATCH -v2 18/24] telit: improve sap disable Gustavo F. Padovan
2011-09-13 18:58 ` [PATCH -v2 19/24] sap: disconnect link if enable() fails Gustavo F. Padovan
2011-09-13 18:58 ` [PATCH -v2 20/24] sap: do a proper shutdown of the channels Gustavo F. Padovan
2011-09-13 18:58 ` [PATCH -v2 21/24] sap: retrigger bluetooth GetProperties call Gustavo F. Padovan
2011-09-13 18:58 ` [PATCH -v2 22/24] telit: add needed flags to proper connect the serial port Gustavo F. Padovan
2011-09-13 18:58 ` [PATCH -v2 23/24] bluetooth: track DBus call pending Gustavo F. Padovan
2011-09-13 5:15 ` Denis Kenzior
2011-09-13 18:58 ` [PATCH -v2 24/24] sap: de-register DBus callback if BlueZ goes down Gustavo F. Padovan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox