* [PATCH] Extend discover characteristic by UUID in gatttool to fetch all values
@ 2010-11-23 12:37 Sheldon Demario
2010-11-25 12:21 ` Johan Hedberg
0 siblings, 1 reply; 2+ messages in thread
From: Sheldon Demario @ 2010-11-23 12:37 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Sheldon Demario
If the number of characteristics returned exceeds the MTU size, it will
be needed to ask for more data until the handle range is entirely
searched.
---
attrib/gatttool.c | 24 +++++++++++++++++++++++-
1 files changed, 23 insertions(+), 1 deletions(-)
diff --git a/attrib/gatttool.c b/attrib/gatttool.c
index d0ef6d3..6ad2cfb 100644
--- a/attrib/gatttool.c
+++ b/attrib/gatttool.c
@@ -401,9 +401,14 @@ done:
static void char_read_by_uuid_cb(guint8 status, const guint8 *pdu,
guint16 plen, gpointer user_data)
{
+ struct characteristic_data *char_data = user_data;
struct att_data_list *list;
int i;
+ if ((status == ATT_ECODE_ATTR_NOT_FOUND) &&
+ (char_data->start != opt_start))
+ goto done;
+
if (status != 0) {
g_printerr("Read characteristics by UUID failed: %s\n",
att_ecode2str(status));
@@ -418,6 +423,8 @@ static void char_read_by_uuid_cb(guint8 status, const guint8 *pdu,
uint8_t *value = list->data[i];
int j;
+ char_data->start = att_get_u16(value) + 1;
+
g_print("handle: 0x%04x \t value: ", att_get_u16(value));
value += 2;
for (j = 0; j < list->len - 2; j++, value++)
@@ -427,7 +434,14 @@ static void char_read_by_uuid_cb(guint8 status, const guint8 *pdu,
att_data_list_free(list);
+ gatt_read_char_by_uuid(char_data->attrib, char_data->start,
+ char_data->end, opt_uuid,
+ char_read_by_uuid_cb,
+ char_data);
+
+ return;
done:
+ g_free(char_data);
g_main_loop_quit(event_loop);
}
@@ -436,8 +450,16 @@ static gboolean characteristics_read(gpointer user_data)
GAttrib *attrib = user_data;
if (opt_uuid != NULL) {
+ struct characteristic_data *char_data;
+
+ char_data = g_new(struct characteristic_data, 1);
+ char_data->attrib = attrib;
+ char_data->start = opt_start;
+ char_data->end = opt_end;
+
gatt_read_char_by_uuid(attrib, opt_start, opt_end, opt_uuid,
- char_read_by_uuid_cb, attrib);
+ char_read_by_uuid_cb, char_data);
+
return FALSE;
}
--
1.7.3.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] Extend discover characteristic by UUID in gatttool to fetch all values
2010-11-23 12:37 [PATCH] Extend discover characteristic by UUID in gatttool to fetch all values Sheldon Demario
@ 2010-11-25 12:21 ` Johan Hedberg
0 siblings, 0 replies; 2+ messages in thread
From: Johan Hedberg @ 2010-11-25 12:21 UTC (permalink / raw)
To: Sheldon Demario; +Cc: linux-bluetooth
Hi Sheldon,
On Tue, Nov 23, 2010, Sheldon Demario wrote:
> If the number of characteristics returned exceeds the MTU size, it will
> be needed to ask for more data until the handle range is entirely
> searched.
> ---
> attrib/gatttool.c | 24 +++++++++++++++++++++++-
> 1 files changed, 23 insertions(+), 1 deletions(-)
Thanks.
> + if ((status == ATT_ECODE_ATTR_NOT_FOUND) &&
> + (char_data->start != opt_start))
> + goto done;
No need for the extra () here. However, since it was the only issue I
found I fixed it myself and pushed the patch upstream.
Johan
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2010-11-25 12:21 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-11-23 12:37 [PATCH] Extend discover characteristic by UUID in gatttool to fetch all values Sheldon Demario
2010-11-25 12:21 ` Johan Hedberg
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).