[PATCH BlueZ v2 11/12] android/bas: Read CCC initial value for Battery Level

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Luiz Augusto von Dentz <luiz.von.dentz@xxxxxxxxx>

This is required by the following test:

- TP/HGRF/HH/BV-11-I [Read Client Characteristic Configuration Descriptor
for Battery Level Characteristic]
---
 android/bas.c | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/android/bas.c b/android/bas.c
index 996f3c0..7342895 100644
--- a/android/bas.c
+++ b/android/bas.c
@@ -48,6 +48,7 @@ struct bt_bas {
 	GAttrib *attrib;
 	struct gatt_primary *primary;
 	uint16_t handle;
+	uint16_t ccc_handle;
 	guint id;
 };
 
@@ -126,6 +127,20 @@ static void write_ccc(GAttrib *attrib, uint16_t handle, void *user_data)
 								user_data);
 }
 
+
+static void ccc_read_cb(guint8 status, const guint8 *pdu, guint16 len,
+							gpointer user_data)
+{
+	struct bt_bas *bas = user_data;
+
+	if (status != 0) {
+		error("Error reading CCC value: %s", att_ecode2str(status));
+		return;
+	}
+
+	write_ccc(bas->attrib, bas->ccc_handle, bas);
+}
+
 static void discover_descriptor_cb(uint8_t status, GSList *descs,
 								void *user_data)
 {
@@ -139,8 +154,9 @@ static void discover_descriptor_cb(uint8_t status, GSList *descs,
 
 	/* There will be only one descriptor on list and it will be CCC */
 	desc = descs->data;
+	bas->ccc_handle = desc->handle;
 
-	write_ccc(bas->attrib, desc->handle, bas);
+	gatt_read_char(bas->attrib, desc->handle, ccc_read_cb, bas);
 }
 
 static void bas_discovered_cb(uint8_t status, GSList *chars, void *user_data)
-- 
1.9.3

--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux