diff options
author | Luiz Augusto von Dentz <luiz.von.dentz@intel.com> | 2023-03-24 16:38:54 -0700 |
---|---|---|
committer | Luiz Augusto von Dentz <luiz.von.dentz@intel.com> | 2023-03-27 13:56:48 -0700 |
commit | cf72428156689a7bf2e2c6013788fedca08c6ff7 (patch) | |
tree | eb34325252f7fd38807efae837d6cb2aacc29bba /monitor | |
parent | 7610b9264147c387e0c12d17221ae83f97add776 (diff) | |
download | bluez-cf72428156689a7bf2e2c6013788fedca08c6ff7.tar.gz |
monitor/att: Print value when printing descriptors
This prints the value attribute information when print attribute
descriptors:
< ACL Data TX: Handle 3585 flags 0x00 dlen 9
ATT: Write Request (0x12) len 4
Handle: 0x002c Type: Client Characteristic Configuration (0x2902)
Value Handle: 0x002b Type: Battery Level (0x2a19)
Data: 0100
Notification (0x01)
Diffstat (limited to 'monitor')
-rw-r--r-- | monitor/att.c | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/monitor/att.c b/monitor/att.c index 18a5af05b..35a1fd066 100644 --- a/monitor/att.c +++ b/monitor/att.c @@ -122,6 +122,56 @@ static struct att_read *att_get_read(const struct l2cap_frame *frame) return queue_remove_if(data->reads, match_read_frame, (void *)frame); } +static void print_value(struct gatt_db_attribute *attr) +{ + uint16_t handle; + struct gatt_db_attribute *val; + const bt_uuid_t *uuid; + bt_uuid_t chrc = { + .type = BT_UUID16, + .value.u16 = 0x2803, + }; + char label[27]; + + uuid = gatt_db_attribute_get_type(attr); + if (!uuid) + return; + + /* Skip in case of characteristic declaration since it already prints + * the value handle and properties. + */ + if (!bt_uuid_cmp(uuid, &chrc)) + return; + + val = gatt_db_attribute_get_value(attr); + if (!val || val == attr) + return; + + uuid = gatt_db_attribute_get_type(val); + if (!uuid) + return; + + handle = gatt_db_attribute_get_handle(val); + if (!handle) + return; + + switch (uuid->type) { + case BT_UUID16: + sprintf(label, "Value Handle: 0x%4.4x Type", handle); + print_field("%s: %s (0x%4.4x)", label, + bt_uuid16_to_str(uuid->value.u16), + uuid->value.u16); + return; + case BT_UUID128: + sprintf(label, "Value Handle: 0x%4.4x Type", handle); + print_uuid(label, &uuid->value.u128, 16); + return; + case BT_UUID_UNSPEC: + case BT_UUID32: + break; + } +} + static void print_attribute(struct gatt_db_attribute *attr) { uint16_t handle; @@ -142,10 +192,12 @@ static void print_attribute(struct gatt_db_attribute *attr) print_field("%s: %s (0x%4.4x)", label, bt_uuid16_to_str(uuid->value.u16), uuid->value.u16); + print_value(attr); return; case BT_UUID128: sprintf(label, "Handle: 0x%4.4x Type", handle); print_uuid(label, &uuid->value.u128, 16); + print_value(attr); return; case BT_UUID_UNSPEC: case BT_UUID32: |