Thread (11 messages) read the whole thread 11 messages, 4 authors, 2011-12-05
STALE5352d

[PATCH 2/2] Update gatt-exmaple to check if attributes were registered.

From: Santiago Carot-Nemesio <hidden>
Date: 2011-11-24 10:08:10
Subsystem: the rest · Maintainer: Linus Torvalds

---
 plugins/gatt-example.c |   11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/plugins/gatt-example.c b/plugins/gatt-example.c
index 1456284..6d9b6b8 100644
--- a/plugins/gatt-example.c
+++ b/plugins/gatt-example.c
@@ -28,6 +28,7 @@
 
 #include <glib.h>
 #include <bluetooth/uuid.h>
+#include <errno.h>
 
 #include "plugin.h"
 #include "hcid.h"
@@ -68,9 +69,9 @@ static uint8_t battery_state_read(struct attribute *a, gpointer user_data)
 	return 0;
 }
 
-static void register_battery_service(void)
+static gboolean register_battery_service(void)
 {
-	gatt_service_add(GATT_PRIM_SVC_UUID, BATTERY_STATE_SVC_UUID,
+	return gatt_service_add(GATT_PRIM_SVC_UUID, BATTERY_STATE_SVC_UUID,
 			/* battery state characteristic */
 			GATT_OPT_CHR_UUID, BATTERY_STATE_UUID,
 			GATT_OPT_CHR_PROPS, ATT_CHAR_PROPER_READ |
@@ -445,7 +446,11 @@ static int gatt_example_init(void)
 		return -1;
 	}
 
-	register_battery_service();
+	if (!register_battery_service()) {
+		DBG("Battery service could not be registered");
+		return -EIO;
+	}
+
 	register_manuf1_service(manuf1_range);
 	register_manuf2_service(manuf2_range);
 	register_termometer_service(manuf1_range, manuf2_range);
-- 
1.7.7.4
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help