[PATCH -v4 01/21] udevng: look also to VID
by Gustavo F. Padovan
From: "Gustavo F. Padovan" <padovan(a)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
9 years, 4 months
[PATCH -v3 01/23] udevng: look also to VID
by Gustavo F. Padovan
From: "Gustavo F. Padovan" <padovan(a)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
9 years, 4 months
[PATCH -v6] sap: Add basic sap plugin
by Gustavo F. Padovan
From: "Gustavo F. Padovan" <padovan(a)profusion.mobi>
---
Makefile.am | 3 +
plugins/bluetooth.c | 1 -
plugins/bluetooth.h | 12 ++
plugins/hfp_hf.c | 2 -
plugins/sap.c | 288 +++++++++++++++++++++++++++++++++++++++++++++++++++
plugins/telit.c | 10 ++
6 files changed, 313 insertions(+), 3 deletions(-)
create mode 100644 plugins/sap.c
diff --git a/Makefile.am b/Makefile.am
index 71962ea..8771cb2 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -369,6 +369,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 a286dd4..274d25b 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 4056f0a..b21ab64 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 0c6ed83..d5f26c0 100644
--- a/plugins/hfp_hf.c
+++ b/plugins/hfp_hf.c
@@ -45,8 +45,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..bdded70
--- /dev/null
+++ b/plugins/sap.c
@@ -0,0 +1,288 @@
+/*
+ *
+ * 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 struct ofono_modem *sap_hw_modem = NULL;
+static struct bluetooth_sap_driver *sap_hw_driver = NULL;
+
+struct sap_data {
+ char *server_path;
+ struct ofono_modem *hw_modem;
+ struct bluetooth_sap_driver *sap_driver;
+};
+
+int bluetooth_sap_client_register(struct bluetooth_sap_driver *sap,
+ struct ofono_modem *modem)
+{
+ if (sap_hw_modem != NULL)
+ return -EPERM;
+
+ sap_hw_modem = modem;
+ sap_hw_driver = sap;
+
+ return 0;
+}
+
+static void sap_remove_modem(struct ofono_modem *modem)
+{
+ struct sap_data *data = ofono_modem_get_data(modem);
+
+ g_free(data->server_path);
+ g_free(data);
+
+ ofono_modem_set_data(modem, NULL);
+
+ ofono_modem_remove(modem);
+}
+
+static void sap_remove_all_modem(void)
+{
+ GHashTableIter iter;
+ gpointer key, value;
+
+ g_hash_table_iter_init(&iter, modem_hash);
+
+ while (g_hash_table_iter_next(&iter, &key, &value)) {
+
+ g_hash_table_iter_remove(&iter);
+
+ sap_remove_modem(value);
+ }
+}
+
+void bluetooth_sap_client_unregister(struct ofono_modem *modem)
+{
+ if (sap_hw_modem == NULL)
+ return;
+
+ sap_remove_all_modem();
+
+ sap_hw_modem = NULL;
+ sap_hw_driver = NULL;
+}
+
+static int sap_probe(struct ofono_modem *modem)
+{
+ DBG("%p", modem);
+
+ return 0;
+}
+
+static void sap_remove(struct ofono_modem *modem)
+{
+ DBG("%p", modem);
+}
+
+/* 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];
+
+ if(sap_hw_modem == NULL)
+ return -ENODEV;
+
+ /* We already have this device in our hash, ignore */
+ if (g_hash_table_lookup(modem_hash, device) != NULL)
+ return -EALREADY;
+
+ 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;
+
+ 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);
+
+ return 0;
+
+free:
+ g_free(data);
+ ofono_modem_remove(modem);
+
+ return -ENOMEM;
+}
+
+static void bluetooth_sap_remove(const char *prefix)
+{
+ GHashTableIter iter;
+ gpointer key, value;
+
+ DBG("%s", prefix);
+
+ if (modem_hash == NULL)
+ return;
+
+ if (prefix == NULL) {
+ sap_remove_all_modem();
+ return;
+ }
+
+ g_hash_table_iter_init(&iter, modem_hash);
+
+ while (g_hash_table_iter_next(&iter, &key, &value)) {
+
+ if (!g_str_equal(prefix, (char *)key))
+ continue;
+
+ g_hash_table_iter_remove(&iter);
+
+ sap_remove_modem(value);
+ return;
+ }
+}
+
+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);
+
+ return 0;
+}
+
+static void sap_exit(void)
+{
+ DBG("");
+
+ bluetooth_unregister_uuid(SAP_UUID);
+ ofono_modem_driver_unregister(&sap_driver);
+ 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
9 years, 4 months
[PATCH 00/12] Bluetooth HFP-specific extensions
by Mikel Astiz
Hi,
Here you have my first proposals to add a new atom to support HFP-specific
capabilities, and the corresponding implementation in hfpmodem. Only some of
these extensions have been included in this series. Hope this fits the ideas
discussed in the mailing list.
Looking forward to your review,
Mikel
Mikel Astiz (12):
TODO: Task added for HFP-specific capabilities
Add handsfree atom for HFP-specific capabilities
hfpmodem: Driver implements handsfree atom
hfp_hf: Plugin creates handsfree atom
handsfree: Atom supports inband ringing status
hfpmodem: Support for +BSIR unsol. result codes
handsfree: Support for number requests (AT+BINP=1)
handsfree: Expose RequestInput in D-Bus API
hfpmodem: Support of number requests (AT+BINP=1)
handsfree: Read-only voice-recognition D-Bus prop
handsfree: Writable voice-recogn. prop (AT+BVRA)
hfpmodem: Support for AT+BVRA
Makefile.am | 9 +-
TODO | 11 ++
drivers/hfpmodem/handsfree.c | 223 ++++++++++++++++++++++++
drivers/hfpmodem/hfpmodem.c | 2 +
drivers/hfpmodem/hfpmodem.h | 3 +
include/dbus.h | 1 +
include/handsfree.h | 74 ++++++++
plugins/hfp_hf.c | 2 +
src/handsfree.c | 385 ++++++++++++++++++++++++++++++++++++++++++
src/ofono.h | 1 +
10 files changed, 708 insertions(+), 3 deletions(-)
create mode 100644 drivers/hfpmodem/handsfree.c
create mode 100644 include/handsfree.h
create mode 100644 src/handsfree.c
--
1.7.6
9 years, 4 months
[PATCH -v5] sap: add basic sap plugin
by Gustavo F. Padovan
From: "Gustavo F. Padovan" <padovan(a)profusion.mobi>
---
Makefile.am | 3 +
plugins/bluetooth.c | 1 -
plugins/bluetooth.h | 12 +++
plugins/hfp_hf.c | 2 -
plugins/sap.c | 266 +++++++++++++++++++++++++++++++++++++++++++++++++++
plugins/telit.c | 10 ++
6 files changed, 291 insertions(+), 3 deletions(-)
create mode 100644 plugins/sap.c
diff --git a/Makefile.am b/Makefile.am
index 71962ea..8771cb2 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -369,6 +369,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 a286dd4..274d25b 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 4056f0a..b21ab64 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 0c6ed83..d5f26c0 100644
--- a/plugins/hfp_hf.c
+++ b/plugins/hfp_hf.c
@@ -45,8 +45,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..daf1f97
--- /dev/null
+++ b/plugins/sap.c
@@ -0,0 +1,266 @@
+/*
+ *
+ * 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 struct ofono_modem *sap_hw_modem = NULL;
+static struct bluetooth_sap_driver *sap_hw_driver = NULL;
+
+struct sap_data {
+ char *server_path;
+ struct ofono_modem *hw_modem;
+ struct bluetooth_sap_driver *sap_driver;
+};
+
+int bluetooth_sap_client_register(struct bluetooth_sap_driver *sap,
+ struct ofono_modem *modem)
+{
+ if (sap_hw_modem != NULL)
+ return -EPERM;
+
+ sap_hw_modem = modem;
+ sap_hw_driver = sap;
+
+ return 0;
+}
+
+static gboolean sap_remove_modem(gpointer data)
+{
+ GHashTableIter iter;
+ gpointer key, value;
+
+ g_hash_table_iter_init(&iter, modem_hash);
+
+ while (g_hash_table_iter_next(&iter, &key, &value)) {
+ struct ofono_modem *modem = value;
+ struct sap_data *data = ofono_modem_get_data(modem);
+
+ g_hash_table_iter_remove(&iter);
+
+ g_free(data->server_path);
+ g_free(data);
+
+ ofono_modem_set_data(modem, NULL);
+
+ ofono_modem_remove(modem);
+ }
+
+ return FALSE;
+}
+
+void bluetooth_sap_client_unregister(struct ofono_modem *modem)
+{
+ if (sap_hw_modem == NULL)
+ return;
+
+ sap_remove_modem(NULL);
+
+ sap_hw_modem = NULL;
+ sap_hw_driver = NULL;
+}
+
+static int sap_probe(struct ofono_modem *modem)
+{
+ DBG("%p", modem);
+
+ return 0;
+}
+
+static void sap_remove(struct ofono_modem *modem)
+{
+ DBG("%p", modem);
+}
+
+/* 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];
+
+ if(sap_hw_modem == NULL)
+ return -ENODEV;
+
+ /* We already have this device in our hash, ignore */
+ if (g_hash_table_lookup(modem_hash, device) != NULL)
+ return -EALREADY;
+
+ 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;
+
+ 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);
+
+ return 0;
+
+free:
+ g_free(data);
+ ofono_modem_remove(modem);
+
+ return -ENOMEM;
+}
+
+static void bluetooth_sap_remove(const char *prefix)
+{
+ DBG("%s", prefix);
+
+ if (modem_hash == NULL)
+ return;
+
+ sap_remove_modem(NULL);
+}
+
+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);
+
+ return 0;
+}
+
+static void sap_exit(void)
+{
+ DBG("");
+
+ bluetooth_unregister_uuid(SAP_UUID);
+ ofono_modem_driver_unregister(&sap_driver);
+ 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
9 years, 4 months
[[PATCH -v4]] sap: add basic SAP plugin
by Gustavo F. Padovan
From: "Gustavo F. Padovan" <padovan(a)profusion.mobi>
---
Makefile.am | 3 +
plugins/bluetooth.c | 1 -
plugins/bluetooth.h | 12 ++
plugins/hfp_hf.c | 2 -
plugins/sap.c | 286 +++++++++++++++++++++++++++++++++++++++++++++++++++
plugins/telit.c | 10 ++
6 files changed, 311 insertions(+), 3 deletions(-)
create mode 100644 plugins/sap.c
diff --git a/Makefile.am b/Makefile.am
index 71962ea..8771cb2 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -369,6 +369,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 a286dd4..274d25b 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 4056f0a..b21ab64 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 0c6ed83..d5f26c0 100644
--- a/plugins/hfp_hf.c
+++ b/plugins/hfp_hf.c
@@ -45,8 +45,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..b55f712
--- /dev/null
+++ b/plugins/sap.c
@@ -0,0 +1,286 @@
+/*
+ *
+ * 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 struct ofono_modem *sap_hw_modem = NULL;
+static struct bluetooth_sap_driver *sap_hw_driver = NULL;
+
+struct sap_data {
+ char *server_path;
+ struct ofono_modem *hw_modem;
+ struct bluetooth_sap_driver *sap_driver;
+};
+
+int bluetooth_sap_client_register(struct bluetooth_sap_driver *sap,
+ struct ofono_modem *modem)
+{
+ if (sap_hw_modem != NULL)
+ return -EPERM;
+
+ sap_hw_modem = modem;
+ sap_hw_driver = sap;
+
+ return 0;
+}
+
+static gboolean _remove_modem(gpointer data)
+{
+ GHashTableIter iter;
+ gpointer key, value;
+
+ g_hash_table_iter_init(&iter, modem_hash);
+
+ while (g_hash_table_iter_next(&iter, &key, &value)) {
+ struct ofono_modem *modem = value;
+
+ g_hash_table_iter_remove(&iter);
+
+ ofono_modem_remove(modem);
+ }
+
+ return FALSE;
+}
+
+void bluetooth_sap_client_unregister(struct ofono_modem *modem)
+{
+ if (sap_hw_modem == NULL)
+ return;
+
+ g_idle_add(_remove_modem, NULL);
+
+ sap_hw_modem = NULL;
+ sap_hw_driver = NULL;
+}
+
+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];
+
+ if(sap_hw_modem == NULL)
+ return -ENODEV;
+
+ /* We already have this device in our hash, ignore */
+ if (g_hash_table_lookup(modem_hash, device) != NULL)
+ return -EALREADY;
+
+ 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 = sap_hw_modem;
+ data->sap_driver = sap_hw_driver;
+
+ 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);
+
+ 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);
+
+ return 0;
+}
+
+static void sap_exit(void)
+{
+ DBG("");
+
+ bluetooth_unregister_uuid(SAP_UUID);
+ ofono_modem_driver_unregister(&sap_driver);
+ 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
9 years, 4 months
[[PATCH -v4]] sap: add basic SAP plugin
by Gustavo F. Padovan
From: "Gustavo F. Padovan" <padovan(a)profusion.mobi>
---
Makefile.am | 3 +
plugins/bluetooth.c | 1 -
plugins/bluetooth.h | 12 ++
plugins/hfp_hf.c | 2 -
plugins/sap.c | 286 +++++++++++++++++++++++++++++++++++++++++++++++++++
plugins/telit.c | 10 ++
6 files changed, 311 insertions(+), 3 deletions(-)
create mode 100644 plugins/sap.c
diff --git a/Makefile.am b/Makefile.am
index 71962ea..8771cb2 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -369,6 +369,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 a286dd4..274d25b 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 4056f0a..b21ab64 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 0c6ed83..d5f26c0 100644
--- a/plugins/hfp_hf.c
+++ b/plugins/hfp_hf.c
@@ -45,8 +45,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..b55f712
--- /dev/null
+++ b/plugins/sap.c
@@ -0,0 +1,286 @@
+/*
+ *
+ * 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 struct ofono_modem *sap_hw_modem = NULL;
+static struct bluetooth_sap_driver *sap_hw_driver = NULL;
+
+struct sap_data {
+ char *server_path;
+ struct ofono_modem *hw_modem;
+ struct bluetooth_sap_driver *sap_driver;
+};
+
+int bluetooth_sap_client_register(struct bluetooth_sap_driver *sap,
+ struct ofono_modem *modem)
+{
+ if (sap_hw_modem != NULL)
+ return -EPERM;
+
+ sap_hw_modem = modem;
+ sap_hw_driver = sap;
+
+ return 0;
+}
+
+static gboolean _remove_modem(gpointer data)
+{
+ GHashTableIter iter;
+ gpointer key, value;
+
+ g_hash_table_iter_init(&iter, modem_hash);
+
+ while (g_hash_table_iter_next(&iter, &key, &value)) {
+ struct ofono_modem *modem = value;
+
+ g_hash_table_iter_remove(&iter);
+
+ ofono_modem_remove(modem);
+ }
+
+ return FALSE;
+}
+
+void bluetooth_sap_client_unregister(struct ofono_modem *modem)
+{
+ if (sap_hw_modem == NULL)
+ return;
+
+ g_idle_add(_remove_modem, NULL);
+
+ sap_hw_modem = NULL;
+ sap_hw_driver = NULL;
+}
+
+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];
+
+ if(sap_hw_modem == NULL)
+ return -ENODEV;
+
+ /* We already have this device in our hash, ignore */
+ if (g_hash_table_lookup(modem_hash, device) != NULL)
+ return -EALREADY;
+
+ 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 = sap_hw_modem;
+ data->sap_driver = sap_hw_driver;
+
+ 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);
+
+ 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);
+
+ return 0;
+}
+
+static void sap_exit(void)
+{
+ DBG("");
+
+ bluetooth_unregister_uuid(SAP_UUID);
+ ofono_modem_driver_unregister(&sap_driver);
+ 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
9 years, 4 months
[PATCH -v3 02/23] sap: add basic SAP plugin
by Gustavo F. Padovan
From: "Gustavo F. Padovan" <padovan(a)profusion.mobi>
---
Makefile.am | 3 +
plugins/bluetooth.c | 1 -
plugins/bluetooth.h | 12 ++
plugins/hfp_hf.c | 2 -
plugins/sap.c | 289 +++++++++++++++++++++++++++++++++++++++++++++++++++
plugins/telit.c | 10 ++
6 files changed, 314 insertions(+), 3 deletions(-)
create mode 100644 plugins/sap.c
diff --git a/Makefile.am b/Makefile.am
index 71962ea..8771cb2 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -369,6 +369,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 a286dd4..274d25b 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 4056f0a..b21ab64 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 0c6ed83..d5f26c0 100644
--- a/plugins/hfp_hf.c
+++ b/plugins/hfp_hf.c
@@ -45,8 +45,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..24345f5
--- /dev/null
+++ b/plugins/sap.c
@@ -0,0 +1,289 @@
+/*
+ *
+ * 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 struct ofono_modem *sap_hw_modem = NULL;
+static struct bluetooth_sap_driver *sap_hw_driver = NULL;
+
+struct sap_data {
+ char *server_path;
+ struct ofono_modem *hw_modem;
+ struct bluetooth_sap_driver *sap_driver;
+};
+
+int bluetooth_sap_client_register(struct bluetooth_sap_driver *sap,
+ struct ofono_modem *modem)
+{
+ if (sap_hw_modem != NULL)
+ return -EPERM;
+
+ sap_hw_modem = modem;
+ sap_hw_driver = 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 (sap_hw_modem == NULL || sap_hw_modem != modem)
+ 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 *data = ofono_modem_get_data(sap_modem);
+
+ if (sap_hw_modem != data->hw_modem)
+ continue;
+
+ g_idle_add(_remove_modem, sap_modem);
+
+ break;
+ }
+
+ sap_hw_modem = NULL;
+ sap_hw_driver = NULL;
+}
+
+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];
+
+ /* We already have this device in our hash, ignore */
+ if (g_hash_table_lookup(modem_hash, device) != NULL)
+ return -EALREADY;
+
+ 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 = sap_hw_modem;
+ data->sap_driver = sap_hw_driver;
+
+ 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);
+
+ 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);
+
+ return 0;
+}
+
+static void sap_exit(void)
+{
+ DBG("");
+
+ bluetooth_unregister_uuid(SAP_UUID);
+ ofono_modem_driver_unregister(&sap_driver);
+ 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
9 years, 4 months
Udev detection broken?
by Artem Makhutov
Hello,
I am trying to setup ofono on my PC again, unfortunatly ofono does not pick up the connected huawei modem.
I have traced it down to plugins/udev.c - get_property function.
The udev rules seems to get ok, as I can see it in the udev logs:
UDEV_LOG=3
ACTION=add
DEVPATH=/devices/pci0000:00/0000:00:02.1/usb1/1-3
SUBSYSTEM=usb
DEVNAME=/dev/bus/usb/001/016
DEVTYPE=usb_device
DEVICE=/proc/bus/usb/001/016
PRODUCT=12d1/1001/0
TYPE=0/0/0
BUSNUM=001
DEVNUM=016
SEQNUM=9847
ID_VENDOR=HUAWEI_Technology
ID_VENDOR_ENC=HUAWEI\x20Technology
ID_VENDOR_ID=12d1
ID_MODEL=HUAWEI_Mobile
ID_MODEL_ENC=HUAWEI\x20Mobile
ID_MODEL_ID=1001
ID_REVISION=0000
ID_SERIAL=HUAWEI_Technology_HUAWEI_Mobile
ID_BUS=usb
ID_USB_INTERFACES=:ffffff:
OFONO_DRIVER=huawei
MAJOR=189
MINOR=15
But get_property can not find the "OFONO_DRIVER" property.
It only find the properties below:
Sep 14 23:45:56 gandalf ofonod[19789]: plugins/udev.c:get_property() Name:UDEV_LOG
Sep 14 23:45:56 gandalf ofonod[19789]: plugins/udev.c:get_property() Name:DEVPATH
Sep 14 23:45:56 gandalf ofonod[19789]: plugins/udev.c:get_property() Name:MAJOR
Sep 14 23:45:56 gandalf ofonod[19789]: plugins/udev.c:get_property() Name:MINOR
Sep 14 23:45:56 gandalf ofonod[19789]: plugins/udev.c:get_property() Name:DEVNAME
Sep 14 23:45:56 gandalf ofonod[19789]: plugins/udev.c:get_property() Name:DEVTYPE
Sep 14 23:45:56 gandalf ofonod[19789]: plugins/udev.c:get_property() Name:DRIVER
Sep 14 23:45:56 gandalf ofonod[19789]: plugins/udev.c:get_property() Name:DEVICE
Sep 14 23:45:56 gandalf ofonod[19789]: plugins/udev.c:get_property() Name:PRODUCT
Sep 14 23:45:56 gandalf ofonod[19789]: plugins/udev.c:get_property() Name:TYPE
Sep 14 23:45:56 gandalf ofonod[19789]: plugins/udev.c:get_property() Name:BUSNUM
Sep 14 23:45:56 gandalf ofonod[19789]: plugins/udev.c:get_property() Name:DEVNUM
Sep 14 23:45:56 gandalf ofonod[19789]: plugins/udev.c:get_property() Name:SUBSYSTEM
Any ideas why it does not find some properties?
Thanks, Artem
9 years, 4 months
[PATCHv6 0/3] Mobile broadband provider info plugin
by Oleg Zhurakivskyy
Hello,
Please find the mobile broadband provider info plugin ("Internet Access Provider database" TODO item).
If enabled, the plugin reads mobile-broadband-provider-info database entries (PROVIDER_DATABASE) and returns GRPS context settings to oFono provisioning module.
Regards,
Oleg
Oleg Zhurakivskyy (3):
Mobile broadband provider info plugin makefile changes
Mobile broadband provider info plugin autoconf support
Mobile broadband provider info plugin
Makefile.am | 7 +
configure.ac | 19 +-
plugins/mobile-broadband-provider-info.c | 804 ++++++++++++++++++++++++++++++
3 files changed, 824 insertions(+), 6 deletions(-)
create mode 100644 plugins/mobile-broadband-provider-info.c
--
1.7.4.1
9 years, 4 months