All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/6] Add bluetooth plugin skeleton.
@ 2010-05-26  4:51 Gustavo F. Padovan
  2010-05-26  4:51 ` [PATCH 2/6] Move bluetooth utils from hfp.c to bluetooth.c Gustavo F. Padovan
  2010-05-28 14:11 ` [PATCH 1/6] Add bluetooth plugin skeleton Denis Kenzior
  0 siblings, 2 replies; 12+ messages in thread
From: Gustavo F. Padovan @ 2010-05-26  4:51 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 5909 bytes --]

The bluetooth plugin has bluetooth_resgister_uuid() and
bluetooth_unresgister_uuid() where bluetooth profiles plugins such as HFP
and DUN can register themselves to get know about BlueZ stuff ( new
devices, bluetoothd shutdown, etc..)
---
 Makefile.am         |    3 ++
 plugins/bluetooth.c |   75 +++++++++++++++++++++++++++++++++++++++++++++++++++
 plugins/bluetooth.h |   47 ++++++++++++++++++++++++++++++++
 plugins/hfp.c       |    8 +----
 4 files changed, 127 insertions(+), 6 deletions(-)
 create mode 100644 plugins/bluetooth.c
 create mode 100644 plugins/bluetooth.h

diff --git a/Makefile.am b/Makefile.am
index ed13346..e0083ef 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -231,6 +231,9 @@ builtin_sources += plugins/em770.c
 builtin_modules += novatel
 builtin_sources += plugins/novatel.c
 
+builtin_modules += bluetooth
+builtin_sources += plugins/bluetooth.c
+
 builtin_modules += hfp
 builtin_sources += plugins/hfp.c
 
diff --git a/plugins/bluetooth.c b/plugins/bluetooth.c
new file mode 100644
index 0000000..b4fe676
--- /dev/null
+++ b/plugins/bluetooth.c
@@ -0,0 +1,75 @@
+/*
+ *  oFono - Open Source Telephony
+ *
+ *  Copyright (C) 2008-2010  Intel Corporation. All rights reserved.
+ *  Copyright (C) 2010  ProFUSION embedded systems
+ *  Copyright (C) 2010 Gustavo F. Padovan <gustavo@padovan.org>
+ *
+ *  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>
+
+#include <ofono/dbus.h>
+
+#include "bluetooth.h"
+
+static DBusConnection *connection;
+static GHashTable *uuid_hash = NULL;
+static GHashTable *adapter_address_hash = NULL;
+
+int bluetooth_register_uuid(const char *uuid, struct bluetooth_profile *profile)
+{
+	if (uuid_hash)
+		goto done;
+
+	connection = ofono_dbus_get_connection();
+
+	uuid_hash = g_hash_table_new_full(g_str_hash, g_str_equal,
+						g_free, NULL);
+
+	adapter_address_hash = g_hash_table_new_full(g_str_hash, g_str_equal,
+						g_free, g_free);
+
+done:
+	g_hash_table_insert(uuid_hash, g_strdup(uuid), profile);
+
+	return 0;
+}
+
+void bluetooth_unregister_uuid(const char *uuid)
+{
+	g_hash_table_remove(uuid_hash, uuid);
+
+	if (g_hash_table_size(uuid_hash))
+		return;
+
+	g_hash_table_destroy(uuid_hash);
+	g_hash_table_destroy(adapter_address_hash);
+	uuid_hash = NULL;
+}
+
+OFONO_PLUGIN_DEFINE(bluetooth, "Bluetooth Utils Plugins", VERSION,
+			OFONO_PLUGIN_PRIORITY_DEFAULT, NULL, NULL)
diff --git a/plugins/bluetooth.h b/plugins/bluetooth.h
new file mode 100644
index 0000000..99bd617
--- /dev/null
+++ b/plugins/bluetooth.h
@@ -0,0 +1,47 @@
+/*
+ *  oFono - Open Source Telephony
+ *
+ *  Copyright (C) 2010 Gustavo F. Padovan <gustavo@padovan.org>
+ *
+ *  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
+ *
+ */
+
+#ifndef __BLUETOOTH_H
+#define __BLUETOOTH_H
+
+#define	BLUEZ_SERVICE "org.bluez"
+#define	BLUEZ_MANAGER_INTERFACE		BLUEZ_SERVICE ".Manager"
+#define	BLUEZ_ADAPTER_INTERFACE		BLUEZ_SERVICE ".Adapter"
+#define	BLUEZ_DEVICE_INTERFACE		BLUEZ_SERVICE ".Device"
+
+#define HFP_AG_UUID	"0000111F-0000-1000-8000-00805F9B34FB"
+#define DUN_GW_UUID	"00001103-0000-1000-8000-00805F9B34FB"
+
+/* Profiles bitfield */
+#define HFP_AG 0x01
+#define DUN_GW 0x02
+
+struct bluetooth_profile {
+	const char *name;
+	int (*create)(const char *device, const char *dev_addr, const char *adapter_addr, const char *alias);
+	void (*remove_all)();
+	void (*set_alias)(const char *device, const char *);
+};
+
+int bluetooth_register_uuid(const char *uuid, struct bluetooth_profile *profile);
+void bluetooth_unregister_uuid(const char *uuid);
+
+
+#endif /* __BLUETOOTH_H */
diff --git a/plugins/hfp.c b/plugins/hfp.c
index e37c9fc..a49e4af 100644
--- a/plugins/hfp.c
+++ b/plugins/hfp.c
@@ -45,17 +45,13 @@
 
 #include <ofono/dbus.h>
 
