GATT: Optimize discovery
Luiz Augusto von Dentz
maintainercover GATT: Optimize discovery
From: Luiz Augusto von Dentz <[email protected]>
This reduces quite a bit the complexity of GATT discovery while reducing the amount traffic, this is achieved by using breadth-first like lookup.
Bellow is the traces with using Zephyr peripheral sample which uses a somewhat small MTU (65 bytes), it probably has even better results when using bigger MTU.
Luiz Augusto von Dentz (10):
shared/gatt-db: Add gatt_db_get_service shared/gatt-db: Add gatt_db_service_insert_included shared/gatt-client: Insert included attribute with handle shared/gatt-db: Add gatt_db_insert_included shared/gatt-client: Simplify included discovery unit/test-gatt: Adjust the PDUs to the new behavior shared/gatt-db: Add gatt_db_insert_characteristic shared/gatt-db: Add gatt_db_insert_descriptor shared/gatt-client: Simplify characteristics discovery unit/test-gatt: Adjust the PDUs for characteristic discovery
src/shared/gatt-client.c | 215 +++++++++++------------------------------------ src/shared/gatt-db.c | 116 ++++++++++++++++++++++--- src/shared/gatt-db.h | 30 +++++++ unit/test-gatt.c | 86 ++++++++----------- 4 files changed, 220 insertions(+), 227 deletions(-)
=== Before (~5 seconds) ===
[NEW] Primary Service
/org/bluez/hci0/dev_5A_7F_DE_51_75_60/service0006 0000180d-0000-1000-8000-00805f9b34fb Heart Rate [NEW] Characteristic /org/bluez/hci0/dev_5A_7F_DE_51_75_60/service0006/char0007 00002a37-0000-1000-8000-00805f9b34fb Heart Rate Measurement [NEW] Descriptor /org/bluez/hci0/dev_5A_7F_DE_51_75_60/service0006/char0007/desc0009 00002902-0000-1000-8000-00805f9b34fb Client Characteristic Configuration [NEW] Characteristic /org/bluez/hci0/dev_5A_7F_DE_51_75_60/service0006/char000a 00002a38-0000-1000-8000-00805f9b34fb Body Sensor Location [NEW] Characteristic /org/bluez/hci0/dev_5A_7F_DE_51_75_60/service0006/char000c 00002a39-0000-1000-8000-00805f9b34fb Heart Rate Control Point [NEW] Primary Service /org/bluez/hci0/dev_5A_7F_DE_51_75_60/service000e 0000180f-0000-1000-8000-00805f9b34fb Battery Service [NEW] Characteristic /org/bluez/hci0/dev_5A_7F_DE_51_75_60/service000e/char000f 00002a19-0000-1000-8000-00805f9b34fb Battery Level [NEW] Descriptor /org/bluez/hci0/dev_5A_7F_DE_51_75_60/service000e/char000f/desc0011 00002902-0000-1000-8000-00805f9b34fb Client Characteristic Configuration [NEW] Primary Service /org/bluez/hci0/dev_5A_7F_DE_51_75_60/service0012 00001805-0000-1000-8000-00805f9b34fb Current Time Service [NEW] Characteristic /org/bluez/hci0/dev_5A_7F_DE_51_75_60/service0012/char0013 00002a2b-0000-1000-8000-00805f9b34fb Current Time [NEW] Descriptor /org/bluez/hci0/dev_5A_7F_DE_51_75_60/service0012/char0013/desc0015 00002902-0000-1000-8000-00805f9b34fb Client Characteristic Configuration [NEW] Primary Service /org/bluez/hci0/dev_5A_7F_DE_51_75_60/service0016 0000180a-0000-1000-8000-00805f9b34fb Device Information [NEW] Characteristic /org/bluez/hci0/dev_5A_7F_DE_51_75_60/service0016/char0017 00002a24-0000-1000-8000-00805f9b34fb Model Number String [NEW] Characteristic /org/bluez/hci0/dev_5A_7F_DE_51_75_60/service0016/char0019 00002a29-0000-1000-8000-00805f9b34fb Manufacturer Name String [NEW] Primary Service /org/bluez/hci0/dev_5A_7F_DE_51_75_60/service001b 12345678-1234-5678-1234-56789abcdef0 Vendor specific [NEW] Characteristic /org/bluez/hci0/dev_5A_7F_DE_51_75_60/service001b/char001c 12345678-1234-5678-1234-56789abcdef1 Vendor specific [NEW] Descriptor /org/bluez/hci0/dev_5A_7F_DE_51_75_60/service001b/char001c/desc001e 00002902-0000-1000-8000-00805f9b34fb Client Characteristic Configuration [NEW] Characteristic /org/bluez/hci0/dev_5A_7F_DE_51_75_60/service001b/char001f 12345678-1234-5678-1234-56789abcdef2 Vendor specific [NEW] Characteristic /org/bluez/hci0/dev_5A_7F_DE_51_75_60/service001b/char0021 12345678-1234-5678-1234-56789abcdef3 Vendor specific [NEW] Descriptor /org/bluez/hci0/dev_5A_7F_DE_51_75_60/service001b/char0021/desc0023 00002900-0000-1000-8000-00805f9b34fb Characteristic Extended Properties [NEW] Characteristic /org/bluez/hci0/dev_5A_7F_DE_51_75_60/service001b/char0024 13345678-1234-5678-1334-56789abcdef3 Vendor specific
< ACL Data TX: Handle 76 flags 0x00 dlen 7 #24 15:51:07.180686
ATT: Exchange MTU Request (0x02) len 2
Client RX MTU: 517
Quoted 1 line
ACL Data RX: Handle 76 flags
0x02dlen 7 #26 15:51:07.295081
ATT: Exchange MTU Response (0x03) len 2
Server RX MTU: 65
< ACL Data TX: Handle 76 flags 0x00 dlen 11 #27 15:51:07.332810
ATT: Read By Group Type Request (0x10) len 6
Handle range: 0x0001-0xffff
Attribute group type: Primary Service (0x2800)Quoted 2 lines
ACL Data RX: Handle 76 flags
0x02dlen 27 #29 15:51:07.435148
ACL Data RX: Handle 76 flags0x01dlen 9 #30 15:51:07.435715
ATT: Read By Group Type Response (0x11) len 31
Attribute data length: 6
Attribute group list: 5 entries
Handle range: 0x0001-0x0005
UUID: Generic Access Profile (0x1800)
Handle range: 0x0006-0x000d
UUID: Heart Rate (0x180d)
Handle range: 0x000e-0x0011
UUID: Battery Service (0x180f)
Handle range: 0x0012-0x0015
UUID: Current Time Service (0x1805)
Handle range: 0x0016-0x001a
UUID: Device Information (0x180a)
< ACL Data TX: Handle 76 flags 0x00 dlen 11 #31 15:51:07.444516
ATT: Read By Group Type Request (0x10) len 6
Handle range: 0x001b-0xffff
Attribute group type: Primary Service (0x2800)Quoted 1 line
ACL Data RX: Handle 76 flags
0x02dlen 26 #33 15:51:07.575218
ATT: Read By Group Type Response (0x11) len 21
Attribute data length: 20
Attribute group list: 1 entry
Handle range: 0x001b-0x0025
UUID: Vendor specific (12345678-1234-5678-1234-56789abcdef0)
< ACL Data TX: Handle 76 flags 0x00 dlen 11 #34 15:51:07.577256
ATT: Read By Group Type Request (0x10) len 6
Handle range: 0x0026-0xffff
Attribute group type: Primary Service (0x2800)Quoted 1 line
ACL Data RX: Handle 76 flags
0x02dlen 9 #36 15:51:07.715060
ATT: Error Response (0x01) len 4
Read By Group Type Request (0x10)
Handle: 0x0026
Error: Attribute Not Found (0x0a)
< ACL Data TX: Handle 76 flags 0x00 dlen 11 #37 15:51:07.733790
ATT: Read By Group Type Request (0x10) len 6
Handle range: 0x0001-0xffff
Attribute group type: Secondary Service (0x2801)Quoted 1 line
ACL Data RX: Handle 76 flags
0x02dlen 9 #39 15:51:07.861760
ATT: Error Response (0x01) len 4
Read By Group Type Request (0x10)
Handle: 0x0001
Error: Attribute Not Found (0x0a)
< ACL Data TX: Handle 76 flags 0x00 dlen 11 #40 15:51:07.873951
ATT: Read By Type Request (0x08) len 6
Handle range: 0x0001-0x0005
Attribute type: Include (0x2802)Quoted 1 line
ACL Data RX: Handle 76 flags
0x02dlen 9 #42 15:51:07.995639
ATT: Error Response (0x01) len 4
Read By Type Request (0x08)
Handle: 0x0001
Error: Attribute Not Found (0x0a)
< ACL Data TX: Handle 76 flags 0x00 dlen 11 #43 15:51:07.998681
ATT: Read By Type Request (0x08) len 6
Handle range: 0x0006-0x000d
Attribute type: Include (0x2802)Quoted 1 line
ACL Data RX: Handle 76 flags
0x02dlen 9 #45 15:51:08.135117
ATT: Error Response (0x01) len 4
Read By Type Request (0x08)
Handle: 0x0006
Error: Attribute Not Found (0x0a)
< ACL Data TX: Handle 76 flags 0x00 dlen 11 #46 15:51:08.137222
ATT: Read By Type Request (0x08) len 6
Handle range: 0x000e-0x0011
Attribute type: Include (0x2802)Quoted 1 line
ACL Data RX: Handle 76 flags
0x02dlen 9 #48 15:51:08.281940
ATT: Error Response (0x01) len 4
Read By Type Request (0x08)
Handle: 0x000e
Error: Attribute Not Found (0x0a)
< ACL Data TX: Handle 76 flags 0x00 dlen 11 #49 15:51:08.284618
ATT: Read By Type Request (0x08) len 6
Handle range: 0x0012-0x0015
Attribute type: Include (0x2802)Quoted 1 line
ACL Data RX: Handle 76 flags
0x02dlen 9 #51 15:51:08.415537
ATT: Error Response (0x01) len 4
Read By Type Request (0x08)
Handle: 0x0012
Error: Attribute Not Found (0x0a)
< ACL Data TX: Handle 76 flags 0x00 dlen 11 #52 15:51:08.417313
ATT: Read By Type Request (0x08) len 6
Handle range: 0x0016-0x001a
Attribute type: Include (0x2802)Quoted 1 line
ACL Data RX: Handle 76 flags
0x02dlen 9 #54 15:51:08.555069
ATT: Error Response (0x01) len 4
Read By Type Request (0x08)
Handle: 0x0016
Error: Attribute Not Found (0x0a)
< ACL Data TX: Handle 76 flags 0x00 dlen 11 #55 15:51:08.555910
ATT: Read By Type Request (0x08) len 6
Handle range: 0x001b-0x0025
Attribute type: Include (0x2802)Quoted 1 line
ACL Data RX: Handle 76 flags
0x02dlen 9 #57 15:51:08.695065
ATT: Error Response (0x01) len 4
Read By Type Request (0x08)
Handle: 0x001b
Error: Attribute Not Found (0x0a)
< ACL Data TX: Handle 76 flags 0x00 dlen 11 #58 15:51:08.700168
ATT: Read By Type Request (0x08) len 6
Handle range: 0x0001-0x0005
Attribute type: Characteristic (0x2803)Quoted 1 line
ACL Data RX: Handle 76 flags
0x02dlen 20 #60 15:51:08.835157
ATT: Read By Type Response (0x09) len 15
Attribute data length: 7
Attribute data list: 2 entries
Handle: 0x0002
Value: 020300002a
Handle: 0x0004
Value: 020500012a
< ACL Data TX: Handle 76 flags 0x00 dlen 11 #61 15:51:08.840512
ATT: Read By Type Request (0x08) len 6
Handle range: 0x0005-0x0005
Attribute type: Characteristic (0x2803)Quoted 1 line
ACL Data RX: Handle 76 flags
0x02dlen 9 #63 15:51:08.975572
ATT: Error Response (0x01) len 4
Read By Type Request (0x08)
Handle: 0x0005
Error: Attribute Not Found (0x0a)
< ACL Data TX: Handle 76 flags 0x00 dlen 11 #64 15:51:09.011545
ATT: Read By Type Request (0x08) len 6
Handle range: 0x0006-0x000d
Attribute type: Characteristic (0x2803)Quoted 1 line
ACL Data RX: Handle 76 flags
0x02dlen 27 #66 15:51:09.115727
ATT: Read By Type Response (0x09) len 22
Attribute data length: 7
Attribute data list: 3 entries
Handle: 0x0007
Value: 100800372a
Handle: 0x000a
Value: 020b00382a
Handle: 0x000c
Value: 080d00392a
< ACL Data TX: Handle 76 flags 0x00 dlen 11 #67 15:51:09.118416
ATT: Read By Type Request (0x08) len 6
Handle range: 0x000d-0x000d
Attribute type: Characteristic (0x2803)Quoted 1 line
ACL Data RX: Handle 76 flags
0x02dlen 9 #69 15:51:09.255079
ATT: Error Response (0x01) len 4
Read By Type Request (0x08)
Handle: 0x000d
Error: Attribute Not Found (0x0a)
< ACL Data TX: Handle 76 flags 0x00 dlen 9 #70 15:51:09.260958
ATT: Find Information Request (0x04) len 4
Handle range: 0x0009-0x0009Quoted 1 line
ACL Data RX: Handle 76 flags
0x02dlen 10 #72 15:51:09.395088
ATT: Find Information Response (0x05) len 5
Format: UUID-16 (0x01)
Handle: 0x0009
UUID: Client Characteristic Configuration (0x2902)
< ACL Data TX: Handle 76 flags 0x00 dlen 11 #73 15:51:09.412720
ATT: Read By Type Request (0x08) len 6
Handle range: 0x000e-0x0011
Attribute type: Characteristic (0x2803)Quoted 1 line
ACL Data RX: Handle 76 flags
0x02dlen 13 #75 15:51:09.535534
ATT: Read By Type Response (0x09) len 8
Attribute data length: 7
Attribute data list: 1 entry
Handle: 0x000f
Value: 121000192a
< ACL Data TX: Handle 76 flags 0x00 dlen 11 #76 15:51:09.537262
ATT: Read By Type Request (0x08) len 6
Handle range: 0x0010-0x0011
Attribute type: Characteristic (0x2803)Quoted 1 line
ACL Data RX: Handle 76 flags
0x02dlen 9 #78 15:51:09.745068
ATT: Error Response (0x01) len 4
Read By Type Request (0x08)
Handle: 0x0010
Error: Attribute Not Found (0x0a)
< ACL Data TX: Handle 76 flags 0x00 dlen 9 #79 15:51:09.747585
ATT: Find Information Request (0x04) len 4
Handle range: 0x0011-0x0011Quoted 1 line
ACL Data RX: Handle 76 flags
0x02dlen 10 #81 15:51:09.891777
ATT: Find Information Response (0x05) len 5
Format: UUID-16 (0x01)
Handle: 0x0011
UUID: Client Characteristic Configuration (0x2902)
< ACL Data TX: Handle 76 flags 0x00 dlen 11 #82 15:51:09.894557
ATT: Read By Type Request (0x08) len 6
Handle range: 0x0012-0x0015
Attribute type: Characteristic (0x2803)Quoted 1 line
ACL Data RX: Handle 76 flags
0x02dlen 13 #84 15:51:10.025331
ATT: Read By Type Response (0x09) len 8
Attribute data length: 7
Attribute data list: 1 entry
Handle: 0x0013
Value: 1a14002b2a
< ACL Data TX: Handle 76 flags 0x00 dlen 11 #85 15:51:10.026486
ATT: Read By Type Request (0x08) len 6
Handle range: 0x0014-0x0015
Attribute type: Characteristic (0x2803)Quoted 1 line
ACL Data RX: Handle 76 flags
0x02dlen 9 #87 15:51:10.165084
ATT: Error Response (0x01) len 4
Read By Type Request (0x08)
Handle: 0x0014
Error: Attribute Not Found (0x0a)
< ACL Data TX: Handle 76 flags 0x00 dlen 9 #88 15:51:10.170516
ATT: Find Information Request (0x04) len 4
Handle range: 0x0015-0x0015Quoted 1 line
ACL Data RX: Handle 76 flags
0x02dlen 10 #90 15:51:10.305095
ATT: Find Information Response (0x05) len 5
Format: UUID-16 (0x01)
Handle: 0x0015
UUID: Client Characteristic Configuration (0x2902)
< ACL Data TX: Handle 76 flags 0x00 dlen 11 #91 15:51:10.307514
ATT: Read By Type Request (0x08) len 6
Handle range: 0x0016-0x001a
Attribute type: Characteristic (0x2803)Quoted 1 line
ACL Data RX: Handle 76 flags
0x02dlen 20 #93 15:51:10.445389
ATT: Read By Type Response (0x09) len 15
Attribute data length: 7
Attribute data list: 2 entries
Handle: 0x0017
Value: 021800242a
Handle: 0x0019
Value: 021a00292a
< ACL Data TX: Handle 76 flags 0x00 dlen 11 #94 15:51:10.445973
ATT: Read By Type Request (0x08) len 6
Handle range: 0x001a-0x001a
Attribute type: Characteristic (0x2803)Quoted 1 line
ACL Data RX: Handle 76 flags
0x02dlen 9 #96 15:51:10.585123
ATT: Error Response (0x01) len 4
Read By Type Request (0x08)
Handle: 0x001a
Error: Attribute Not Found (0x0a)
< ACL Data TX: Handle 76 flags 0x00 dlen 11 #97 15:51:10.594292
ATT: Read By Type Request (0x08) len 6
Handle range: 0x001b-0x0025
Attribute type: Characteristic (0x2803)Quoted 2 lines
ACL Data RX: Handle 76 flags
0x02dlen 27 #99 15:51:10.725259
ACL Data RX: Handle 76 flags0x01dlen 21 #100 15:51:10.725896
ATT: Read By Type Response (0x09) len 43
Attribute data length: 21
Attribute data list: 2 entries
Handle: 0x001c
Value: 2a1d00f1debc9a785634127856341278563412
Handle: 0x001f
Value: 0a2000f2debc9a785634127856341278563412
< ACL Data TX: Handle 76 flags 0x00 dlen 11 #101 15:51:10.728654
ATT: Read By Type Request (0x08) len 6
Handle range: 0x0020-0x0025
Attribute type: Characteristic (0x2803)Quoted 2 lines
ACL Data RX: Handle 76 flags
0x02dlen 27 #103 15:51:10.865172
ACL Data RX: Handle 76 flags0x01dlen 21 #104 15:51:10.866134
ATT: Read By Type Response (0x09) len 43
Attribute data length: 21
Attribute data list: 2 entries
Handle: 0x0021
Value: 8a2200f3debc9a785634127856341278563412
Handle: 0x0024
Value: 4a2500f3debc9a785634137856341278563413
< ACL Data TX: Handle 76 flags 0x00 dlen 11 #105 15:51:10.867215
ATT: Read By Type Request (0x08) len 6
Handle range: 0x0025-0x0025
Attribute type: Characteristic (0x2803)Quoted 1 line
ACL Data RX: Handle 76 flags
0x02dlen 9 #107 15:51:11.011665
ATT: Error Response (0x01) len 4
Read By Type Request (0x08)
Handle: 0x0025
Error: Attribute Not Found (0x0a)
< ACL Data TX: Handle 76 flags 0x00 dlen 9 #108 15:51:11.020693
ATT: Find Information Request (0x04) len 4
Handle range: 0x001e-0x001eQuoted 1 line
ACL Data RX: Handle 76 flags
0x02dlen 10 #110 15:51:11.145086
ATT: Find Information Response (0x05) len 5
Format: UUID-16 (0x01)
Handle: 0x001e
UUID: Client Characteristic Configuration (0x2902)
< ACL Data TX: Handle 76 flags 0x00 dlen 9 #111 15:51:11.147455
ATT: Find Information Request (0x04) len 4
Handle range: 0x0023-0x0023Quoted 1 line
ACL Data RX: Handle 76 flags
0x02dlen 10 #113 15:51:11.285087
ATT: Find Information Response (0x05) len 5
Format: UUID-16 (0x01)
Handle: 0x0023
UUID: Characteristic Extended Properties (0x2900)
< ACL Data TX: Handle 76 flags 0x00 dlen 7 #114 15:51:11.292722
ATT: Read Request (0x0a) len 2
Handle: 0x0023Quoted 1 line
ACL Data RX: Handle 76 flags
0x02dlen 7 #116 15:51:11.432110
ATT: Read Response (0x0b) len 2
Value: 0100
< ACL Data TX: Handle 76 flags 0x00 dlen 7 #117 15:51:11.568202
ATT: Read Request (0x0a) len 2
Handle: 0x0003Quoted 1 line
ACL Data RX: Handle 76 flags
0x02dlen 20 #119 15:51:11.705683
ATT: Read Response (0x0b) len 15
Value: 54657374207065726970686572616c
< ACL Data TX: Handle 76 flags 0x00 dlen 7 #120 15:51:11.712575
ATT: Read Request (0x0a) len 2
Handle: 0x0005Quoted 1 line
ACL Data RX: Handle 76 flags
0x02dlen 7 #122 15:51:11.851670
ATT: Read Response (0x0b) len 2
Value: 4103=== After (~3 seconds) ===
[NEW] Primary Service
/org/bluez/hci0/dev_5A_7F_DE_51_75_60/service0006 0000180d-0000-1000-8000-00805f9b34fb Heart Rate [NEW] Characteristic /org/bluez/hci0/dev_5A_7F_DE_51_75_60/service0006/char0007 00002a37-0000-1000-8000-00805f9b34fb Heart Rate Measurement [NEW] Descriptor /org/bluez/hci0/dev_5A_7F_DE_51_75_60/service0006/char0007/desc0009 00002902-0000-1000-8000-00805f9b34fb Client Characteristic Configuration [NEW] Characteristic /org/bluez/hci0/dev_5A_7F_DE_51_75_60/service0006/char000a 00002a38-0000-1000-8000-00805f9b34fb Body Sensor Location [NEW] Characteristic /org/bluez/hci0/dev_5A_7F_DE_51_75_60/service0006/char000c 00002a39-0000-1000-8000-00805f9b34fb Heart Rate Control Point [NEW] Primary Service /org/bluez/hci0/dev_5A_7F_DE_51_75_60/service000e 0000180f-0000-1000-8000-00805f9b34fb Battery Service [NEW] Characteristic /org/bluez/hci0/dev_5A_7F_DE_51_75_60/service000e/char000f 00002a19-0000-1000-8000-00805f9b34fb Battery Level [NEW] Descriptor /org/bluez/hci0/dev_5A_7F_DE_51_75_60/service000e/char000f/desc0011 00002902-0000-1000-8000-00805f9b34fb Client Characteristic Configuration [NEW] Primary Service /org/bluez/hci0/dev_5A_7F_DE_51_75_60/service0012 00001805-0000-1000-8000-00805f9b34fb Current Time Service [NEW] Characteristic /org/bluez/hci0/dev_5A_7F_DE_51_75_60/service0012/char0013 00002a2b-0000-1000-8000-00805f9b34fb Current Time [NEW] Descriptor /org/bluez/hci0/dev_5A_7F_DE_51_75_60/service0012/char0013/desc0015 00002902-0000-1000-8000-00805f9b34fb Client Characteristic Configuration [NEW] Primary Service /org/bluez/hci0/dev_5A_7F_DE_51_75_60/service0016 0000180a-0000-1000-8000-00805f9b34fb Device Information [NEW] Characteristic /org/bluez/hci0/dev_5A_7F_DE_51_75_60/service0016/char0017 00002a24-0000-1000-8000-00805f9b34fb Model Number String [NEW] Characteristic /org/bluez/hci0/dev_5A_7F_DE_51_75_60/service0016/char0019 00002a29-0000-1000-8000-00805f9b34fb Manufacturer Name String [NEW] Primary Service /org/bluez/hci0/dev_5A_7F_DE_51_75_60/service001b 12345678-1234-5678-1234-56789abcdef0 Vendor specific [NEW] Characteristic /org/bluez/hci0/dev_5A_7F_DE_51_75_60/service001b/char001c 12345678-1234-5678-1234-56789abcdef1 Vendor specific [NEW] Descriptor /org/bluez/hci0/dev_5A_7F_DE_51_75_60/service001b/char001c/desc001e 00002902-0000-1000-8000-00805f9b34fb Client Characteristic Configuration [NEW] Characteristic /org/bluez/hci0/dev_5A_7F_DE_51_75_60/service001b/char001f 12345678-1234-5678-1234-56789abcdef2 Vendor specific [NEW] Characteristic /org/bluez/hci0/dev_5A_7F_DE_51_75_60/service001b/char0021 12345678-1234-5678-1234-56789abcdef3 Vendor specific [NEW] Descriptor /org/bluez/hci0/dev_5A_7F_DE_51_75_60/service001b/char0021/desc0023 00002900-0000-1000-8000-00805f9b34fb Characteristic Extended Properties [NEW] Characteristic /org/bluez/hci0/dev_5A_7F_DE_51_75_60/service001b/char0024 13345678-1234-5678-1334-56789abcdef3 Vendor specific
< ACL Data TX: Handle 76 flags 0x00 dlen 7 #380 15:42:10.341758
ATT: Exchange MTU Request (0x02) len 2
Client RX MTU: 517
Quoted 1 line
ACL Data RX: Handle 76 flags
0x02dlen 7 #382 15:42:10.473974
ATT: Exchange MTU Response (0x03) len 2
Server RX MTU: 65
< ACL Data TX: Handle 76 flags 0x00 dlen 11 #383 15:42:10.517274
ATT: Read By Group Type Request (0x10) len 6
Handle range: 0x0001-0xffff
Attribute group type: Primary Service (0x2800)Quoted 2 lines
ACL Data RX: Handle 76 flags
0x02dlen 27 #385 15:42:10.614040
ACL Data RX: Handle 76 flags0x01dlen 9 #386 15:42:10.614164
ATT: Read By Group Type Response (0x11) len 31
Attribute data length: 6
Attribute group list: 5 entries
Handle range: 0x0001-0x0005
UUID: Generic Access Profile (0x1800)
Handle range: 0x0006-0x000d
UUID: Heart Rate (0x180d)
Handle range: 0x000e-0x0011
UUID: Battery Service (0x180f)
Handle range: 0x0012-0x0015
UUID: Current Time Service (0x1805)
Handle range: 0x0016-0x001a
UUID: Device Information (0x180a)
< ACL Data TX: Handle 76 flags 0x00 dlen 11 #387 15:42:10.621084
ATT: Read By Group Type Request (0x10) len 6
Handle range: 0x001b-0xffff
Attribute group type: Primary Service (0x2800)Quoted 1 line
ACL Data RX: Handle 76 flags
0x02dlen 26 #389 15:42:10.754092
ATT: Read By Group Type Response (0x11) len 21
Attribute data length: 20
Attribute group list: 1 entry
Handle range: 0x001b-0x0025
UUID: Vendor specific (12345678-1234-5678-1234-56789abcdef0)
< ACL Data TX: Handle 76 flags 0x00 dlen 11 #390 15:42:10.758998
ATT: Read By Group Type Request (0x10) len 6
Handle range: 0x0026-0xffff
Attribute group type: Primary Service (0x2800)Quoted 1 line
ACL Data RX: Handle 76 flags
0x02dlen 9 #392 15:42:10.893951
ATT: Error Response (0x01) len 4
Read By Group Type Request (0x10)
Handle: 0x0026
Error: Attribute Not Found (0x0a)
< ACL Data TX: Handle 76 flags 0x00 dlen 11 #393 15:42:10.940594
ATT: Read By Group Type Request (0x10) len 6
Handle range: 0x0001-0xffff
Attribute group type: Secondary Service (0x2801)Quoted 1 line
ACL Data RX: Handle 76 flags
0x02dlen 9 #395 15:42:11.033493
ATT: Error Response (0x01) len 4
Read By Group Type Request (0x10)
Handle: 0x0001
Error: Attribute Not Found (0x0a)
< ACL Data TX: Handle 76 flags 0x00 dlen 11 #396 15:42:11.038975
ATT: Read By Type Request (0x08) len 6
Handle range: 0x0001-0xffff
Attribute type: Include (0x2802)Quoted 1 line
ACL Data RX: Handle 76 flags
0x02dlen 9 #398 15:42:11.173677
ATT: Error Response (0x01) len 4
Read By Type Request (0x08)
Handle: 0x0001
Error: Attribute Not Found (0x0a)
< ACL Data TX: Handle 76 flags 0x00 dlen 11 #399 15:42:11.192954
ATT: Read By Type Request (0x08) len 6
Handle range: 0x0001-0xffff
Attribute type: Characteristic (0x2803)Quoted 3 lines
ACL Data RX: Handle 76 flags
0x02dlen 27 #401 15:42:11.313573
ACL Data RX: Handle 76 flags0x01dlen 27 #402 15:42:11.314233
ACL Data RX: Handle 76 flags0x01dlen 8 #403 15:42:11.321496
ATT: Read By Type Response (0x09) len 57
Attribute data length: 7
Attribute data list: 8 entries
Handle: 0x0002
Value: 020300002a
Handle: 0x0004
Value: 020500012a
Handle: 0x0007
Value: 100800372a
Handle: 0x000a
Value: 020b00382a
Handle: 0x000c
Value: 080d00392a
Handle: 0x000f
Value: 121000192a
Handle: 0x0013
Value: 1a14002b2a
Handle: 0x0017
Value: 021800242a
< ACL Data TX: Handle 76 flags 0x00 dlen 11 #404 15:42:11.329596
ATT: Read By Type Request (0x08) len 6
Handle range: 0x0018-0xffff
Attribute type: Characteristic (0x2803)Quoted 1 line
ACL Data RX: Handle 76 flags
0x02dlen 13 #406 15:42:11.453695
ATT: Read By Type Response (0x09) len 8
Attribute data length: 7
Attribute data list: 1 entry
Handle: 0x0019
Value: 021a00292a
< ACL Data TX: Handle 76 flags 0x00 dlen 11 #407 15:42:11.456347
ATT: Read By Type Request (0x08) len 6
Handle range: 0x001a-0xffff
Attribute type: Characteristic (0x2803)Quoted 2 lines
ACL Data RX: Handle 76 flags
0x02dlen 27 #409 15:42:11.593920
ACL Data RX: Handle 76 flags0x01dlen 21 #410 15:42:11.594382
ATT: Read By Type Response (0x09) len 43
Attribute data length: 21
Attribute data list: 2 entries
Handle: 0x001c
Value: 2a1d00f1debc9a785634127856341278563412
Handle: 0x001f
Value: 0a2000f2debc9a785634127856341278563412
< ACL Data TX: Handle 76 flags 0x00 dlen 11 #411 15:42:11.598132
ATT: Read By Type Request (0x08) len 6
Handle range: 0x0020-0xffff
Attribute type: Characteristic (0x2803)Quoted 2 lines
ACL Data RX: Handle 76 flags
0x02dlen 27 #413 15:42:11.733813
ACL Data RX: Handle 76 flags0x01dlen 21 #414 15:42:11.734279
ATT: Read By Type Response (0x09) len 43
Attribute data length: 21
Attribute data list: 2 entries
Handle: 0x0021
Value: 8a2200f3debc9a785634127856341278563412
Handle: 0x0024
Value: 4a2500f3debc9a785634137856341278563413
< ACL Data TX: Handle 76 flags 0x00 dlen 11 #415 15:42:11.737344
ATT: Read By Type Request (0x08) len 6
Handle range: 0x0025-0xffff
Attribute type: Characteristic (0x2803)Quoted 1 line
ACL Data RX: Handle 76 flags
0x02dlen 9 #417 15:42:11.880388
ATT: Error Response (0x01) len 4
Read By Type Request (0x08)
Handle: 0x0025
Error: Attribute Not Found (0x0a)
< ACL Data TX: Handle 76 flags 0x00 dlen 9 #418 15:42:11.933241
ATT: Find Information Request (0x04) len 4
Handle range: 0x0009-0x0009Quoted 1 line
ACL Data RX: Handle 76 flags
0x02dlen 10 #420 15:42:12.013704
ATT: Find Information Response (0x05) len 5
Format: UUID-16 (0x01)
Handle: 0x0009
UUID: Client Characteristic Configuration (0x2902)
< ACL Data TX: Handle 76 flags 0x00 dlen 9 #421 15:42:12.030887
ATT: Find Information Request (0x04) len 4
Handle range: 0x0011-0x0011Quoted 1 line
ACL Data RX: Handle 76 flags
0x02dlen 10 #423 15:42:12.153980
ATT: Find Information Response (0x05) len 5
Format: UUID-16 (0x01)
Handle: 0x0011
UUID: Client Characteristic Configuration (0x2902)
< ACL Data TX: Handle 76 flags 0x00 dlen 9 #424 15:42:12.161328
ATT: Find Information Request (0x04) len 4
Handle range: 0x0015-0x0015Quoted 1 line
ACL Data RX: Handle 76 flags
0x02dlen 10 #426 15:42:12.293534
ATT: Find Information Response (0x05) len 5
Format: UUID-16 (0x01)
Handle: 0x0015
UUID: Client Characteristic Configuration (0x2902)
< ACL Data TX: Handle 76 flags 0x00 dlen 9 #427 15:42:12.295493
ATT: Find Information Request (0x04) len 4
Handle range: 0x001e-0x001eQuoted 1 line
ACL Data RX: Handle 76 flags
0x02dlen 10 #429 15:42:12.433681
ATT: Find Information Response (0x05) len 5
Format: UUID-16 (0x01)
Handle: 0x001e
UUID: Client Characteristic Configuration (0x2902)
< ACL Data TX: Handle 76 flags 0x00 dlen 9 #430 15:42:12.437015
ATT: Find Information Request (0x04) len 4
Handle range: 0x0023-0x0023Quoted 1 line
ACL Data RX: Handle 76 flags
0x02dlen 10 #432 15:42:12.643547
ATT: Find Information Response (0x05) len 5
Format: UUID-16 (0x01)
Handle: 0x0023
UUID: Characteristic Extended Properties (0x2900)
< ACL Data TX: Handle 76 flags 0x00 dlen 7 #433 15:42:12.668272
ATT: Read Request (0x0a) len 2
Handle: 0x0023Quoted 1 line
ACL Data RX: Handle 76 flags
0x02dlen 7 #435 15:42:12.783946
ATT: Read Response (0x0b) len 2
Value: 0100
< ACL Data TX: Handle 76 flags 0x00 dlen 7 #436 15:42:12.941349
ATT: Read Request (0x0a) len 2
Handle: 0x0003Quoted 1 line
ACL Data RX: Handle 76 flags
0x02dlen 20 #438 15:42:13.064155
ATT: Read Response (0x0b) len 15
Value: 54657374207065726970686572616cSignature · 1 line
2.9.3
Luiz Augusto von Dentz
maintainerPATCH 1/10 shared/gatt-db: Add gatt_db_get_service
From: Luiz Augusto von Dentz <[email protected]>
This adds gatt_db_get_service which can be used to lookup service by handle.
--- src/shared/gatt-db.c | 21 ++++++++++++++++++--- src/shared/gatt-db.h | 3 +++ 2 files changed, 21 insertions(+), 3 deletions(-)
src/shared/gatt-db.c +18 -3
@@ -1316,20 +1316,35 @@ static bool find_service_for_handle(const void *data, const void *user_data)return (start <= handle) && (handle <= end); } -struct gatt_db_attribute *gatt_db_get_attribute (struct gatt_db *db, +struct gatt_db_attribute *gatt_db_get_service (struct gatt_db *db,uint16_t handle) {struct gatt_db_service *service; -int i;if (!db || !handle)return NULL ; service =queue_find (db->services, find_service_for_handle, -UINT_TO_PTR (handle)); +UINT_TO_PTR (handle));if (!service)return NULL ; +return service->attributes[0 ]; +} + +struct gatt_db_attribute *gatt_db_get_attribute (struct gatt_db *db, +uint16_t handle) +{ +struct gatt_db_attribute *attrib; +struct gatt_db_service *service; +int i; + + attrib =gatt_db_get_service (db, handle); +if (!attrib) +return NULL ; + + service = attrib->service; +for (i =0 ; i < service->num_handles; i++) {if (!service->attributes[i])continue ;
src/shared/gatt-db.h +3 -0
@@ -170,6 +170,9 @@ unsigned int gatt_db_register(struct gatt_db *db, gatt_db_destroy_func_t destroy);bool gatt_db_unregister (struct gatt_db *db,unsigned int id); +struct gatt_db_attribute *gatt_db_get_service (struct gatt_db *db, +uint16_t handle); +struct gatt_db_attribute *gatt_db_get_attribute (struct gatt_db *db,uint16_t handle);
Signature · 1 line
2.9.3
Luiz Augusto von Dentz
maintainerPATCH 2/10 shared/gatt-db: Add gatt_db_service_insert_included
In reply to Luiz Augusto von DentzFrom: Luiz Augusto von Dentz <[email protected]>
This introduces gatt_db_service_insert_included which is a variant of gatt_db_service_add_included containing the handle where it should be inserted.
--- src/shared/gatt-db.c | 40 ++++++++++++++++++++++++++++++++-------- src/shared/gatt-db.h | 4 ++++ 2 files changed, 36 insertions(+), 8 deletions(-)
src/shared/gatt-db.c +32 -8
@@ -834,19 +834,15 @@ gatt_db_service_add_descriptor(struct gatt_db_attribute *attrib, user_data); } -struct gatt_db_attribute * -gatt_db_service_add_included (struct gatt_db_attribute *attrib, +static struct gatt_db_attribute * +service_insert_included (struct gatt_db_service *service,uint16_t handle,struct gatt_db_attribute *include) { -struct gatt_db_service *service, *included; +struct gatt_db_service *included;uint8_t value[MAX_INCLUDED_VALUE_LEN ];uint16_t included_handle, len =0 ;int index; -if (!attrib || !include) -return NULL ; - - service = attrib->service; included = include->service;/* Adjust include to point to the first attribute */
@@ -873,7 +869,14 @@ gatt_db_service_add_included(struct gatt_db_attribute *attrib,if (!index)return NULL ; - service->attributes[index] =new_attribute (service,0 , +/* Check if handle is in within service range */ +if (handle && handle <= service->attributes[0 ]->handle) +return NULL ; + +if (!handle) + handle =get_handle_at_index (service, index -1 ) +1 ; + + service->attributes[index] =new_attribute (service, handle, &included_service_uuid, value, len);if (!service->attributes[index])
@@ -889,6 +892,27 @@ gatt_db_service_add_included(struct gatt_db_attribute *attrib,return attribute_update (service, index); } +struct gatt_db_attribute * +gatt_db_service_add_included (struct gatt_db_attribute *attrib, +struct gatt_db_attribute *include) +{ +if (!attrib || !include) +return NULL ; + +return service_insert_included (attrib->service,0 , include); +} + +struct gatt_db_attribute * +gatt_db_service_insert_included (struct gatt_db_attribute *attrib, +uint16_t handle, +struct gatt_db_attribute *include) +{ +if (!attrib || !handle || !include) +return NULL ; + +return service_insert_included (attrib->service, handle, include); +} +bool gatt_db_service_set_active (struct gatt_db_attribute *attrib,bool active) {struct gatt_db_service *service;
src/shared/gatt-db.h +4 -0
@@ -96,6 +96,10 @@ gatt_db_service_insert_descriptor(struct gatt_db_attribute *attrib,struct gatt_db_attribute *gatt_db_service_add_included (struct gatt_db_attribute *attrib,struct gatt_db_attribute *include); +struct gatt_db_attribute * +gatt_db_service_insert_included (struct gatt_db_attribute *attrib, +uint16_t handle, +struct gatt_db_attribute *include);bool gatt_db_service_set_active (struct gatt_db_attribute *attrib,bool active);bool gatt_db_service_get_active (struct gatt_db_attribute *attrib);
Signature · 1 line
2.9.3
Luiz Augusto von Dentz
maintainerPATCH 3/10 shared/gatt-client: Insert included attribute with handle
In reply to Luiz Augusto von DentzFrom: Luiz Augusto von Dentz <[email protected]>
This ensures the local representation matches exactly the handle used by the remote in its database.
--- src/shared/gatt-client.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
src/shared/gatt-client.c +1 -1
@@ -457,7 +457,7 @@ static void discover_incl_cb(bool success, uint8_t att_ecode,if (!tmp) goto failed; - tmp =gatt_db_service_add_included (attr, tmp); + tmp =gatt_db_service_insert_included (attr, handle, tmp);if (!tmp) goto failed;
Signature · 1 line
2.9.3
Luiz Augusto von Dentz
maintainerPATCH 4/10 shared/gatt-db: Add gatt_db_insert_included
In reply to Luiz Augusto von DentzFrom: Luiz Augusto von Dentz <[email protected]>
This introduces gatt_db_insert_included which is similar to gatt_db_service_insert_included but doesn't require the caller to know the service where the attribute should be inserted.
--- src/shared/gatt-db.c | 13 +++++++++++++ src/shared/gatt-db.h | 4 ++++ 2 files changed, 17 insertions(+)
src/shared/gatt-db.c +13 -0
@@ -913,6 +913,19 @@ gatt_db_service_insert_included(struct gatt_db_attribute *attrib,return service_insert_included (attrib->service, handle, include); } +struct gatt_db_attribute * +gatt_db_insert_included (struct gatt_db *db,uint16_t handle, +struct gatt_db_attribute *include) +{ +struct gatt_db_attribute *attrib; + + attrib =gatt_db_get_service (db, handle); +if (!attrib) +return NULL ; + +return service_insert_included (attrib->service, handle, include); +} +bool gatt_db_service_set_active (struct gatt_db_attribute *attrib,bool active) {struct gatt_db_service *service;
src/shared/gatt-db.h +4 -0
@@ -94,6 +94,10 @@ gatt_db_service_insert_descriptor(struct gatt_db_attribute *attrib, void *user_data);struct gatt_db_attribute * +gatt_db_insert_included (struct gatt_db *db,uint16_t handle, +struct gatt_db_attribute *include); + +struct gatt_db_attribute *gatt_db_service_add_included (struct gatt_db_attribute *attrib,struct gatt_db_attribute *include); struct gatt_db_attribute *
Signature · 1 line
2.9.3
Luiz Augusto von Dentz
maintainerPATCH 5/10 shared/gatt-client: Simplify included discovery
In reply to Luiz Augusto von DentzFrom: Luiz Augusto von Dentz <[email protected]>
Instead of doing include per service in a depth-first fashion do it in breadth-first like its done for primary and secondary since it is now possible to insert the include handle, not just append at the end, it is not longer necessary to fetch the attribute in order to have included handle.
As a bonus this can also speed up the discovery procedure since it will result in less traffic over the air.
--- src/shared/gatt-client.c | 89 ++++++++---------------------------------------- 1 file changed, 15 insertions(+), 74 deletions(-)
src/shared/gatt-client.c +15 -74
@@ -315,7 +315,6 @@ struct discovery_op {struct bt_gatt_client *client;struct queue *pending_svcs;struct queue *pending_chrcs; -struct queue *svcs;struct queue *ext_prop_desc;struct gatt_db_attribute *cur_svc;bool success;
@@ -331,7 +330,6 @@ static void discovery_op_free(struct discovery_op *op) {queue_destroy (op->pending_svcs,NULL );queue_destroy (op->pending_chrcs, free); -queue_destroy (op->svcs,NULL );queue_destroy (op->ext_prop_desc,NULL );free (op); }
@@ -357,7 +355,6 @@ static struct discovery_op *discovery_op_create(struct bt_gatt_client *client, op = new0(struct discovery_op, 1); op->pending_svcs =queue_new (); op->pending_chrcs =queue_new (); - op->svcs =queue_new (); op->ext_prop_desc =queue_new (); op->client = client; op->complete_func = complete_func;
@@ -408,7 +405,7 @@ static void discover_incl_cb(bool success, uint8_t att_ecode,struct discovery_op *op = user_data;struct bt_gatt_client *client = op->client;struct bt_gatt_iter iter; -struct gatt_db_attribute *attr, *tmp; +struct gatt_db_attribute *attr;uint16_t handle, start, end;uint128_t u128;bt_uuid_t uuid;
@@ -424,11 +421,6 @@ static void discover_incl_cb(bool success, uint8_t att_ecode, goto failed; } -/* Get the currently processed service */ - attr = op->cur_svc; -if (!attr) - goto failed; -if (!result || !bt_gatt_iter_init (&iter, result)) goto failed;
@@ -453,12 +445,12 @@ static void discover_incl_cb(bool success, uint8_t att_ecode,"handle: 0x%04x, start: 0x%04x, end: 0x%04x," "uuid: %s", handle, start, end, uuid_str); - tmp =gatt_db_get_attribute (client->db, start); -if (!tmp) + attr =gatt_db_get_attribute (client->db, start); +if (!attr) goto failed; - tmp =gatt_db_service_insert_included (attr, handle, tmp); -if (!tmp) + attr =gatt_db_insert_included (client->db, handle, attr); +if (!attr) goto failed;/*
@@ -467,62 +459,32 @@ static void discover_incl_cb(bool success, uint8_t att_ecode,* these entries, the correct handle must be assigned to the new * attribute. */ -if (gatt_db_attribute_get_handle (tmp) != handle) +if (gatt_db_attribute_get_handle (attr) != handle) goto failed; } next:/* Move on to the next service */ attr =queue_pop_head (op->pending_svcs); -if (!attr) { -/* -* We have processed all include definitions. Move on to -* characteristics. -*/ - attr =queue_pop_head (op->svcs); -if (!attr) - goto failed; - -if (!gatt_db_attribute_get_service_handles (attr, &start, &end)) - goto failed; - - op->cur_svc = attr; - - client->discovery_req =bt_gatt_discover_characteristics ( - client->att, - start, end, - discover_chrcs_cb, -discovery_op_ref (op), - discovery_op_unref); -if (client->discovery_req) -return ; - -util_debug (client->debug_callback, client->debug_data, -"Failed to start characteristic discovery" ); -discovery_op_unref (op); +if (!attr) goto failed; - } -queue_push_tail (op->svcs, attr); - op->cur_svc = attr;if (!gatt_db_attribute_get_service_handles (attr, &start, &end)) goto failed; -if (start == end) - goto next; + op->cur_svc = attr; - client->discovery_req =bt_gatt_discover_included_services (client->att, + client->discovery_req =bt_gatt_discover_characteristics (client->att, start, end, - discover_incl_cb, + discover_chrcs_cb,discovery_op_ref (op), discovery_op_unref);if (client->discovery_req)return ;util_debug (client->debug_callback, client->debug_data, -"Failed to start included discovery" ); +"Failed to start characteristic discovery" );discovery_op_unref (op); - failed:discovery_op_complete (op, false, att_ecode); }
@@ -674,7 +636,7 @@ static void ext_prop_read_cb(bool success, uint8_t att_ecode,/* Done with the current service */ gatt_db_service_set_active (op->cur_svc, true); - next_srv =queue_pop_head (op->svcs); + next_srv =queue_pop_head (op->pending_svcs);if (!next_srv) goto done;
@@ -782,7 +744,7 @@ next:/* Done with the current service */ gatt_db_service_set_active (op->cur_svc, true); - attr =queue_pop_head (op->svcs); + attr =queue_pop_head (op->pending_svcs);if (!attr) goto done;
@@ -888,7 +850,7 @@ next:/* Done with the current service */ gatt_db_service_set_active (op->cur_svc, true); - attr =queue_pop_head (op->svcs); + attr =queue_pop_head (op->pending_svcs);if (!attr) goto done;
@@ -994,29 +956,8 @@ static void discover_secondary_cb(bool success, uint8_t att_ecode, } next: -/* Sequentially discover included services */ - attr =queue_pop_head (op->pending_svcs); - -/* Complete with success if queue is empty */ -if (!attr) { - success = true; - goto done; - } - -/* -* Store the service in the svcs queue to be reused during -* characteristics discovery later. -*/ -queue_push_tail (op->svcs, attr); - op->cur_svc = attr; - -if (!gatt_db_attribute_get_service_handles (attr, &start, &end)) { - success = false; - goto done; - } - client->discovery_req =bt_gatt_discover_included_services (client->att, - start, end, + op->start, op->end, discover_incl_cb,discovery_op_ref (op), discovery_op_unref);
Signature · 1 line
2.9.3
Luiz Augusto von Dentz
maintainerPATCH 6/10 unit/test-gatt: Adjust the PDUs to the new behavior
In reply to Luiz Augusto von DentzFrom: Luiz Augusto von Dentz <[email protected]>
The new behavior of bt_gatt_client is to discovery the entire range (0x0001-0xffff) not service by service.
--- unit/test-gatt.c | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-)
unit/test-gatt.c +6 -14
@@ -134,10 +134,8 @@ struct context {raw_pdu (0x01 ,0x10 ,0x09 ,0x00 ,0x0a ), \raw_pdu (0x10 ,0x01 ,0x00 ,0xff ,0xff ,0x01 ,0x28 ), \raw_pdu (0x01 ,0x10 ,0x01 ,0x00 ,0x0a ), \ -raw_pdu (0x08 ,0x01 ,0x00 ,0x04 ,0x00 ,0x02 ,0x28 ), \ +raw_pdu (0x08 ,0x01 ,0x00 ,0xff ,0xff ,0x02 ,0x28 ), \raw_pdu (0x01 ,0x08 ,0x01 ,0x00 ,0x0a ), \ -raw_pdu (0x08 ,0x05 ,0x00 ,0x08 ,0x00 ,0x02 ,0x28 ), \ -raw_pdu (0x01 ,0x08 ,0x05 ,0x00 ,0x0a ), \raw_pdu (0x08 ,0x01 ,0x00 ,0x04 ,0x00 ,0x03 ,0x28 ), \raw_pdu (0x09 ,0x07 ,0x02 ,0x00 ,0x02 ,0x03 ,0x00 ,0x00 , \ 0x2a), \
@@ -163,10 +161,8 @@ struct context {raw_pdu (0x01 ,0x10 ,0x0b ,0x00 ,0x0a ), \raw_pdu (0x10 ,0x01 ,0x00 ,0xff ,0xff ,0x01 ,0x28 ), \raw_pdu (0x01 ,0x10 ,0x01 ,0x00 ,0x0a ), \ -raw_pdu (0x08 ,0x01 ,0x00 ,0x04 ,0x00 ,0x02 ,0x28 ), \ +raw_pdu (0x08 ,0x01 ,0x00 ,0xff ,0xff ,0x02 ,0x28 ), \raw_pdu (0x01 ,0x08 ,0x01 ,0x00 ,0x0a ), \ -raw_pdu (0x08 ,0x05 ,0x00 ,0x0a ,0x00 ,0x02 ,0x28 ), \ -raw_pdu (0x01 ,0x08 ,0x05 ,0x00 ,0x0a ), \raw_pdu (0x08 ,0x01 ,0x00 ,0x04 ,0x00 ,0x03 ,0x28 ), \raw_pdu (0x09 ,0x07 ,0x02 ,0x00 ,0x02 ,0x03 ,0x00 ,0x00 , \ 0x2a), \
@@ -193,10 +189,8 @@ struct context {raw_pdu (0x01 ,0x10 ,0x21 ,0x03 ,0x0a ), \raw_pdu (0x10 ,0x01 ,0x00 ,0xff ,0xff ,0x01 ,0x28 ), \raw_pdu (0x01 ,0x10 ,0x01 ,0x00 ,0x0a ), \ -raw_pdu (0x08 ,0x00 ,0x01 ,0x21 ,0x01 ,0x02 ,0x28 ), \ +raw_pdu (0x08 ,0x01 ,0x00 ,0xff ,0xff ,0x02 ,0x28 ), \raw_pdu (0x01 ,0x08 ,0x00 ,0x01 ,0x0a ), \ -raw_pdu (0x08 ,0x00 ,0x03 ,0x20 ,0x03 ,0x02 ,0x28 ), \ -raw_pdu (0x01 ,0x08 ,0x00 ,0x03 ,0x0a ), \raw_pdu (0x08 ,0x00 ,0x01 ,0x21 ,0x01 ,0x03 ,0x28 ), \raw_pdu (0x09 ,0x07 ,0x10 ,0x01 ,0x02 ,0x11 ,0x01 ,0x00 , \ 0x2a, 0x20, 0x01, 0x02, 0x21, 0x01, 0x01, 0x2a),\
@@ -249,13 +243,11 @@ struct context { raw_pdu(0x01, 0x10, 0x11, 0x00, 0x0a)#define INCLUDE_DISC_SMALL_DB \ - raw_pdu(0x08, 0x10, 0xf0, 0x18, 0xf0, 0x02, 0x28), \ + raw_pdu(0x08, 0x01, 0x00, 0xff, 0xff, 0x02, 0x28), \ raw_pdu(0x09, 0x08, 0x11, 0xf0, 0x01, 0x00, 0x0f, 0x00, \ 0x0a, 0x18), \ - raw_pdu(0x08, 0x12, 0xf0, 0x18, 0xf0, 0x02, 0x28), \ - raw_pdu(0x01, 0x08, 0x12, 0xf0, 0x0a), \ - raw_pdu(0x08, 0x01, 0x00, 0x10, 0x00, 0x02, 0x28), \ - raw_pdu(0x01, 0x08, 0x01, 0x00, 0x0a) + raw_pdu(0x08, 0x12, 0xf0, 0xff, 0xff, 0x02, 0x28), \ + raw_pdu(0x01, 0x08, 0x12, 0xf0, 0x0a)#define CHARACTERISTIC_DISC_SMALL_DB \ raw_pdu(0x08, 0x10, 0xf0, 0x18, 0xf0, 0x03, 0x28), \
Signature · 1 line
2.9.3
Luiz Augusto von Dentz
maintainerPATCH 7/10 shared/gatt-db: Add gatt_db_insert_characteristic
In reply to Luiz Augusto von DentzFrom: Luiz Augusto von Dentz <[email protected]>
This introduces gatt_db_insert_characteristic which is similar to gatt_db_service_insert_charactersitic but doesn't require the caller to know the service where the attribute should be inserted.
--- src/shared/gatt-db.c | 22 ++++++++++++++++++++++ src/shared/gatt-db.h | 10 ++++++++++ 2 files changed, 32 insertions(+)
src/shared/gatt-db.c +22 -0
@@ -733,6 +733,28 @@ service_insert_characteristic(struct gatt_db_service *service, }struct gatt_db_attribute * +gatt_db_insert_characteristic (struct gatt_db *db, +uint16_t handle, +const bt_uuid_t *uuid, +uint32_t permissions, +uint8_t properties, +gatt_db_read_t read_func, +gatt_db_write_t write_func, +void *user_data) +{ +struct gatt_db_attribute *attrib; + + attrib =gatt_db_get_service (db, handle); +if (!attrib) +return NULL ; + +return service_insert_characteristic (attrib->service, handle, uuid, + permissions, properties, + read_func, write_func, + user_data); +} + +struct gatt_db_attribute * gatt_db_service_insert_characteristic(struct gatt_db_attribute *attrib, uint16_t handle, const bt_uuid_t *uuid,
src/shared/gatt-db.h +10 -0
@@ -78,6 +78,16 @@ gatt_db_service_insert_characteristic(struct gatt_db_attribute *attrib, void *user_data);struct gatt_db_attribute * +gatt_db_insert_characteristic (struct gatt_db *db, +uint16_t handle, +const bt_uuid_t *uuid, +uint32_t permissions, +uint8_t properties, +gatt_db_read_t read_func, +gatt_db_write_t write_func, +void *user_data); + +struct gatt_db_attribute * gatt_db_service_add_descriptor(struct gatt_db_attribute *attrib, const bt_uuid_t *uuid, uint32_t permissions,
Signature · 1 line
2.9.3
Luiz Augusto von Dentz
maintainerPATCH 8/10 shared/gatt-db: Add gatt_db_insert_descriptor
In reply to Luiz Augusto von DentzFrom: Luiz Augusto von Dentz <[email protected]>
This introduces gatt_db_insert_descriptor which is similar to gatt_db_service_insert_descriptor but doesn't require the caller to know the service where the attribute should be inserted.
--- src/shared/gatt-db.c | 20 ++++++++++++++++++++ src/shared/gatt-db.h | 9 +++++++++ 2 files changed, 29 insertions(+)
src/shared/gatt-db.c +20 -0
@@ -824,6 +824,26 @@ service_insert_descriptor(struct gatt_db_service *service, }struct gatt_db_attribute * +gatt_db_insert_descriptor (struct gatt_db *db, +uint16_t handle, +const bt_uuid_t *uuid, +uint32_t permissions, +gatt_db_read_t read_func, +gatt_db_write_t write_func, +void *user_data) +{ +struct gatt_db_attribute *attrib; + + attrib =gatt_db_get_service (db, handle); +if (!attrib) +return NULL ; + +return service_insert_descriptor (attrib->service, handle, uuid, + permissions, read_func, write_func, + user_data); +} + +struct gatt_db_attribute * gatt_db_service_insert_descriptor(struct gatt_db_attribute *attrib, uint16_t handle, const bt_uuid_t *uuid,
src/shared/gatt-db.h +9 -0
@@ -88,6 +88,15 @@ gatt_db_insert_characteristic(struct gatt_db *db, void *user_data);struct gatt_db_attribute * +gatt_db_insert_descriptor (struct gatt_db *db, +uint16_t handle, +const bt_uuid_t *uuid, +uint32_t permissions, +gatt_db_read_t read_func, +gatt_db_write_t write_func, +void *user_data); + +struct gatt_db_attribute * gatt_db_service_add_descriptor(struct gatt_db_attribute *attrib, const bt_uuid_t *uuid, uint32_t permissions,
Signature · 1 line
2.9.3
Luiz Augusto von Dentz
maintainerPATCH 9/10 shared/gatt-client: Simplify characteristics discovery
In reply to Luiz Augusto von DentzFrom: Luiz Augusto von Dentz <[email protected]>
Instead of discovering characteristics per service in a depth-first fashion do it in breadth-first like its done for primary, secondary and included.
As a bonus this can also speed up the discovery procedure since it will result in less traffic over the air.
--- src/shared/gatt-client.c | 138 ++++++++++++++--------------------------------- 1 file changed, 40 insertions(+), 98 deletions(-)
src/shared/gatt-client.c +40 -98
@@ -464,18 +464,8 @@ static void discover_incl_cb(bool success, uint8_t att_ecode, } next: -/* Move on to the next service */ - attr =queue_pop_head (op->pending_svcs); -if (!attr) - goto failed; - -if (!gatt_db_attribute_get_service_handles (attr, &start, &end)) - goto failed; - - op->cur_svc = attr; - client->discovery_req =bt_gatt_discover_characteristics (client->att, - start, end, + op->start, op->end, discover_chrcs_cb,discovery_op_ref (op), discovery_op_unref);
@@ -511,7 +501,10 @@ static bool discover_descs(struct discovery_op *op, bool *discovering) *discovering = false;while ((chrc_data =queue_pop_head (op->pending_chrcs))) { - attr = gatt_db_service_insert_characteristic(op->cur_svc, +struct gatt_db_attribute *svc; +uint16_t start, end; + + attr = gatt_db_insert_characteristic(client->db, chrc_data->value_handle, &chrc_data->uuid, 0, chrc_data->properties,
@@ -528,6 +521,25 @@ static bool discover_descs(struct discovery_op *op, bool *discovering) chrc_data->value_handle) goto failed; +/* Adjust current service */ + svc =gatt_db_get_service (client->db, chrc_data->value_handle); +if (op->cur_svc != svc) { +queue_remove (op->pending_svcs, svc); + +/* Done with the current service */ +gatt_db_service_set_active (op->cur_svc, true); + op->cur_svc = svc; + } + +gatt_db_attribute_get_service_handles (svc, &start, &end); + +/* +* Ajust end_handle in case the next chrc is not within the +* same service. +*/ +if (chrc_data->end_handle > end) + chrc_data->end_handle = end; +/* * check for descriptors presence, before initializing the * desc_handle and avoid integer overflow during desc_handle
@@ -537,6 +549,7 @@ static bool discover_descs(struct discovery_op *op, bool *discovering)free (chrc_data);continue ; } + desc_start = chrc_data->value_handle +1 ; client->discovery_req = bt_gatt_discover_descriptors(
@@ -607,8 +620,6 @@ static void ext_prop_read_cb(bool success, uint8_t att_ecode,struct bt_gatt_client *client = op->client;bool discovering;struct gatt_db_attribute *desc_attr =NULL ; -struct gatt_db_attribute *next_srv; -uint16_t start, end;util_debug (client->debug_callback, client->debug_data,"Ext. prop value: 0x%04x" , (uint16_t )value[0 ]);
@@ -625,42 +636,16 @@ static void ext_prop_read_cb(bool success, uint8_t att_ecode,if (read_ext_prop_desc (op))return ; -/* Continue with discovery */ -do { -if (!discover_descs (op, &discovering)) - goto failed; - -if (discovering) -return ; - -/* Done with the current service */ -gatt_db_service_set_active (op->cur_svc, true); - - next_srv =queue_pop_head (op->pending_svcs); -if (!next_srv) - goto done; - -if (!gatt_db_attribute_get_service_handles (next_srv, &start, - &end)) +if (!discover_descs (op, &discovering)) goto failed; - }while (start == end); - -/* Move on to the next service */ - op->cur_svc = next_srv; - - client->discovery_req =bt_gatt_discover_characteristics (client->att, - start, end, - discover_chrcs_cb, -discovery_op_ref (op), - discovery_op_unref); -if (client->discovery_req) +if (discovering)return ; -util_debug (client->debug_callback, client->debug_data, -"Failed to start characteristic discovery" ); +/* Done with the current service */ +gatt_db_service_set_active (op->cur_svc, true); -discovery_op_unref (op); + goto done; failed: success = false;
@@ -677,7 +662,7 @@ static void discover_descs_cb(bool success, uint8_t att_ecode,struct bt_gatt_client *client = op->client;struct bt_gatt_iter iter;struct gatt_db_attribute *attr; -uint16_t handle, start, end; +uint16_t handle;uint128_t u128;bt_uuid_t uuid;char uuid_str[MAX_LEN_UUID_STR ];
@@ -717,11 +702,15 @@ static void discover_descs_cb(bool success, uint8_t att_ecode,"handle: 0x%04x, uuid: %s" , handle, uuid_str); - attr =gatt_db_service_insert_descriptor (op->cur_svc, handle, + attr =gatt_db_insert_descriptor (client->db, handle, &uuid,0 ,NULL ,NULL ,NULL ); -if (!attr) +if (!attr) { +util_debug (client->debug_callback, client->debug_data, +"Failed to insert descriptor at 0x%04x" , + handle); goto failed; + }if (gatt_db_attribute_get_handle (attr) != handle) goto failed;
@@ -744,30 +733,7 @@ next:/* Done with the current service */ gatt_db_service_set_active (op->cur_svc, true); - attr =queue_pop_head (op->pending_svcs); -if (!attr) - goto done; - -if (!gatt_db_attribute_get_service_handles (attr, &start, &end)) - goto failed; - -if (start == end) - goto next; - -/* Move on to the next service */ - op->cur_svc = attr; - - client->discovery_req =bt_gatt_discover_characteristics (client->att, - start, end, - discover_chrcs_cb, -discovery_op_ref (op), - discovery_op_unref); -if (client->discovery_req) -return ; - -util_debug (client->debug_callback, client->debug_data, -"Failed to start characteristic discovery" ); -discovery_op_unref (op); + goto done; failed: success = false;
@@ -783,7 +749,6 @@ static void discover_chrcs_cb(bool success, uint8_t att_ecode,struct discovery_op *op = user_data;struct bt_gatt_client *client = op->client;struct bt_gatt_iter iter; -struct gatt_db_attribute *attr;struct chrc *chrc_data;uint16_t start, end, value;uint8_t properties;
@@ -804,7 +769,7 @@ static void discover_chrcs_cb(bool success, uint8_t att_ecode, goto done; } -if (!op->cur_svc || !result || !bt_gatt_iter_init (&iter, result)) +if (!result || !bt_gatt_iter_init (&iter, result)) goto failed; chrc_count =bt_gatt_result_characteristic_count (result);
@@ -850,30 +815,7 @@ next:/* Done with the current service */ gatt_db_service_set_active (op->cur_svc, true); - attr =queue_pop_head (op->pending_svcs); -if (!attr) - goto done; - -if (!gatt_db_attribute_get_service_handles (attr, &start, &end)) - goto failed; - -if (start == end) - goto next; - -/* Move on to the next service */ - op->cur_svc = attr; - - client->discovery_req =bt_gatt_discover_characteristics (client->att, - start, end, - discover_chrcs_cb, -discovery_op_ref (op), - discovery_op_unref); -if (client->discovery_req) -return ; - -util_debug (client->debug_callback, client->debug_data, -"Failed to start characteristic discovery" ); -discovery_op_unref (op); + goto done; failed: success = false;
Signature · 1 line
2.9.3
Luiz Augusto von Dentz
maintainerPATCH 10/10 unit/test-gatt: Adjust the PDUs for characteristic discovery
In reply to Luiz Augusto von DentzFrom: Luiz Augusto von Dentz <[email protected]>
The new behavior of bt_gatt_client is to discovery the characteristics of the entire range (0x0001-0xffff) not service by service.
--- unit/test-gatt.c | 66 ++++++++++++++++++++++++++------------------------------ 1 file changed, 30 insertions(+), 36 deletions(-)
unit/test-gatt.c +30 -36
@@ -136,18 +136,16 @@ struct context {raw_pdu (0x01 ,0x10 ,0x01 ,0x00 ,0x0a ), \raw_pdu (0x08 ,0x01 ,0x00 ,0xff ,0xff ,0x02 ,0x28 ), \raw_pdu (0x01 ,0x08 ,0x01 ,0x00 ,0x0a ), \ -raw_pdu (0x08 ,0x01 ,0x00 ,0x04 ,0x00 ,0x03 ,0x28 ), \ +raw_pdu (0x08 ,0x01 ,0x00 ,0xff ,0xff ,0x03 ,0x28 ), \raw_pdu (0x09 ,0x07 ,0x02 ,0x00 ,0x02 ,0x03 ,0x00 ,0x00 , \0x2a ), \ -raw_pdu (0x08 ,0x03 ,0x00 ,0x04 ,0x00 ,0x03 ,0x28 ), \ -raw_pdu (0x01 ,0x08 ,0x03 ,0x00 ,0x0a ), \ -raw_pdu (0x04 ,0x04 ,0x00 ,0x04 ,0x00 ), \ -raw_pdu (0x05 ,0x01 ,0x04 ,0x00 ,0x01 ,0x29 ), \ -raw_pdu (0x08 ,0x05 ,0x00 ,0x08 ,0x00 ,0x03 ,0x28 ), \ +raw_pdu (0x08 ,0x03 ,0x00 ,0xff ,0xff ,0x03 ,0x28 ), \raw_pdu (0x09 ,0x07 ,0x06 ,0x00 ,0x0a ,0x07 ,0x00 ,0x29 , \0x2a ), \ -raw_pdu (0x08 ,0x07 ,0x00 ,0x08 ,0x00 ,0x03 ,0x28 ), \ +raw_pdu (0x08 ,0x07 ,0x00 ,0xff ,0xff ,0x03 ,0x28 ), \raw_pdu (0x01 ,0x08 ,0x07 ,0x00 ,0x0a ), \ +raw_pdu (0x04 ,0x04 ,0x00 ,0x04 ,0x00 ), \ +raw_pdu (0x05 ,0x01 ,0x04 ,0x00 ,0x01 ,0x29 ), \raw_pdu (0x04 ,0x08 ,0x00 ,0x08 ,0x00 ), \raw_pdu (0x05 ,0x01 ,0x08 ,0x00 ,0x01 ,0x29 )
@@ -163,18 +161,16 @@ struct context {raw_pdu (0x01 ,0x10 ,0x01 ,0x00 ,0x0a ), \raw_pdu (0x08 ,0x01 ,0x00 ,0xff ,0xff ,0x02 ,0x28 ), \raw_pdu (0x01 ,0x08 ,0x01 ,0x00 ,0x0a ), \ -raw_pdu (0x08 ,0x01 ,0x00 ,0x04 ,0x00 ,0x03 ,0x28 ), \ +raw_pdu (0x08 ,0x01 ,0x00 ,0xff ,0xff ,0x03 ,0x28 ), \raw_pdu (0x09 ,0x07 ,0x02 ,0x00 ,0x02 ,0x03 ,0x00 ,0x00 , \0x2a ), \ -raw_pdu (0x08 ,0x03 ,0x00 ,0x04 ,0x00 ,0x03 ,0x28 ), \ -raw_pdu (0x01 ,0x08 ,0x03 ,0x00 ,0x0a ), \ -raw_pdu (0x04 ,0x04 ,0x00 ,0x04 ,0x00 ), \ -raw_pdu (0x05 ,0x01 ,0x04 ,0x00 ,0x01 ,0x29 ), \ -raw_pdu (0x08 ,0x05 ,0x00 ,0x0a ,0x00 ,0x03 ,0x28 ), \ +raw_pdu (0x08 ,0x03 ,0x00 ,0xff ,0xff ,0x03 ,0x28 ), \raw_pdu (0x09 ,0x07 ,0x07 ,0x00 ,0x0a ,0x08 ,0x00 ,0x29 , \0x2a ), \ -raw_pdu (0x08 ,0x08 ,0x00 ,0x0a ,0x00 ,0x03 ,0x28 ), \ +raw_pdu (0x08 ,0x08 ,0x00 ,0xff ,0xff ,0x03 ,0x28 ), \raw_pdu (0x01 ,0x08 ,0x08 ,0x00 ,0x0a ), \ +raw_pdu (0x04 ,0x04 ,0x00 ,0x04 ,0x00 ), \ +raw_pdu (0x05 ,0x01 ,0x04 ,0x00 ,0x01 ,0x29 ), \raw_pdu (0x04 ,0x09 ,0x00 ,0x0a ,0x00 ), \raw_pdu (0x05 ,0x01 ,0x0a ,0x00 ,0x01 ,0x29 )
@@ -191,18 +187,16 @@ struct context {raw_pdu (0x01 ,0x10 ,0x01 ,0x00 ,0x0a ), \raw_pdu (0x08 ,0x01 ,0x00 ,0xff ,0xff ,0x02 ,0x28 ), \raw_pdu (0x01 ,0x08 ,0x00 ,0x01 ,0x0a ), \ -raw_pdu (0x08 ,0x00 ,0x01 ,0x21 ,0x01 ,0x03 ,0x28 ), \ +raw_pdu (0x08 ,0x01 ,0x00 ,0xff ,0xff ,0x03 ,0x28 ), \raw_pdu (0x09 ,0x07 ,0x10 ,0x01 ,0x02 ,0x11 ,0x01 ,0x00 , \0x2a ,0x20 ,0x01 ,0x02 ,0x21 ,0x01 ,0x01 ,0x2a ),\ -raw_pdu (0x08 ,0x21 ,0x01 ,0x21 ,0x01 ,0x03 ,0x28 ), \ -raw_pdu (0x01 ,0x08 ,0x21 ,0x01 ,0x0a ), \ -raw_pdu (0x04 ,0x12 ,0x01 ,0x1f ,0x01 ), \ -raw_pdu (0x01 ,0x04 ,0x12 ,0x01 ,0x0a ), \ -raw_pdu (0x08 ,0x00 ,0x03 ,0x20 ,0x03 ,0x03 ,0x28 ), \ +raw_pdu (0x08 ,0x21 ,0x01 ,0xff ,0xff ,0x03 ,0x28 ), \raw_pdu (0x09 ,0x07 ,0x10 ,0x03 ,0x0a ,0x11 ,0x03 ,0x29 , \0x2a ), \ -raw_pdu (0x08 ,0x11 ,0x03 ,0x20 ,0x03 ,0x03 ,0x28 ), \ +raw_pdu (0x08 ,0x11 ,0x03 ,0xff ,0xff ,0x03 ,0x28 ), \raw_pdu (0x01 ,0x08 ,0x11 ,0x03 ,0x0a ), \ +raw_pdu (0x04 ,0x12 ,0x01 ,0x1f ,0x01 ), \ +raw_pdu (0x01 ,0x04 ,0x12 ,0x01 ,0x0a ), \raw_pdu (0x04 ,0x12 ,0x03 ,0x20 ,0x03 ), \raw_pdu (0x05 ,0x01 ,0x20 ,0x03 ,0x02 ,0x29 )
@@ -250,34 +244,32 @@ struct context { raw_pdu(0x01, 0x08, 0x12, 0xf0, 0x0a)#define CHARACTERISTIC_DISC_SMALL_DB \ - raw_pdu(0x08, 0x10, 0xf0, 0x18, 0xf0, 0x03, 0x28), \ + raw_pdu(0x08, 0x01, 0x00, 0xff, 0xff, 0x03, 0x28), \ + raw_pdu(0x09, 0x07, 0x02, 0x00, 0xb2, 0x03, 0x00, 0x29, \ + 0x2a), \ + raw_pdu(0x08, 0x03, 0x00, 0xff, 0xff, 0x03, 0x28), \ raw_pdu(0x09, 0x07, 0x12, 0xf0, 0x02, 0x13, 0xf0, 0x00, \ 0x2a), \ - raw_pdu(0x08, 0x13, 0xf0, 0x18, 0xf0, 0x03, 0x28), \ + raw_pdu(0x08, 0x13, 0xf0, 0xff, 0xff, 0x03, 0x28), \ raw_pdu(0x09, 0x15, 0x14, 0xf0, 0x82, 0x15, 0xf0, 0xef, \ 0xcd, 0xab, 0x89, 0x67, 0x45, 0x23, 0x01, 0x00, \ 0x00, 0x00, 0x00, 0x09, 0xB0, 0x00, 0x00), \ - raw_pdu(0x08, 0x15, 0xf0, 0x18, 0xf0, 0x03, 0x28), \ + raw_pdu(0x08, 0x15, 0xf0, 0xff, 0xff, 0x03, 0x28), \ raw_pdu(0x09, 0x07, 0x17, 0xf0, 0x02, 0x18, 0xf0, 0x01, \ 0x2a), \ - raw_pdu(0x08, 0x18, 0xf0, 0x18, 0xf0, 0x03, 0x28), \ - raw_pdu(0x01, 0x08, 0x18, 0xf0, 0x0a), \ - raw_pdu(0x04, 0x16, 0xf0, 0x16, 0xf0), \ - raw_pdu(0x05, 0x01, 0x16, 0xf0, 0x00, 0x29), \ - raw_pdu(0x0a, 0x16, 0xf0), \ - raw_pdu(0x0b, 0x01, 0x00), \ - raw_pdu(0x08, 0x01, 0x00, 0x10, 0x00, 0x03, 0x28), \ - raw_pdu(0x09, 0x07, 0x02, 0x00, 0xb2, 0x03, 0x00, 0x29, \ - 0x2a), \ - raw_pdu(0x08, 0x03, 0x00, 0x10, 0x00, 0x03, 0x28), \ - raw_pdu(0x01, 0x08, 0x03, 0x00, 0x0a) + raw_pdu(0x08, 0x18, 0xf0, 0xff, 0xff, 0x03, 0x28), \ + raw_pdu(0x01, 0x08, 0x18, 0xf0, 0x0a)#define DESCRIPTOR_DISC_SMALL_DB \ raw_pdu(0x04, 0x04, 0x00, 0x10, 0x00), \ raw_pdu(0x05, 0x01, 0x04, 0x00, 0x02, 0x29, 0x05, 0x00, \ 0x01, 0x29), \ raw_pdu(0x04, 0x06, 0x00, 0x10, 0x00), \ - raw_pdu(0x01, 0x04, 0x06, 0x00, 0x0a) + raw_pdu(0x01, 0x04, 0x06, 0x00, 0x0a), \ + raw_pdu(0x04, 0x16, 0xf0, 0x16, 0xf0), \ + raw_pdu(0x05, 0x01, 0x16, 0xf0, 0x00, 0x29), \ + raw_pdu(0x0a, 0x16, 0xf0), \ + raw_pdu(0x0b, 0x01, 0x00)#define SMALL_DB_DISCOVERY_PDUS \ PRIMARY_DISC_SMALL_DB, \
@@ -450,6 +442,8 @@ static gboolean test_handler(GIOChannel *channel, GIOCondition cond,util_hexdump ('>' , buf, len, test_debug,"GATT: " ); +util_hexdump ('=' , pdu->data, pdu->size, test_debug,"PDU: " ); + g_assert_cmpint(len, ==, pdu->size);g_assert (memcmp (buf, pdu->data, pdu->size) ==0 );
Signature · 1 line
2.9.3