Bluetooth: GATT: Fix Read By Type response for Include attribute type
In Read By Type response, GATT Server shall send UUID of a included service only if this service UUID is 16 bit. Otherwise GATT Client will send Read Request to get 128 bit UUID. Fix tested with PTS. > ACL Data RX: Handle 64 flags 0x02 dlen 11 [hci0] 1125351.430506 ATT: Read By Type Request (0x08) len 6 Handle range: 0x0001-0xffff Attribute type: Include (0x2802) < ACL Data TX: Handle 64 flags 0x00 dlen 12 [hci0] 1125351.435346 ATT: Read By Type Response (0x09) len 7 Attribute data length: 6 Attribute data list: 1 entry Handle: 0x0002 Value: 01000200 > ACL Data RX: Handle 64 flags 0x02 dlen 7 [hci0] 1125351.605504 ATT: Read Request (0x0a) len 2 Handle: 0x0001 < ACL Data TX: Handle 64 flags 0x00 dlen 21 [hci0] 1125351.613432 ATT: Read Response (0x0b) len 16 Value: efcdab89674523b10040510450aa00f0 Change-Id: Ie07ec7930663b04dc134ee1c5a95c4e0670f5926 Signed-off-by: Mariusz Skamra <mariusz.skamra@tieto.com>
This commit is contained in:
parent
4e5d6581c0
commit
dd0186c4d0
1 changed files with 6 additions and 7 deletions
|
@ -144,10 +144,7 @@ int bt_gatt_attr_read_service(struct bt_conn *conn,
|
|||
struct gatt_incl {
|
||||
uint16_t start_handle;
|
||||
uint16_t end_handle;
|
||||
union {
|
||||
uint16_t uuid16;
|
||||
uint8_t uuid[16];
|
||||
};
|
||||
uint16_t uuid16;
|
||||
} __packed;
|
||||
|
||||
int bt_gatt_attr_read_included(struct bt_conn *conn,
|
||||
|
@ -162,12 +159,14 @@ int bt_gatt_attr_read_included(struct bt_conn *conn,
|
|||
pdu.end_handle = sys_cpu_to_le16(incl->end_handle);
|
||||
value_len = sizeof(pdu.start_handle) + sizeof(pdu.end_handle);
|
||||
|
||||
/*
|
||||
* Core 4.2, Vol 3, Part G, 3.2,
|
||||
* The Service UUID shall only be present when the UUID is a 16-bit
|
||||
* Bluetooth UUID.
|
||||
*/
|
||||
if (incl->uuid->type == BT_UUID_16) {
|
||||
pdu.uuid16 = sys_cpu_to_le16(incl->uuid->u16);
|
||||
value_len += sizeof(pdu.uuid16);
|
||||
} else {
|
||||
memcpy(pdu.uuid, incl->uuid->u128, sizeof(incl->uuid->u128));
|
||||
value_len += sizeof(incl->uuid->u128);
|
||||
}
|
||||
|
||||
return bt_gatt_attr_read(conn, attr, buf, len, offset, &pdu, value_len);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue