summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2008-05-28 13:11:05 +0000
committerMarcel Holtmann <marcel@holtmann.org>2008-05-28 13:11:05 +0000
commit24cce397c3479e95f3e525da9285234fbafd2984 (patch)
tree135f016d9783863e5a3c227dba3d678771003e25
parent7c426c4c7e234e28a4dffcb7d88feb0eeefcd5ce (diff)
Add first skeletion of device driver integration
-rw-r--r--hcid/device.c20
-rw-r--r--hcid/device.h12
-rw-r--r--serial/main.c25
3 files changed, 57 insertions, 0 deletions
diff --git a/hcid/device.c b/hcid/device.c
index 850ce1af..f8550b4a 100644
--- a/hcid/device.c
+++ b/hcid/device.c
@@ -1163,3 +1163,23 @@ int device_browse(struct device *device, DBusConnection *conn,
str2ba(device->address, &dst);
return bt_discover_services(&src, &dst, browse_cb, req, NULL);
}
+
+static GSList *drivers = NULL;
+
+int btd_register_device_driver(struct btd_device_driver *driver)
+{
+ const char **uuid;
+
+ drivers = g_slist_append(drivers, driver);
+
+ for (uuid = driver->uuids; *uuid; uuid++) {
+ debug("name %s uuid %s", driver->name, *uuid);
+ }
+
+ return 0;
+}
+
+void btd_unregister_device_driver(struct btd_device_driver *driver)
+{
+ drivers = g_slist_remove(drivers, driver);
+}
diff --git a/hcid/device.h b/hcid/device.h
index 4bfa9feb..5ef524df 100644
--- a/hcid/device.h
+++ b/hcid/device.h
@@ -39,3 +39,15 @@ void device_remove(struct device *device, DBusConnection *conn);
gint device_address_cmp(struct device *device, const gchar *address);
int device_browse(struct device *device, DBusConnection *conn,
DBusMessage *msg);
+
+#define BTD_UUIDS(args...) ((const char *[]) { args, NULL } )
+
+struct btd_device_driver {
+ const char *name;
+ const char **uuids;
+ int (*probe) (const char *path);
+ void (*remove) (const char *path);
+};
+
+int btd_register_device_driver(struct btd_device_driver *driver);
+void btd_unregister_device_driver(struct btd_device_driver *driver);
diff --git a/serial/main.c b/serial/main.c
index b4533a01..24de70a5 100644
--- a/serial/main.c
+++ b/serial/main.c
@@ -35,11 +35,32 @@
#include <dbus/dbus.h>
#include "plugin.h"
+#include "device.h"
+#include "logging.h"
#include "dbus-service.h"
#include "manager.h"
static DBusConnection *conn;
+static int serial_probe(const char *path)
+{
+ debug("path %s", path);
+
+ return 0;
+}
+
+static void serial_remove(const char *path)
+{
+ debug("path %s", path);
+}
+
+static struct btd_device_driver serial_driver = {
+ .name = "serial",
+ .uuids = BTD_UUIDS("spp", "dun"),
+ .probe = serial_probe,
+ .remove = serial_remove,
+};
+
static int serial_init(void)
{
conn = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
@@ -53,11 +74,15 @@ static int serial_init(void)
register_service("serial", NULL);
+ btd_register_device_driver(&serial_driver);
+
return 0;
}
static void serial_exit(void)
{
+ btd_unregister_device_driver(&serial_driver);
+
unregister_service("serial");
serial_manager_exit();