aboutsummaryrefslogtreecommitdiffstats
path: root/attrib/gatt.c
diff options
context:
space:
mode:
authorSheldon Demario <sheldon.demario@openbossa.org>2011-03-16 19:00:56 -0300
committerJohan Hedberg <johan.hedberg@nokia.com>2011-03-17 14:50:59 +0200
commit922c5feb93adfb9773a854d8e89eb2c5604e632b (patch)
tree6437cff05ed5f701ba4aa21fece8c54dbe196dd9 /attrib/gatt.c
parent2da716f340e99d315a9c773ea95253d583ba2b74 (diff)
downloadbluez-922c5feb93adfb9773a854d8e89eb2c5604e632b.tar.gz
bluez-922c5feb93adfb9773a854d8e89eb2c5604e632b.tar.xz
bluez-922c5feb93adfb9773a854d8e89eb2c5604e632b.zip
Add discover characteristics by UUID to gatttool
According to the specification the characteristics discover and characteristics discover by UUID use the same opcode and the result should be filtered by callback.
Diffstat (limited to 'attrib/gatt.c')
-rw-r--r--attrib/gatt.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/attrib/gatt.c b/attrib/gatt.c
index 32bd4a0f..1cd651ca 100644
--- a/attrib/gatt.c
+++ b/attrib/gatt.c
@@ -40,7 +40,7 @@ struct discover_primary {
struct discover_char {
GAttrib *attrib;
- bt_uuid_t uuid;
+ bt_uuid_t *uuid;
uint16_t end;
GSList *characteristics;
gatt_cb_t cb;
@@ -59,6 +59,7 @@ static void discover_char_free(struct discover_char *dc)
g_slist_foreach(dc->characteristics, (GFunc) g_free, NULL);
g_slist_free(dc->characteristics);
g_attrib_unref(dc->attrib);
+ g_free(dc->uuid);
g_free(dc);
}
@@ -281,6 +282,9 @@ static void char_discovered_cb(guint8 status, const guint8 *ipdu, guint16 iplen,
goto done;
}
+ if (dc->uuid && bt_uuid_cmp(dc->uuid, &uuid))
+ break;
+
chars->handle = last;
chars->properties = value[2];
chars->value_handle = att_get_u16(&value[3]);
@@ -313,16 +317,17 @@ done:
}
guint gatt_discover_char(GAttrib *attrib, uint16_t start, uint16_t end,
- gatt_cb_t func, gpointer user_data)
+ bt_uuid_t *uuid, gatt_cb_t func,
+ gpointer user_data)
{
uint8_t pdu[ATT_DEFAULT_LE_MTU];
struct discover_char *dc;
+ bt_uuid_t type_uuid;
guint16 plen;
- bt_uuid_t uuid;
- bt_uuid16_create(&uuid, GATT_CHARAC_UUID);
+ bt_uuid16_create(&type_uuid, GATT_CHARAC_UUID);
- plen = enc_read_by_type_req(start, end, &uuid, pdu, sizeof(pdu));
+ plen = enc_read_by_type_req(start, end, &type_uuid, pdu, sizeof(pdu));
if (plen == 0)
return 0;
@@ -334,6 +339,7 @@ guint gatt_discover_char(GAttrib *attrib, uint16_t start, uint16_t end,
dc->cb = func;
dc->user_data = user_data;
dc->end = end;
+ dc->uuid = g_memdup(uuid, sizeof(bt_uuid_t));
return g_attrib_send(attrib, 0, pdu[0], pdu, plen, char_discovered_cb,
dc, NULL);