Initial support for HDP plugin

This commit is contained in:
Santiago Carot-Nemesio 2010-07-27 16:11:29 +02:00
parent 5c66d6f066
commit 2792e639a9
8 changed files with 340 additions and 1 deletions

View File

@ -196,6 +196,13 @@ builtin_sources += attrib/main.c \
attrib/example.h attrib/example.c
endif
if HEALTHPLUGIN
builtin_modules += health
builtin_sources += health/hdp_main.c health/hdp_types.h \
health/hdp_manager.h health/hdp_manager.c \
health/hdp.h health/hdp.c
endif
builtin_modules += hciops
builtin_sources += plugins/hciops.c

View File

@ -175,6 +175,7 @@ AC_DEFUN([AC_ARG_BLUEZ], [
serial_enable=yes
network_enable=yes
service_enable=yes
health_enable=no
mcap_enable=no
pnat_enable=no
attrib_enable=no
@ -226,6 +227,10 @@ AC_DEFUN([AC_ARG_BLUEZ], [
service_enable=${enableval}
])
AC_ARG_ENABLE(health, AC_HELP_STRING([--enable-health], [enable health plugin]), [
health_enable=${enableval}
])
AC_ARG_ENABLE(mcap, AC_HELP_STRING([--enable-mcap], [enable mcap support]), [
mcap_enable=${enableval}
])
@ -352,7 +357,8 @@ AC_DEFUN([AC_ARG_BLUEZ], [
AM_CONDITIONAL(SERIALPLUGIN, test "${serial_enable}" = "yes")
AM_CONDITIONAL(NETWORKPLUGIN, test "${network_enable}" = "yes")
AM_CONDITIONAL(SERVICEPLUGIN, test "${service_enable}" = "yes")
AM_CONDITIONAL(MCAP, test "${mcap_enable}" = "yes")
AM_CONDITIONAL(HEALTHPLUGIN, test "${health_enable}" = "yes")
AM_CONDITIONAL(MCAP, test "${mcap_enable}" = "yes" || test "${health_enable}" = "yes")
AM_CONDITIONAL(HAL, test "${hal_enable}" = "yes")
AM_CONDITIONAL(ATTRIBPLUGIN, test "${attrib_enable}" = "yes")
AM_CONDITIONAL(ECHOPLUGIN, test "no" = "yes")

72
health/hdp.c Normal file
View File

@ -0,0 +1,72 @@
/*
*
* BlueZ - Bluetooth protocol stack for Linux
*
* Copyright (C) 2010 GSyC/LibreSoft, Universidad Rey Juan Carlos.
* Authors:
* Santiago Carot Nemesio <sancane at gmail.com>
* Jose Antonio Santos-Cadenas <santoscadenas at gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* 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
*
*/
#include <gdbus.h>
#include "log.h"
#include <adapter.h>
#include <device.h>
int hdp_adapter_register(DBusConnection *conn, struct btd_adapter *adapter)
{
const char *path = adapter_get_path(adapter);
DBG("New health adapter %s", path);
return 0;
}
void hdp_adapter_unregister(struct btd_adapter *adapter)
{
const char *path = adapter_get_path(adapter);
DBG("Health adapter %s removed", path);
}
int hdp_device_register(DBusConnection *conn, struct btd_device *device)
{
const char *path = device_get_path(device);
DBG("New health device %s", path);
return 0;
}
void hdp_device_unregister(struct btd_device *device)
{
const char *path = device_get_path(device);
DBG("Health device %s removed", path);
}
int hdp_manager_start(DBusConnection *conn)
{
DBG("Starting Health manager");
return 0;
}
void hdp_manager_stop()
{
DBG("Stopped Health manager");
}

33
health/hdp.h Normal file
View File

@ -0,0 +1,33 @@
/*
*
* BlueZ - Bluetooth protocol stack for Linux
*
* Copyright (C) 2010 GSyC/LibreSoft, Universidad Rey Juan Carlos.
* Authors:
* Santiago Carot Nemesio <sancane at gmail.com>
* Jose Antonio Santos-Cadenas <santoscadenas at gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* 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
*
*/
int hdp_adapter_register(DBusConnection *conn, struct btd_adapter *btd_adapter);
void hdp_adapter_unregister(struct btd_adapter *btd_adapter);
int hdp_device_register(DBusConnection *conn, struct btd_device *device);
void hdp_device_unregister(struct btd_device *device);
int hdp_manager_start(DBusConnection *conn);
void hdp_manager_stop();

60
health/hdp_main.c Normal file
View File

@ -0,0 +1,60 @@
/*
*
* BlueZ - Bluetooth protocol stack for Linux
*
* Copyright (C) 2010 GSyC/LibreSoft, Universidad Rey Juan Carlos.
* Authors:
* Santiago Carot Nemesio <sancane at gmail.com>
* Jose Antonio Santos-Cadenas <santoscadenas at gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* 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 <errno.h>
#include <gdbus.h>
#include "plugin.h"
#include "hdp_manager.h"
static DBusConnection *connection;
static int hdp_init(void)
{
connection = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
if (connection == NULL)
return -EIO;
if (hdp_manager_init(connection) < 0) {
dbus_connection_unref(connection);
return -EIO;
}
return 0;
}
static void hdp_exit(void)
{
hdp_manager_exit();
dbus_connection_unref(connection);
}
BLUETOOTH_PLUGIN_DEFINE(health, VERSION,
BLUETOOTH_PLUGIN_PRIORITY_DEFAULT, hdp_init, hdp_exit)

100
health/hdp_manager.c Normal file
View File

@ -0,0 +1,100 @@
/*
*
* BlueZ - Bluetooth protocol stack for Linux
*
* Copyright (C) 2010 GSyC/LibreSoft, Universidad Rey Juan Carlos.
* Authors:
* Santiago Carot Nemesio <sancane at gmail.com>
* Jose Antonio Santos-Cadenas <santoscadenas at gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* 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 <bluetooth/sdp.h>
#include <bluetooth/sdp_lib.h>
#include <btio.h>
#include <adapter.h>
#include <device.h>
#include "hdp_types.h"
#include "log.h"
#include "hdp_manager.h"
#include "hdp.h"
#include "glib-helper.h"
static DBusConnection *connection = NULL;
static int hdp_adapter_probe(struct btd_adapter *adapter)
{
return hdp_adapter_register(connection, adapter);
}
static void hdp_adapter_remove(struct btd_adapter *adapter)
{
hdp_adapter_unregister(adapter);
}
static struct btd_adapter_driver hdp_adapter_driver = {
.name = "hdp-adapter-driver",
.probe = hdp_adapter_probe,
.remove = hdp_adapter_remove,
};
static int hdp_driver_probe(struct btd_device *device, GSList *uuids)
{
return hdp_device_register(connection, device);
}
static void hdp_driver_remove(struct btd_device *device)
{
hdp_device_unregister(device);
}
static struct btd_device_driver hdp_device_driver = {
.name = "hdp-device-driver",
.uuids = BTD_UUIDS(HDP_UUID, HDP_SOURCE_UUID, HDP_SINK_UUID),
.probe = hdp_driver_probe,
.remove = hdp_driver_remove
};
int hdp_manager_init(DBusConnection *conn)
{
if (hdp_manager_start(conn))
return -1;
connection = dbus_connection_ref(conn);
btd_register_adapter_driver(&hdp_adapter_driver);
btd_register_device_driver(&hdp_device_driver);
return 0;
}
void hdp_manager_exit(void)
{
btd_unregister_device_driver(&hdp_device_driver);
btd_unregister_adapter_driver(&hdp_adapter_driver);
hdp_manager_stop();
dbus_connection_unref(connection);
connection = NULL;
}

27
health/hdp_manager.h Normal file
View File

@ -0,0 +1,27 @@
/*
*
* BlueZ - Bluetooth protocol stack for Linux
*
* Copyright (C) 2010 GSyC/LibreSoft, Universidad Rey Juan Carlos.
* Authors:
* Santiago Carot Nemesio <sancane at gmail.com>
* Jose Antonio Santos-Cadenas <santoscadenas at gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* 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
*
*/
int hdp_manager_init(DBusConnection *conn);
void hdp_manager_exit(void);

34
health/hdp_types.h Normal file
View File

@ -0,0 +1,34 @@
/*
*
* BlueZ - Bluetooth protocol stack for Linux
*
* Copyright (C) 2010 GSyC/LibreSoft, Universidad Rey Juan Carlos.
* Authors:
* Santiago Carot Nemesio <sancane at gmail.com>
* Jose Antonio Santos-Cadenas <santoscadenas at gmail.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* 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 __HDP_TYPES_H__
#define __HDP_TYPES_H__
#define HDP_UUID "00001400-0000-1000-8000-00805F9B34FB"
#define HDP_SOURCE_UUID "00001401-0000-1000-8000-00805F9B34FB"
#define HDP_SINK_UUID "00001402-0000-1000-8000-00805F9B34FB"
#endif /* __HDP_TYPES_H__ */