-#define	BLUEZ_SERVICE "org.bluez"
-#define	BLUEZ_MANAGER_INTERFACE		BLUEZ_SERVICE ".Manager"
-#define	BLUEZ_ADAPTER_INTERFACE		BLUEZ_SERVICE ".Adapter"
-#define	BLUEZ_DEVICE_INTERFACE		BLUEZ_SERVICE ".Device"
+#include "bluetooth.h"
+
 #define	BLUEZ_GATEWAY_INTERFACE		BLUEZ_SERVICE ".HandsfreeGateway"
 
 #define HFP_AGENT_INTERFACE "org.bluez.HandsfreeAgent"
 #define HFP_AGENT_ERROR_INTERFACE "org.bluez.Error"
 
-#define HFP_AG_UUID	"0000111F-0000-1000-8000-00805F9B34FB"
-
 #ifndef DBUS_TYPE_UNIX_FD
 #define DBUS_TYPE_UNIX_FD -1
 #endif
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread
* [PATCH 4/6] Move create_path() to bluetooth plugin
@ 2010-05-17  2:11 Gustavo F. Padovan
  2010-05-17  2:11 ` [PATCH 5/6] Change hfpmodem's header define Gustavo F. Padovan
  0 siblings, 1 reply; 12+ messages in thread
From: Gustavo F. Padovan @ 2010-05-17  2:11 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 3143 bytes --]

---
 plugins/bluetooth.c |   22 ++++++++++++++++++++++
 plugins/bluetooth.h |    1 +
 plugins/hfp.c       |   25 +------------------------
 3 files changed, 24 insertions(+), 24 deletions(-)

diff --git a/plugins/bluetooth.c b/plugins/bluetooth.c
index fc89579..49d1b5e 100644
--- a/plugins/bluetooth.c
+++ b/plugins/bluetooth.c
@@ -40,6 +40,28 @@ static DBusConnection *connection;
 static GHashTable *uuid_hash = NULL;
 static GHashTable *adapter_address_hash = NULL;
 
+void bluetooth_create_path(const char *dev_addr, const char *adapter_addr, char *buf, int size)
+{
+	int i, j;
+
+	for (i = 0, j = 0; adapter_addr[j] && i < size - 1; j++)
+		if (adapter_addr[j] >= '0' && adapter_addr[j] <= '9')
+			buf[i++] = adapter_addr[j];
+		else if (adapter_addr[j] >= 'A' && adapter_addr[j] <= 'F')
+			buf[i++] = adapter_addr[j];
+
+	if (i < size - 1)
+		buf[i++] = '_';
+
+	for (j = 0; dev_addr[j] && i < size - 1; j++)
+		if (dev_addr[j] >= '0' && dev_addr[j] <= '9')
+			buf[i++] = dev_addr[j];
+		else if (dev_addr[j] >= 'A' && dev_addr[j] <= 'F')
+			buf[i++] = dev_addr[j];
+
+	buf[i] = '\0';
+}
+
 static int send_method_call_with_reply(const char *dest, const char *path,
 				const char *interface, const char *method,
 				DBusPendingCallNotifyFunction cb,
diff --git a/plugins/bluetooth.h b/plugins/bluetooth.h
index 99bd617..4019daa 100644
--- a/plugins/bluetooth.h
+++ b/plugins/bluetooth.h
@@ -43,5 +43,6 @@ struct bluetooth_profile {
 int bluetooth_register_uuid(const char *uuid, struct bluetooth_profile *profile);
 void bluetooth_unregister_uuid(const char *uuid);
 
+void bluetooth_create_path(const char *dev_addr, const char *adapter_addr, char *buf, int size);
 
 #endif /* __BLUETOOTH_H */
diff --git a/plugins/hfp.c b/plugins/hfp.c
index 6fd3464..c2b3711 100644
--- a/plugins/hfp.c
+++ b/plugins/hfp.c
@@ -448,29 +448,6 @@ static GDBusMethodTable agent_methods[] = {
 	{ NULL, NULL, NULL, NULL }
 };
 
-static void create_path(const char *dev_addr, const char *adapter_addr,
-			char *buf, int size)
-{
-	int i, j;
-
-	for (i = 0, j = 0; adapter_addr[j] && i < size - 1; j++)
-		if (adapter_addr[j] >= '0' && adapter_addr[j] <= '9')
-			buf[i++] = adapter_addr[j];
-		else if (adapter_addr[j] >= 'A' && adapter_addr[j] <= 'F')
-			buf[i++] = adapter_addr[j];
-
-	if (i < size - 1)
-		buf[i++] = '_';
-
-	for (j = 0; dev_addr[j] && i < size - 1; j++)
-		if (dev_addr[j] >= '0' && dev_addr[j] <= '9')
-			buf[i++] = dev_addr[j];
-		else if (dev_addr[j] >= 'A' && dev_addr[j] <= 'F')
-			buf[i++] = dev_addr[j];
-
-	buf[i] = '\0';
-}
-
 static int hfp_create_modem(const char *device, const char *dev_addr,
 				const char *adapter_addr, const char *alias)
 {
@@ -486,7 +463,7 @@ static int hfp_create_modem(const char *device, const char *dev_addr,
 			device, dev_addr, adapter_addr);
 
 	strcpy(buf, "hfp/");
-	create_path(dev_addr, adapter_addr, buf + 4, sizeof(buf) - 4);
+	bluetooth_create_path(dev_addr, adapter_addr, buf + 4, sizeof(buf) - 4);
 
 	modem = ofono_modem_create(buf, "hfp");
 	if (modem == NULL)
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2010-05-31 15:51 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-26  4:51 [PATCH 1/6] Add bluetooth plugin skeleton Gustavo F. Padovan
2010-05-26  4:51 ` [PATCH 2/6] Move bluetooth utils from hfp.c to bluetooth.c Gustavo F. Padovan
2010-05-26  4:51   ` [PATCH 3/6] Remove send_method_call from hfp.c Gustavo F. Padovan
2010-05-26  4:51     ` [PATCH 4/6] Move create_path() to bluetooth plugin Gustavo F. Padovan
2010-05-26  4:51       ` [PATCH 5/6] Change hfpmodem's header define Gustavo F. Padovan
2010-05-26  4:51         ` [PATCH 6/6] Bluetooth DUN modem prototype Gustavo F. Padovan
2010-05-28 14:19           ` Denis Kenzior
2010-05-28 14:13         ` [PATCH 5/6] Change hfpmodem's header define Denis Kenzior
2010-05-28 14:11 ` [PATCH 1/6] Add bluetooth plugin skeleton Denis Kenzior
2010-05-31 11:59   ` Kalle Valo
2010-05-31 15:51     ` Marcel Holtmann
  -- strict thread matches above, loose matches on Subject: below --
2010-05-17  2:11 [PATCH 4/6] Move create_path() to bluetooth plugin Gustavo F. Padovan
2010-05-17  2:11 ` [PATCH 5/6] Change hfpmodem's header define Gustavo F. Padovan

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.