summaryrefslogtreecommitdiff
path: root/attrib/gatttool.c
diff options
context:
space:
mode:
authorSheldon Demario <sheldon.demario@openbossa.org>2010-11-19 08:34:57 -0500
committerJohan Hedberg <johan.hedberg@nokia.com>2010-11-19 17:25:30 +0200
commitad0e7f2c5ab9270369301f81eb5da1954eaab82f (patch)
tree4b162de15074f2a63a1993141d2277cda089b3e7 /attrib/gatttool.c
parent0e32ca24d11a83acf5f54f914dfed9ffb9da5610 (diff)
downloadbluez-ad0e7f2c5ab9270369301f81eb5da1954eaab82f.tar.gz
Implement Characteristic Value Read using UUID in the gatttool
Sub-procedure used to read a Characteristic Value when the client only knows the characteristic UUID and doesn't know the handle. More than one handle and attribute value pair can be returned, it is up to the user define the handles range based on the service handles range. Usage example: $gatttool --char-read --uuid=2a00 -i hcix -b xx:xx:xx:xx:xx:xx
Diffstat (limited to 'attrib/gatttool.c')
-rw-r--r--attrib/gatttool.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/attrib/gatttool.c b/attrib/gatttool.c
index e9614314f..d0ef6d30a 100644
--- a/attrib/gatttool.c
+++ b/attrib/gatttool.c
@@ -398,10 +398,49 @@ done:
g_main_loop_quit(event_loop);
}
+static void char_read_by_uuid_cb(guint8 status, const guint8 *pdu,
+ guint16 plen, gpointer user_data)
+{
+ struct att_data_list *list;
+ int i;
+
+ if (status != 0) {
+ g_printerr("Read characteristics by UUID failed: %s\n",
+ att_ecode2str(status));
+ goto done;
+ }
+
+ list = dec_read_by_type_resp(pdu, plen);
+ if (list == NULL)
+ goto done;
+
+ for (i = 0; i < list->num; i++) {
+ uint8_t *value = list->data[i];
+ int j;
+
+ g_print("handle: 0x%04x \t value: ", att_get_u16(value));
+ value += 2;
+ for (j = 0; j < list->len - 2; j++, value++)
+ g_print("%02x ", *value);
+ g_print("\n");
+ }
+
+ att_data_list_free(list);
+
+done:
+ g_main_loop_quit(event_loop);
+}
+
static gboolean characteristics_read(gpointer user_data)
{
GAttrib *attrib = user_data;
+ if (opt_uuid != NULL) {
+ gatt_read_char_by_uuid(attrib, opt_start, opt_end, opt_uuid,
+ char_read_by_uuid_cb, attrib);
+ return FALSE;
+ }
+
if (opt_handle <= 0) {
g_printerr("A valid handle is required\n");
g_main_loop_quit(event_loop);