Initial support for Health Thermometer Profile (HTP)
Subsystems (2)
PATCH 1/7 Initial support for Health Thermometer Profile (HTP)
--- Makefile.am | 5 +++++ acinclude.m4 | 6 ++++++ bootstrap-configure | 1 + thermometer/main.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 57 insertions(+), 0 deletions(-) create mode 100644 thermometer/main.c
Makefile.am +5 -0
@@ -208,6 +208,11 @@ builtin_sources += health/hdp_main.c health/hdp_types.h \ health/hdp_util.h health/hdp_util.c endif +if THERMOMETERPLUGIN +builtin_modules += thermometer +builtin_sources += thermometer/main.c +endif + builtin_modules += hciops mgmtops builtin_sources += plugins/hciops.c plugins/mgmtops.c
acinclude.m4 +6 -0
@@ -214,6 +214,7 @@ AC_DEFUN([AC_ARG_BLUEZ], [ sap_driver=dummy dbusoob_enable=no wiimote_enable=no + thermometer_enable=no AC_ARG_ENABLE(optimization, AC_HELP_STRING([--disable-optimization], [disable code optimization]), [ optimization_enable=${enableval}
@@ -354,6 +355,10 @@ AC_DEFUN([AC_ARG_BLUEZ], [ hal_enable=${enableval} ]) + AC_ARG_ENABLE(thermometer, AC_HELP_STRING([--enable-thermometer], [enable thermometer plugin]), [ + thermometer_enable=${enableval} + ]) + if (test "${fortify_enable}" = "yes"); then CFLAGS="$CFLAGS -D_FORTIFY_SOURCE=2" fi
@@ -409,4 +414,5 @@ AC_DEFUN([AC_ARG_BLUEZ], [ AM_CONDITIONAL(MAEMO6PLUGIN, test "${maemo6_enable}" = "yes") AM_CONDITIONAL(DBUSOOBPLUGIN, test "${dbusoob_enable}" = "yes") AM_CONDITIONAL(WIIMOTEPLUGIN, test "${wiimote_enable}" = "yes") + AM_CONDITIONAL(THERMOMETERPLUGIN, test "${thermometer_enable}" = "yes") ])
bootstrap-configure +1 -0
@@ -30,5 +30,6 @@ fi --enable-test \ --enable-cups \ --enable-sap \ + --enable-thermometer \ --disable-pcmcia \ --disable-datafiles $*
thermometer/main.c new file +45 -0
46 lines not on this page · raw message
Signature · 1 line
1.7.6
PATCH 2/7 Add manager files for HTP
--- Makefile.am | 3 ++- thermometer/main.c | 21 +++++++++++++++++++-- thermometer/manager.c | 38 ++++++++++++++++++++++++++++++++++++++ thermometer/manager.h | 27 +++++++++++++++++++++++++++ 4 files changed, 86 insertions(+), 3 deletions(-) create mode 100644 thermometer/manager.c create mode 100644 thermometer/manager.h
Makefile.am +2 -1
@@ -210,7 +210,8 @@ endif if THERMOMETERPLUGIN builtin_modules += thermometer -builtin_sources += thermometer/main.c +builtin_sources += thermometer/main.c \ + thermometer/manager.h thermometer/manager.c endif builtin_modules += hciops mgmtops
thermometer/main.c +19 -2
@@ -27,18 +27,35 @@#include <config.h> #endif +#include <glib.h> +#include <errno.h> +#include <gdbus.h> +#include "plugin.h" +#include "manager.h" +static DBusConnection *connection =NULL ;static int thermometer_init (void ) { -/*TODO: */ + connection =dbus_bus_get (DBUS_BUS_SYSTEM ,NULL ); +if (connection ==NULL ) +return -EIO ; + +if (thermometer_manager_init (connection) <0 ) { +dbus_connection_unref (connection); +return -EIO ; + } +return 0 ; }static void thermometer_exit (void ) { -/*TODO: */ +thermometer_manager_exit (); + +dbus_connection_unref (connection); + connection =NULL ; } BLUETOOTH_PLUGIN_DEFINE(thermometer, VERSION, BLUETOOTH_PLUGIN_PRIORITY_DEFAULT,
thermometer/manager.c new file +38 -0
@@ -0,0 +1,38 @@ +/* +* +* BlueZ - Bluetooth protocol stack for Linux +* +* Copyright (C) 2011 GSyC/LibreSoft, Universidad Rey Juan Carlos. +* Authors: +* Santiago Carot Nemesio <sancane at gmail.com> +* Jorge Fernandez Gonzalez <jorge.fernandez.gonzalez 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 "manager.h" + +int thermometer_manager_init (DBusConnection *conn) +{ +/*TODO: */ +return 0 ; +} + +void thermometer_manager_exit (void ) +{ +/*TODO: */ +}
thermometer/manager.h new file +27 -0
@@ -0,0 +1,27 @@ +/* +* +* BlueZ - Bluetooth protocol stack for Linux +* +* Copyright (C) 2011 GSyC/LibreSoft, Universidad Rey Juan Carlos. +* Authors: +* Santiago Carot Nemesio <sancane at gmail.com> +* Jorge Fernandez Gonzalez <jorge.fernandez.gonzalez 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 thermometer_manager_init (DBusConnection *conn); +void thermometer_manager_exit (void );
Signature · 1 line
1.7.6
PATCH 3/7 Load HTP plugin only if LE is enabled
--- thermometer/main.c | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-)
thermometer/main.c +5 -0
@@ -30,14 +30,19 @@#include <glib.h> #include <errno.h> #include <gdbus.h> +#include <stdint.h> #include "plugin.h" +#include "hcid.h" #include "manager.h" static DBusConnection *connection =NULL ;static int thermometer_init (void ) { +if (!main_opts.le) +return -EINVAL ; + connection =dbus_bus_get (DBUS_BUS_SYSTEM ,NULL );if (connection ==NULL )return -EIO ;
Signature · 1 line
1.7.6
PATCH 4/7 Register thermometer driver
--- thermometer/main.c | 1 + thermometer/manager.c | 40 ++++++++++++++++++++++++++++++++++++++-- 2 files changed, 39 insertions(+), 2 deletions(-)
thermometer/main.c +1 -0
@@ -32,6 +32,7 @@#include <gdbus.h> #include <stdint.h> +#include "log.h" #include "plugin.h" #include "hcid.h" #include "manager.h"
thermometer/manager.c +38 -2
@@ -24,15 +24,51 @@*/ #include <gdbus.h> + +#include "adapter.h" +#include "device.h" +#include "log.h" #include "manager.h" +#define HEALTH_THERMOMETER_SVC_UUID 0x1809 +#define HEALTH_THERMOMETER_UUID "00001809-0000-1000-8000-00805f9b34fb" + +static DBusConnection *connection =NULL ; + +static int thermometer_driver_probe (struct btd_device *device,GSList *uuids) +{ +/* TODO; */ +return 0 ; +} + +static void thermometer_driver_remove (struct btd_device *device) +{ +/* TODO: */ +} + +static struct btd_device_driver thermometer_device_driver = { + .name ="thermometer-device-driver" , + .uuids =BTD_UUIDS (HEALTH_THERMOMETER_UUID ), + .probe = thermometer_driver_probe, + .remove = thermometer_driver_remove +}; +int thermometer_manager_init (DBusConnection *conn) { -/*TODO: */ +int ret; + + ret =btd_register_device_driver (&thermometer_device_driver); +if (ret <0 ) +return ret; + + connection =dbus_connection_ref (conn);return 0 ; }void thermometer_manager_exit (void ) { -/*TODO: */ +btd_unregister_device_driver (&thermometer_device_driver); + +dbus_connection_unref (connection); + connection =NULL ; }
Signature · 1 line
1.7.6
PATCH 5/7 Add thermometer driver skeleton
--- Makefile.am | 3 ++- thermometer/manager.c | 10 +++------- thermometer/thermometer.c | 41 +++++++++++++++++++++++++++++++++++++++++ thermometer/thermometer.h | 30 ++++++++++++++++++++++++++++++ 4 files changed, 76 insertions(+), 8 deletions(-) create mode 100644 thermometer/thermometer.c create mode 100644 thermometer/thermometer.h
Makefile.am +2 -1
@@ -211,7 +211,8 @@ endif if THERMOMETERPLUGIN builtin_modules += thermometer builtin_sources += thermometer/main.c \ - thermometer/manager.h thermometer/manager.c + thermometer/manager.h thermometer/manager.c \ + thermometer/thermometer.h thermometer/thermometer.c endif builtin_modules += hciops mgmtops
thermometer/manager.c +3 -7
@@ -27,23 +27,19 @@#include "adapter.h" #include "device.h" -#include "log.h" +#include "thermometer.h" #include "manager.h" -#define HEALTH_THERMOMETER_SVC_UUID 0x1809 -#define HEALTH_THERMOMETER_UUID "00001809-0000-1000-8000-00805f9b34fb" -static DBusConnection *connection =NULL ;static int thermometer_driver_probe (struct btd_device *device,GSList *uuids) { -/* TODO; */ -return 0 ; +return thermometer_register (connection, device); }static void thermometer_driver_remove (struct btd_device *device) { -/* TODO: */ +thermometer_unregister (device); }static struct btd_device_driver thermometer_device_driver = {
thermometer/thermometer.c new file +41 -0
42 lines not on this page · raw message
thermometer/thermometer.h new file +30 -0
@@ -0,0 +1,30 @@ +/* +* +* BlueZ - Bluetooth protocol stack for Linux +* +* Copyright (C) 2011 GSyC/LibreSoft, Universidad Rey Juan Carlos. +* Authors: +* Santiago Carot Nemesio <sancane at gmail.com> +* Jorge Fernandez Gonzalez <jorge.fernandez.gonzalez 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 +* +*/ + +#define HEALTH_THERMOMETER_SVC_UUID 0x1809 +#define HEALTH_THERMOMETER_UUID "00001809-0000-1000-8000-00805f9b34fb" + +int thermometer_register (DBusConnection *connection,struct btd_device *device); +void thermometer_unregister (struct btd_device *device);
Signature · 1 line
1.7.6
PATCH 6/7 Initial steps to manage thermometer objects
--- thermometer/thermometer.c | 63 +++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 63 insertions(+), 0 deletions(-)
thermometer/thermometer.c +63 -0
@@ -27,15 +27,78 @@#include "adapter.h" #include "device.h" +#include "log.h" #include "thermometer.h" +struct thermometer { +DBusConnection *conn;/* The connection to the bus */ +struct btd_device *dev;/* Device reference */ +gint ref;/* Reference counter */ +}; + +static GSList *thermometers =NULL ; + +static struct thermometer *thermometer_ref (struct thermometer *t) +{ + t->ref++; + +DBG ("%p: ref=%d" , t, t->ref); + +return t; +} + +static void thermometer_unref (struct thermometer *t) +{ + t->ref--; + +DBG ("%p: ref=%d" , t, t->ref); + +if (t->ref >0 ) +return ; + +dbus_connection_unref (t->conn); +btd_device_unref (t->dev); +g_free (t); +} + +static gint cmp_device (gconstpointer a,gconstpointer b) +{ +const struct thermometer *t = a; +const struct btd_device *dev = b; + +if (dev == t->dev) +return 0 ; + +return -1 ; +} +int thermometer_register (DBusConnection *connection,struct btd_device *device) { +struct thermometer *t; + + t = g_new0(struct thermometer, 1); + t->conn =dbus_connection_ref (connection); + t->dev =btd_device_ref (device); +/* TODO: Register Health Thermometer Interface */ + + thermometers =g_slist_prepend (thermometers,thermometer_ref (t)); +return 0 ; }void thermometer_unregister (struct btd_device *device) { +struct thermometer *t; +GSList *l; + + l =g_slist_find_custom (thermometers, device, cmp_device); +if (!l) +return ; +/* TODO: Unregister Health Thermometer Interface */ + + t = l->data; + thermometers =g_slist_remove (thermometers, t); +thermometer_unref (t); }
Signature · 1 line
1.7.6
PATCH 7/7 Release resources allocated when the thermometer plugin is stopped
--- thermometer/manager.c | 1 + thermometer/thermometer.c | 6 ++++++ thermometer/thermometer.h | 4 +++- 3 files changed, 10 insertions(+), 1 deletions(-)
thermometer/manager.c +1 -0
@@ -64,6 +64,7 @@ int thermometer_manager_init(DBusConnection *conn)void thermometer_manager_exit (void ) {btd_unregister_device_driver (&thermometer_device_driver); +thermometer_stop ();dbus_connection_unref (connection); connection =NULL ;
thermometer/thermometer.c +6 -0
@@ -101,4 +101,10 @@ void thermometer_unregister(struct btd_device *device) t = l->data; thermometers =g_slist_remove (thermometers, t);thermometer_unref (t); +} + +void thermometer_stop () +{ +g_slist_free_full (thermometers, (GDestroyNotify ) thermometer_unref); + thermometers =NULL ; }
thermometer/thermometer.h +3 -1
@@ -27,4 +27,6 @@#define HEALTH_THERMOMETER_UUID "00001809-0000-1000-8000-00805f9b34fb"int thermometer_register (DBusConnection *connection,struct btd_device *device); -void thermometer_unregister (struct btd_device *device); +void thermometer_unregister (struct btd_device *device); + +void thermometer_stop ();
Signature · 1 line
1.7.6