summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile.am8
-rw-r--r--acinclude.m46
-rw-r--r--attrib/example.h26
-rw-r--r--attrib/manager.c6
-rwxr-xr-xbootstrap-configure1
-rw-r--r--plugins/gatt-example.c (renamed from attrib/example.c)25
6 files changed, 29 insertions, 43 deletions
diff --git a/Makefile.am b/Makefile.am
index 77b9b7d06..9b749705e 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -204,8 +204,12 @@ endif
builtin_modules += attrib
builtin_sources += attrib/main.c \
- attrib/manager.h attrib/manager.c \
- attrib/example.h attrib/example.c
+ attrib/manager.h attrib/manager.c
+endif
+
+if GATT_EXAMPLE_PLUGIN
+builtin_modules += gatt_example
+builtin_sources += plugins/gatt-example.c
endif
if HEALTHPLUGIN
diff --git a/acinclude.m4 b/acinclude.m4
index 69e07405d..81b366eb3 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -190,6 +190,7 @@ AC_DEFUN([AC_ARG_BLUEZ], [
health_enable=no
pnat_enable=no
attrib_enable=no
+ gatt_example_enable=no
tracer_enable=no
tools_enable=yes
hidd_enable=no
@@ -261,6 +262,10 @@ AC_DEFUN([AC_ARG_BLUEZ], [
attrib_enable=${enableval}
])
+ AC_ARG_ENABLE(gatt-example, AC_HELP_STRING([--enable-gatt-example], [enable GATT example plugin]), [
+ gatt_example_enable=${enableval}
+ ])
+
AC_ARG_ENABLE(gstreamer, AC_HELP_STRING([--enable-gstreamer], [enable GStreamer support]), [
gstreamer_enable=${enableval}
])
@@ -385,6 +390,7 @@ AC_DEFUN([AC_ARG_BLUEZ], [
AM_CONDITIONAL(HAL, test "${hal_enable}" = "yes")
AM_CONDITIONAL(READLINE, test "${readline_found}" = "yes")
AM_CONDITIONAL(ATTRIBPLUGIN, test "${attrib_enable}" = "yes")
+ AM_CONDITIONAL(GATT_EXAMPLE_PLUGIN, test "${gatt_example_enable}" = "yes")
AM_CONDITIONAL(ECHOPLUGIN, test "no" = "yes")
AM_CONDITIONAL(PNATPLUGIN, test "${pnat_enable}" = "yes")
AM_CONDITIONAL(TRACER, test "${tracer_enable}" = "yes")
diff --git a/attrib/example.h b/attrib/example.h
deleted file mode 100644
index a2b07fe4d..000000000
--- a/attrib/example.h
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- *
- * BlueZ - Bluetooth protocol stack for Linux
- *
- * Copyright (C) 2010 Nokia Corporation
- * Copyright (C) 2010 Marcel Holtmann <marcel@holtmann.org>
- *
- *
- * 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 server_example_init(void);
-void server_example_exit(void);
diff --git a/attrib/manager.c b/attrib/manager.c
index 7c0572058..6a2b80a7d 100644
--- a/attrib/manager.c
+++ b/attrib/manager.c
@@ -32,18 +32,12 @@
#include "hcid.h"
#include "manager.h"
-#include "example.h"
int attrib_manager_init(void)
{
- if (main_opts.attrib_server)
- return server_example_init();
-
return 0;
}
void attrib_manager_exit(void)
{
- if (main_opts.attrib_server)
- server_example_exit();
}
diff --git a/bootstrap-configure b/bootstrap-configure
index 69a102f31..364998f2d 100755
--- a/bootstrap-configure
+++ b/bootstrap-configure
@@ -18,6 +18,7 @@ fi
--libexecdir=/lib \
--enable-capng \
--enable-attrib \
+ --enable-gatt-example \
--enable-health \
--enable-tracer \
--enable-tools \
diff --git a/attrib/example.c b/plugins/gatt-example.c
index fae288ca9..f1dfd5bd1 100644
--- a/attrib/example.c
+++ b/plugins/gatt-example.c
@@ -22,22 +22,18 @@
*
*/
-
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
-#include <arpa/inet.h>
-
-#include <bluetooth/uuid.h>
-
#include <glib.h>
+#include <bluetooth/uuid.h>
+#include "plugin.h"
+#include "hcid.h"
#include "log.h"
#include "attrib-server.h"
-
#include "att.h"
-#include "example.h"
/* FIXME: Not defined by SIG? UUID128? */
#define OPCODES_SUPPORTED_UUID 0xA001
@@ -325,13 +321,21 @@ static int register_attributes(void)
return 0;
}
-int server_example_init(void)
+static int gatt_example_init(void)
{
+ if (!main_opts.attrib_server) {
+ DBG("Attribute server is disabled");
+ return -1;
+ }
+
return register_attributes();
}
-void server_example_exit(void)
+static void gatt_example_exit(void)
{
+ if (!main_opts.attrib_server)
+ return;
+
while (sdp_handles) {
uint32_t handle = GPOINTER_TO_UINT(sdp_handles->data);
@@ -339,3 +343,6 @@ void server_example_exit(void)
sdp_handles = g_slist_remove(sdp_handles, sdp_handles->data);
}
}
+
+BLUETOOTH_PLUGIN_DEFINE(gatt_example, VERSION, BLUETOOTH_PLUGIN_PRIORITY_LOW,
+ gatt_example_init, gatt_example_exit)