* [PATCH BlueZ 01/12] android/hog: Add bt_hog_send
@ 2014-06-30 13:47 Luiz Augusto von Dentz
2014-06-30 13:47 ` [PATCH BlueZ 02/12] android/hidhost: Use bt_hog_send in bt_hid_send_data Luiz Augusto von Dentz
` (10 more replies)
0 siblings, 11 replies; 12+ messages in thread
From: Luiz Augusto von Dentz @ 2014-06-30 13:47 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This function can be used to send data using Output Report if one is
available.
---
android/hog.c | 37 +++++++++++++++++++++++++++++++++++++
android/hog.h | 1 +
2 files changed, 38 insertions(+)
diff --git a/android/hog.c b/android/hog.c
index 7e61790..5d33c63 100644
--- a/android/hog.c
+++ b/android/hog.c
@@ -1009,3 +1009,40 @@ int bt_hog_set_control_point(struct bt_hog *hog, bool suspend)
return 0;
}
+
+int bt_hog_send(struct bt_hog *hog, void *data, size_t size)
+{
+ struct report *report;
+ GSList *l;
+
+ if (!hog)
+ return -EINVAL;
+
+ if (!hog->attrib)
+ return -ENOTCONN;
+
+ l = g_slist_find_custom(hog->reports,
+ GUINT_TO_POINTER(HOG_REPORT_TYPE_OUTPUT),
+ report_type_cmp);
+ if (!l)
+ return -ENOTSUP;
+
+ report = l->data;
+
+ DBG("Sending data to handle 0x%X", report->decl->value_handle);
+
+ if (report->decl->properties & GATT_CHR_PROP_WRITE)
+ gatt_write_char(hog->attrib, report->decl->value_handle,
+ data, size, output_written_cb, hog);
+ else if (report->decl->properties & GATT_CHR_PROP_WRITE_WITHOUT_RESP)
+ gatt_write_cmd(hog->attrib, report->decl->value_handle,
+ data, size, NULL, NULL);
+
+ for (l = hog->instances; l; l = l->next) {
+ struct bt_hog *instance = l->data;
+
+ bt_hog_send(instance, data, size);
+ }
+
+ return 0;
+}
diff --git a/android/hog.h b/android/hog.h
index 7cf446b..4ebc83e 100644
--- a/android/hog.h
+++ b/android/hog.h
@@ -33,3 +33,4 @@ bool bt_hog_attach(struct bt_hog *hog, void *gatt);
void bt_hog_detach(struct bt_hog *hog);
int bt_hog_set_control_point(struct bt_hog *hog, bool suspend);
+int bt_hog_send(struct bt_hog *hog, void *data, size_t size);
--
1.9.3
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH BlueZ 02/12] android/hidhost: Use bt_hog_send in bt_hid_send_data
2014-06-30 13:47 [PATCH BlueZ 01/12] android/hog: Add bt_hog_send Luiz Augusto von Dentz
@ 2014-06-30 13:47 ` Luiz Augusto von Dentz
2014-06-30 13:47 ` [PATCH BlueZ 03/12] android/hog: Read initial value of Report characteristic Luiz Augusto von Dentz
` (9 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Luiz Augusto von Dentz @ 2014-06-30 13:47 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
If bt_hid_send_data is called for a HoG device send data using
bt_hog_send.
---
android/hidhost.c | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/android/hidhost.c b/android/hidhost.c
index 0c0d69d..07b2b02 100644
--- a/android/hidhost.c
+++ b/android/hidhost.c
@@ -1270,6 +1270,21 @@ failed:
status);
}
+static int hog_send_data(struct hid_device *dev, void *data, size_t size)
+{
+ int err;
+
+ DBG("");
+
+ err = bt_hog_send(dev->hog, data, size);
+ if (err == 0)
+ return 0;
+
+ error("hidhost: error writing data to HoG device: %s (%d)",
+ strerror(-err), -err);
+ return err;
+}
+
static void bt_hid_send_data(const void *buf, uint16_t len)
{
const struct hal_cmd_hidhost_send_data *cmd = buf;
@@ -1322,6 +1337,14 @@ static void bt_hid_send_data(const void *buf, uint16_t len)
goto failed;
}
+ if (dev->hog) {
+ if (hog_send_data(dev, req, req_size) == 0)
+ goto done;
+
+ status = HAL_STATUS_FAILED;
+ goto failed;
+ }
+
fd = g_io_channel_unix_get_fd(dev->intr_io);
if (write(fd, req, req_size) < 0) {
@@ -1331,6 +1354,7 @@ static void bt_hid_send_data(const void *buf, uint16_t len)
goto failed;
}
+done:
status = HAL_STATUS_SUCCESS;
failed:
--
1.9.3
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH BlueZ 03/12] android/hog: Read initial value of Report characteristic
2014-06-30 13:47 [PATCH BlueZ 01/12] android/hog: Add bt_hog_send Luiz Augusto von Dentz
2014-06-30 13:47 ` [PATCH BlueZ 02/12] android/hidhost: Use bt_hog_send in bt_hid_send_data Luiz Augusto von Dentz
@ 2014-06-30 13:47 ` Luiz Augusto von Dentz
2014-06-30 13:47 ` [PATCH BlueZ 04/12] android/hog: Read CCC initial value for Input Report Luiz Augusto von Dentz
` (8 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Luiz Augusto von Dentz @ 2014-06-30 13:47 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This is required by following tests:
- TP/HGRF/RH/BV-03-I [Read Report Characteristics – Input Report]
- TP/HGRF/RH/BV-19-I [Read Report Characteristics – Output Report]
- TP/HGRF/RH/BV-07-I [Read Report Characteristics – Feature Report]
---
android/hog.c | 33 ++++++++++++++++++++++++---------
1 file changed, 24 insertions(+), 9 deletions(-)
diff --git a/android/hog.c b/android/hog.c
index 5d33c63..f69fe2a 100644
--- a/android/hog.c
+++ b/android/hog.c
@@ -198,7 +198,7 @@ static void report_reference_cb(guint8 status, const guint8 *pdu,
DBG("Report ID: 0x%02x Report type: 0x%02x", pdu[1], pdu[2]);
/* Enable notifications only for Input Reports */
- if (report->type == 0x01)
+ if (report->type == HOG_REPORT_TYPE_INPUT)
write_ccc(report->hog->attrib, report->ccc_handle, report);
}
@@ -273,6 +273,27 @@ static void discover_report(GAttrib *attrib, uint16_t start, uint16_t end,
user_data);
}
+static void report_read_cb(guint8 status, const guint8 *pdu, guint16 len,
+ gpointer user_data)
+{
+ if (status != 0)
+ error("Error reading Report value: %s", att_ecode2str(status));
+}
+
+static struct report *report_new(struct bt_hog *hog, struct gatt_char *chr)
+{
+ struct report *report;
+
+ report = g_new0(struct report, 1);
+ report->hog = hog;
+ report->decl = g_memdup(chr, sizeof(*chr));
+ hog->reports = g_slist_append(hog->reports, report);
+
+ gatt_read_char(hog->attrib, chr->value_handle, report_read_cb, report);
+
+ return report;
+}
+
static void external_service_char_cb(uint8_t status, GSList *chars,
void *user_data)
{
@@ -297,10 +318,7 @@ static void external_service_char_cb(uint8_t status, GSList *chars,
DBG("0x%04x UUID: %s properties: %02x",
chr->handle, chr->uuid, chr->properties);
- report = g_new0(struct report, 1);
- report->hog = hog;
- report->decl = g_memdup(chr, sizeof(*chr));
- hog->reports = g_slist_append(hog->reports, report);
+ report = report_new(hog, chr);
start = chr->value_handle + 1;
end = (next ? next->handle - 1 : primary->range.end);
discover_report(hog->attrib, start, end, report);
@@ -640,10 +658,7 @@ static void char_discovered_cb(uint8_t status, GSList *chars, void *user_data)
end = (next ? next->handle - 1 : primary->range.end);
if (bt_uuid_cmp(&uuid, &report_uuid) == 0) {
- report = g_new0(struct report, 1);
- report->hog = hog;
- report->decl = g_memdup(chr, sizeof(*chr));
- hog->reports = g_slist_append(hog->reports, report);
+ report = report_new(hog, chr);
discover_report(hog->attrib, start, end, report);
} else if (bt_uuid_cmp(&uuid, &report_map_uuid) == 0) {
gatt_read_char(hog->attrib, chr->value_handle,
--
1.9.3
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH BlueZ 04/12] android/hog: Read CCC initial value for Input Report
2014-06-30 13:47 [PATCH BlueZ 01/12] android/hog: Add bt_hog_send Luiz Augusto von Dentz
2014-06-30 13:47 ` [PATCH BlueZ 02/12] android/hidhost: Use bt_hog_send in bt_hid_send_data Luiz Augusto von Dentz
2014-06-30 13:47 ` [PATCH BlueZ 03/12] android/hog: Read initial value of Report characteristic Luiz Augusto von Dentz
@ 2014-06-30 13:47 ` Luiz Augusto von Dentz
2014-06-30 13:47 ` [PATCH BlueZ 05/12] android/hog: Fix not resetting properly on detach Luiz Augusto von Dentz
` (7 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Luiz Augusto von Dentz @ 2014-06-30 13:47 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This is required by the following test:
- TP/HGRF/RH/BV-05-I [Read Client Characteristic Configuration Descriptors
for Report Characteristics – Input Report]
---
android/hog.c | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/android/hog.c b/android/hog.c
index f69fe2a..1069cca 100644
--- a/android/hog.c
+++ b/android/hog.c
@@ -177,6 +177,19 @@ static void write_ccc(GAttrib *attrib, uint16_t handle, void *user_data)
report_ccc_written_cb, user_data);
}
+static void ccc_read_cb(guint8 status, const guint8 *pdu, guint16 len,
+ gpointer user_data)
+{
+ struct report *report = user_data;
+
+ if (status != 0) {
+ error("Error reading CCC value: %s", att_ecode2str(status));
+ return;
+ }
+
+ write_ccc(report->hog->attrib, report->ccc_handle, report);
+}
+
static void report_reference_cb(guint8 status, const guint8 *pdu,
guint16 plen, gpointer user_data)
{
@@ -199,7 +212,8 @@ static void report_reference_cb(guint8 status, const guint8 *pdu,
/* Enable notifications only for Input Reports */
if (report->type == HOG_REPORT_TYPE_INPUT)
- write_ccc(report->hog->attrib, report->ccc_handle, report);
+ gatt_read_char(report->hog->attrib, report->ccc_handle,
+ ccc_read_cb, report);
}
static void external_report_reference_cb(guint8 status, const guint8 *pdu,
--
1.9.3
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH BlueZ 05/12] android/hog: Fix not resetting properly on detach
2014-06-30 13:47 [PATCH BlueZ 01/12] android/hog: Add bt_hog_send Luiz Augusto von Dentz
` (2 preceding siblings ...)
2014-06-30 13:47 ` [PATCH BlueZ 04/12] android/hog: Read CCC initial value for Input Report Luiz Augusto von Dentz
@ 2014-06-30 13:47 ` Luiz Augusto von Dentz
2014-06-30 13:47 ` [PATCH BlueZ 06/12] android/hog: Fix not detaching on free Luiz Augusto von Dentz
` (6 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Luiz Augusto von Dentz @ 2014-06-30 13:47 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
---
android/hog.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/android/hog.c b/android/hog.c
index 1069cca..2cce4e9 100644
--- a/android/hog.c
+++ b/android/hog.c
@@ -1007,7 +1007,10 @@ void bt_hog_detach(struct bt_hog *hog)
for (l = hog->reports; l; l = l->next) {
struct report *r = l->data;
- g_attrib_unregister(hog->attrib, r->notifyid);
+ if (r->notifyid > 0) {
+ g_attrib_unregister(hog->attrib, r->notifyid);
+ r->notifyid = 0;
+ }
}
if (hog->scpp)
--
1.9.3
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH BlueZ 06/12] android/hog: Fix not detaching on free
2014-06-30 13:47 [PATCH BlueZ 01/12] android/hog: Add bt_hog_send Luiz Augusto von Dentz
` (3 preceding siblings ...)
2014-06-30 13:47 ` [PATCH BlueZ 05/12] android/hog: Fix not resetting properly on detach Luiz Augusto von Dentz
@ 2014-06-30 13:47 ` Luiz Augusto von Dentz
2014-06-30 13:47 ` [PATCH BlueZ 07/12] android/hog: Remove unused code Luiz Augusto von Dentz
` (5 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Luiz Augusto von Dentz @ 2014-06-30 13:47 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
---
android/hog.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/android/hog.c b/android/hog.c
index 2cce4e9..5a758f3 100644
--- a/android/hog.c
+++ b/android/hog.c
@@ -712,6 +712,8 @@ static void hog_free(void *data)
{
struct bt_hog *hog = data;
+ bt_hog_detach(hog);
+
g_slist_free_full(hog->instances, hog_free);
bt_scpp_unref(hog->scpp);
@@ -719,7 +721,6 @@ static void hog_free(void *data)
bt_bas_unref(hog->bas);
bt_uhid_unref(hog->uhid);
g_slist_free_full(hog->reports, report_free);
- g_attrib_unref(hog->attrib);
g_free(hog->name);
g_free(hog->primary);
g_free(hog);
--
1.9.3
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH BlueZ 07/12] android/hog: Remove unused code
2014-06-30 13:47 [PATCH BlueZ 01/12] android/hog: Add bt_hog_send Luiz Augusto von Dentz
` (4 preceding siblings ...)
2014-06-30 13:47 ` [PATCH BlueZ 06/12] android/hog: Fix not detaching on free Luiz Augusto von Dentz
@ 2014-06-30 13:47 ` Luiz Augusto von Dentz
2014-06-30 13:47 ` [PATCH BlueZ 08/12] android/scpp: Fix not unregistering on detach Luiz Augusto von Dentz
` (4 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Luiz Augusto von Dentz @ 2014-06-30 13:47 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
report_free is only called once after detaching so this code is no longer
necessary.
---
android/hog.c | 4 ----
1 file changed, 4 deletions(-)
diff --git a/android/hog.c b/android/hog.c
index 5a758f3..319cb2a 100644
--- a/android/hog.c
+++ b/android/hog.c
@@ -699,10 +699,6 @@ static void char_discovered_cb(uint8_t status, GSList *chars, void *user_data)
static void report_free(void *data)
{
struct report *report = data;
- struct bt_hog *hog = report->hog;
-
- if (hog->attrib)
- g_attrib_unregister(hog->attrib, report->notifyid);
g_free(report->decl);
g_free(report);
--
1.9.3
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH BlueZ 08/12] android/scpp: Fix not unregistering on detach
2014-06-30 13:47 [PATCH BlueZ 01/12] android/hog: Add bt_hog_send Luiz Augusto von Dentz
` (5 preceding siblings ...)
2014-06-30 13:47 ` [PATCH BlueZ 07/12] android/hog: Remove unused code Luiz Augusto von Dentz
@ 2014-06-30 13:47 ` Luiz Augusto von Dentz
2014-06-30 13:47 ` [PATCH BlueZ 09/12] android/scpp: Fix not detaching on free Luiz Augusto von Dentz
` (3 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Luiz Augusto von Dentz @ 2014-06-30 13:47 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
---
android/scpp.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/android/scpp.c b/android/scpp.c
index 81d698b..b831680 100644
--- a/android/scpp.c
+++ b/android/scpp.c
@@ -270,6 +270,11 @@ void bt_scpp_detach(struct bt_scpp *scan)
if (!scan || !scan->attrib)
return;
+ if (scan->refresh_cb_id > 0) {
+ g_attrib_unregister(scan->attrib, scan->refresh_cb_id);
+ scan->refresh_cb_id = 0;
+ }
+
g_attrib_unref(scan->attrib);
scan->attrib = NULL;
}
--
1.9.3
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH BlueZ 09/12] android/scpp: Fix not detaching on free
2014-06-30 13:47 [PATCH BlueZ 01/12] android/hog: Add bt_hog_send Luiz Augusto von Dentz
` (6 preceding siblings ...)
2014-06-30 13:47 ` [PATCH BlueZ 08/12] android/scpp: Fix not unregistering on detach Luiz Augusto von Dentz
@ 2014-06-30 13:47 ` Luiz Augusto von Dentz
2014-06-30 13:47 ` [PATCH BlueZ 10/12] android/bas: Enable notification for Battery Level characteristic Luiz Augusto von Dentz
` (2 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: Luiz Augusto von Dentz @ 2014-06-30 13:47 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
---
android/scpp.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/android/scpp.c b/android/scpp.c
index b831680..9d8bb10 100644
--- a/android/scpp.c
+++ b/android/scpp.c
@@ -62,8 +62,7 @@ struct bt_scpp {
static void scpp_free(struct bt_scpp *scan)
{
- if (scan->attrib)
- g_attrib_unref(scan->attrib);
+ bt_scpp_detach(scan);
g_free(scan->primary);
g_free(scan);
--
1.9.3
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH BlueZ 10/12] android/bas: Enable notification for Battery Level characteristic
2014-06-30 13:47 [PATCH BlueZ 01/12] android/hog: Add bt_hog_send Luiz Augusto von Dentz
` (7 preceding siblings ...)
2014-06-30 13:47 ` [PATCH BlueZ 09/12] android/scpp: Fix not detaching on free Luiz Augusto von Dentz
@ 2014-06-30 13:47 ` Luiz Augusto von Dentz
2014-06-30 13:47 ` [PATCH BlueZ 11/12] android/bas: Read CCC initial value for Battery Level Luiz Augusto von Dentz
2014-06-30 13:47 ` [PATCH BlueZ 12/12] android/dis: Detach on free Luiz Augusto von Dentz
10 siblings, 0 replies; 12+ messages in thread
From: Luiz Augusto von Dentz @ 2014-06-30 13:47 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
---
android/bas.c | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++---
1 file changed, 67 insertions(+), 3 deletions(-)
diff --git a/android/bas.c b/android/bas.c
index ae7d274..996f3c0 100644
--- a/android/bas.c
+++ b/android/bas.c
@@ -41,17 +41,19 @@
#include "android/bas.h"
+#define ATT_NOTIFICATION_HEADER_SIZE 3
+
struct bt_bas {
int ref_count;
GAttrib *attrib;
struct gatt_primary *primary;
uint16_t handle;
+ guint id;
};
static void bas_free(struct bt_bas *bas)
{
- if (bas->attrib)
- g_attrib_unref(bas->attrib);
+ bt_bas_detach(bas);
g_free(bas->primary);
g_free(bas);
@@ -92,10 +94,61 @@ void bt_bas_unref(struct bt_bas *bas)
bas_free(bas);
}
+static void value_cb(const guint8 *pdu, guint16 len, gpointer user_data)
+{
+ DBG("Battery Level at %u", pdu[ATT_NOTIFICATION_HEADER_SIZE]);
+}
+
+static void ccc_written_cb(guint8 status, const guint8 *pdu,
+ guint16 plen, gpointer user_data)
+{
+ struct bt_bas *bas = user_data;
+
+ if (status != 0) {
+ error("Write Scan Refresh CCC failed: %s",
+ att_ecode2str(status));
+ return;
+ }
+
+ DBG("Battery Level: notification enabled");
+
+ bas->id = g_attrib_register(bas->attrib, ATT_OP_HANDLE_NOTIFY,
+ bas->handle, value_cb, bas, NULL);
+}
+
+static void write_ccc(GAttrib *attrib, uint16_t handle, void *user_data)
+{
+ uint8_t value[2];
+
+ put_le16(GATT_CLIENT_CHARAC_CFG_NOTIF_BIT, value);
+
+ gatt_write_char(attrib, handle, value, sizeof(value), ccc_written_cb,
+ user_data);
+}
+
+static void discover_descriptor_cb(uint8_t status, GSList *descs,
+ void *user_data)
+{
+ struct bt_bas *bas = user_data;
+ struct gatt_desc *desc;
+
+ if (status != 0) {
+ error("Discover descriptors failed: %s", att_ecode2str(status));
+ return;
+ }
+
+ /* There will be only one descriptor on list and it will be CCC */
+ desc = descs->data;
+
+ write_ccc(bas->attrib, desc->handle, bas);
+}
+
static void bas_discovered_cb(uint8_t status, GSList *chars, void *user_data)
{
struct bt_bas *bas = user_data;
struct gatt_char *chr;
+ uint16_t start, end;
+ bt_uuid_t uuid;
if (status) {
error("Battery: %s", att_ecode2str(status));
@@ -107,7 +160,13 @@ static void bas_discovered_cb(uint8_t status, GSList *chars, void *user_data)
DBG("Battery handle: 0x%04x", bas->handle);
- /* TODO: Add handling for notification */
+ start = chr->value_handle + 1;
+ end = bas->primary->range.end;
+
+ bt_uuid16_create(&uuid, GATT_CLIENT_CHARAC_CFG_UUID);
+
+ gatt_discover_desc(bas->attrib, start, end, &uuid,
+ discover_descriptor_cb, bas);
}
bool bt_bas_attach(struct bt_bas *bas, void *attrib)
@@ -132,6 +191,11 @@ void bt_bas_detach(struct bt_bas *bas)
if (!bas || !bas->attrib)
return;
+ if (bas->id > 0) {
+ g_attrib_unregister(bas->attrib, bas->id);
+ bas->id = 0;
+ }
+
g_attrib_unref(bas->attrib);
bas->attrib = NULL;
}
--
1.9.3
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH BlueZ 11/12] android/bas: Read CCC initial value for Battery Level
2014-06-30 13:47 [PATCH BlueZ 01/12] android/hog: Add bt_hog_send Luiz Augusto von Dentz
` (8 preceding siblings ...)
2014-06-30 13:47 ` [PATCH BlueZ 10/12] android/bas: Enable notification for Battery Level characteristic Luiz Augusto von Dentz
@ 2014-06-30 13:47 ` Luiz Augusto von Dentz
2014-06-30 13:47 ` [PATCH BlueZ 12/12] android/dis: Detach on free Luiz Augusto von Dentz
10 siblings, 0 replies; 12+ messages in thread
From: Luiz Augusto von Dentz @ 2014-06-30 13:47 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
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
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH BlueZ 12/12] android/dis: Detach on free
2014-06-30 13:47 [PATCH BlueZ 01/12] android/hog: Add bt_hog_send Luiz Augusto von Dentz
` (9 preceding siblings ...)
2014-06-30 13:47 ` [PATCH BlueZ 11/12] android/bas: Read CCC initial value for Battery Level Luiz Augusto von Dentz
@ 2014-06-30 13:47 ` Luiz Augusto von Dentz
10 siblings, 0 replies; 12+ messages in thread
From: Luiz Augusto von Dentz @ 2014-06-30 13:47 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
---
android/dis.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/android/dis.c b/android/dis.c
index ce6e063..0a2a18e 100644
--- a/android/dis.c
+++ b/android/dis.c
@@ -62,8 +62,7 @@ struct characteristic {
static void dis_free(struct bt_dis *dis)
{
- if (dis->attrib)
- g_attrib_unref(dis->attrib);
+ bt_dis_detach(dis);
g_free(dis->primary);
g_free(dis);
--
1.9.3
^ permalink raw reply related [flat|nested] 12+ messages in thread
end of thread, other threads:[~2014-06-30 13:47 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-06-30 13:47 [PATCH BlueZ 01/12] android/hog: Add bt_hog_send Luiz Augusto von Dentz
2014-06-30 13:47 ` [PATCH BlueZ 02/12] android/hidhost: Use bt_hog_send in bt_hid_send_data Luiz Augusto von Dentz
2014-06-30 13:47 ` [PATCH BlueZ 03/12] android/hog: Read initial value of Report characteristic Luiz Augusto von Dentz
2014-06-30 13:47 ` [PATCH BlueZ 04/12] android/hog: Read CCC initial value for Input Report Luiz Augusto von Dentz
2014-06-30 13:47 ` [PATCH BlueZ 05/12] android/hog: Fix not resetting properly on detach Luiz Augusto von Dentz
2014-06-30 13:47 ` [PATCH BlueZ 06/12] android/hog: Fix not detaching on free Luiz Augusto von Dentz
2014-06-30 13:47 ` [PATCH BlueZ 07/12] android/hog: Remove unused code Luiz Augusto von Dentz
2014-06-30 13:47 ` [PATCH BlueZ 08/12] android/scpp: Fix not unregistering on detach Luiz Augusto von Dentz
2014-06-30 13:47 ` [PATCH BlueZ 09/12] android/scpp: Fix not detaching on free Luiz Augusto von Dentz
2014-06-30 13:47 ` [PATCH BlueZ 10/12] android/bas: Enable notification for Battery Level characteristic Luiz Augusto von Dentz
2014-06-30 13:47 ` [PATCH BlueZ 11/12] android/bas: Read CCC initial value for Battery Level Luiz Augusto von Dentz
2014-06-30 13:47 ` [PATCH BlueZ 12/12] android/dis: Detach on free Luiz Augusto von Dentz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).