Linux bluetooth development
 help / color / mirror / Atom feed
From: chen.ganir@ti.com
To: linux-bluetooth@vger.kernel.org
Cc: Chen Ganir <chen.ganir@ti.com>
Subject: [PATCH v4 3/3] GATT: Profile support for EnableGatt
Date: Mon, 19 Mar 2012 16:57:53 +0200	[thread overview]
Message-ID: <1332169073-15885-4-git-send-email-chen.ganir@ti.com> (raw)
In-Reply-To: <1332169073-15885-1-git-send-email-chen.ganir@ti.com>

From: Chen Ganir <chen.ganir@ti.com>

Add support for the EnableGatt for all GATT profiles.
---
 alert/main.c           |    5 +++--
 plugins/gatt-example.c |    2 +-
 proximity/main.c       |   10 +++++++++-
 proximity/reporter.c   |    5 +++--
 src/main.conf          |    5 ++---
 thermometer/main.c     |   11 +++++++++++
 time/main.c            |    5 +++--
 7 files changed, 32 insertions(+), 11 deletions(-)

diff --git a/alert/main.c b/alert/main.c
index 6e2e058..ec4ab6d 100644
--- a/alert/main.c
+++ b/alert/main.c
@@ -28,6 +28,7 @@
 
 #include <stdint.h>
 #include <glib.h>
+#include <errno.h>
 
 #include "plugin.h"
 #include "hcid.h"
@@ -37,8 +38,8 @@
 static int alert_init(void)
 {
 	if (!main_opts.gatt_enabled) {
-		DBG("Attribute server is disabled");
-		return -1;
+		DBG("GATT is disabled");
+		return -ENOTSUP;
 	}
 
 	return alert_server_init();
diff --git a/plugins/gatt-example.c b/plugins/gatt-example.c
index 165d218..58b222c 100644
--- a/plugins/gatt-example.c
+++ b/plugins/gatt-example.c
@@ -561,7 +561,7 @@ static struct btd_adapter_driver gatt_example_adapter_driver = {
 static int gatt_example_init(void)
 {
 	if (!main_opts.gatt_enabled) {
-		DBG("Attribute server is disabled");
+		DBG("GATT is disabled");
 		return -ENOTSUP;
 	}
 
diff --git a/proximity/main.c b/proximity/main.c
index 5f0fc12..3d5d9b2 100644
--- a/proximity/main.c
+++ b/proximity/main.c
@@ -27,13 +27,14 @@
 #endif
 
 #include <errno.h>
-
+#include <stdint.h>
 #include <glib.h>
 #include <gdbus.h>
 
 #include "log.h"
 #include "plugin.h"
 #include "manager.h"
+#include "hcid.h"
 
 static DBusConnection *connection = NULL;
 static GKeyFile *config = NULL;
@@ -59,6 +60,10 @@ static GKeyFile *open_config_file(const char *file)
 
 static int proximity_init(void)
 {
+	if (!main_opts.gatt_enabled) {
+		DBG("GATT is disabled");
+		return -ENOTSUP;
+	}
 
 	connection = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
 	if (connection == NULL)
@@ -76,6 +81,9 @@ static int proximity_init(void)
 
 static void proximity_exit(void)
 {
+	if (!main_opts.gatt_enabled)
+		return;
+
 	if (config)
 		g_key_file_free(config);
 
diff --git a/proximity/reporter.c b/proximity/reporter.c
index d4a4c96..74e6297 100644
--- a/proximity/reporter.c
+++ b/proximity/reporter.c
@@ -29,6 +29,7 @@
 #include <glib.h>
 #include <bluetooth/uuid.h>
 #include <adapter.h>
+#include <errno.h>
 
 #include "log.h"
 
@@ -173,8 +174,8 @@ static void register_immediate_alert(struct btd_adapter *adapter)
 int reporter_init(struct btd_adapter *adapter)
 {
 	if (!main_opts.gatt_enabled) {
-		DBG("Attribute server is disabled");
-		return -1;
+		DBG("GATT is disabled");
+		return -ENOTSUP;
 	}
 
 	DBG("Proximity Reporter for adapter %p", adapter);
diff --git a/src/main.conf b/src/main.conf
index 321f622..469c077 100644
--- a/src/main.conf
+++ b/src/main.conf
@@ -62,6 +62,5 @@ NameResolving = true
 # that they were created for.
 DebugKeys = false
 
-# Enable the GATT Attribute Server. Default is false, because it is only
-# useful for testing.
-AttributeServer = false
+# Enable the GATT functionality. Default is false
+EnableGatt = false
diff --git a/thermometer/main.c b/thermometer/main.c
index 471764e..4447b52 100644
--- a/thermometer/main.c
+++ b/thermometer/main.c
@@ -24,17 +24,25 @@
 #include <config.h>
 #endif
 
+#include <stdint.h>
 #include <glib.h>
 #include <errno.h>
 #include <gdbus.h>
 
 #include "plugin.h"
 #include "manager.h"
+#include "hcid.h"
+#include "log.h"
 
 static DBusConnection *connection = NULL;
 
 static int thermometer_init(void)
 {
+	if (!main_opts.gatt_enabled) {
+		DBG("GATT is disabled");
+		return -ENOTSUP;
+	}
+
 	connection = dbus_bus_get(DBUS_BUS_SYSTEM, NULL);
 	if (connection == NULL)
 		return -EIO;
@@ -49,6 +57,9 @@ static int thermometer_init(void)
 
 static void thermometer_exit(void)
 {
+	if (!main_opts.gatt_enabled)
+		return;
+
 	thermometer_manager_exit();
 
 	dbus_connection_unref(connection);
diff --git a/time/main.c b/time/main.c
index cbcdb0d..d876725 100644
--- a/time/main.c
+++ b/time/main.c
@@ -28,6 +28,7 @@
 
 #include <stdint.h>
 #include <glib.h>
+#include <errno.h>
 
 #include "plugin.h"
 #include "hcid.h"
@@ -37,8 +38,8 @@
 static int time_init(void)
 {
 	if (!main_opts.gatt_enabled) {
-		DBG("Attribute server is disabled");
-		return -1;
+		DBG("GATT is disabled");
+		return -ENOTSUP;
 	}
 
 	return time_server_init();
-- 
1.7.4.1


  parent reply	other threads:[~2012-03-19 14:57 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-19 14:57 [PATCH v4 0/3] GATT: Change the way GATT Plugins are enabled/disabled chen.ganir
2012-03-19 14:57 ` [PATCH v4 1/3] GATT: Remove individual config switches chen.ganir
2012-03-19 14:57 ` [PATCH v4 2/3] GATT: Rename AttributeServer switch chen.ganir
2012-03-19 14:57 ` chen.ganir [this message]
2012-03-26  9:21   ` [PATCH v4 3/3] GATT: Profile support for EnableGatt Johan Hedberg
2012-03-26  9:34     ` Ganir, Chen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1332169073-15885-4-git-send-email-chen.ganir@ti.com \
    --to=chen.ganir@ti.com \
    --cc=linux-bluetooth@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox