diff --git a/android/gatt.c b/android/gatt.c
index 6a580dc..1a1e857 100644
--- a/android/gatt.c
+++ b/android/gatt.c
struct characteristic {
struct element_id id;
struct gatt_char ch;
+ uint16_t end_handle;
struct queue *descriptors;
};
sizeof(ev), &ev);
}
-static void cache_all_srvc_chars(GSList *characteristics, struct queue *q)
+static void cache_all_srvc_chars(struct service *srvc,
+ GSList *characteristics)
{
uint16_t inst_id = 0;
bt_uuid_t uuid;
*/
ch->id.instance = ++inst_id;
- if (!queue_push_tail(q, ch)) {
+ /* Store end handle to use later for descriptors discovery */
+ if (characteristics->next) {
+ struct gatt_char *next = characteristics->next->data;
+ ch->end_handle = next->handle - 1;
+ } else {
+ ch->end_handle = srvc->primary ? srvc->prim.range.end :
+ srvc->incl.range.end;
+ }
+
+ if (!queue_push_tail(srvc->chars, ch)) {
error("gatt: Error while caching characteristic");
destroy_characteristic(ch);
}
struct discover_char_data *data = user_data;
if (queue_isempty(data->service->chars))
- cache_all_srvc_chars(characteristics, data->service->chars);
+ cache_all_srvc_chars(data->service, characteristics);
send_client_char_notify(queue_peek_head(data->service->chars),
data->conn_id, data->service);