mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-03-18 22:20:51 +00:00
respond with attribute UUID instead of attribute value in find information response
This commit is contained in:
parent
10297a1983
commit
ad51f761ed
36
ble/att.c
36
ble/att.c
@ -271,7 +271,7 @@ static uint16_t handle_find_information_request2(uint8_t * response_buffer, uint
|
||||
printf("ATT_FIND_INFORMATION_REQUEST: from %04X to %04X\n", start_handle, end_handle);
|
||||
|
||||
uint16_t offset = 1;
|
||||
uint16_t pair_len = 0;
|
||||
uint16_t uuid_len = 0;
|
||||
|
||||
att_iterator_t it;
|
||||
att_iterator_init(&it);
|
||||
@ -280,41 +280,35 @@ static uint16_t handle_find_information_request2(uint8_t * response_buffer, uint
|
||||
if (!it.handle) break;
|
||||
if (it.handle > end_handle) break;
|
||||
if (it.handle < start_handle) continue;
|
||||
|
||||
att_update_value_len(&it);
|
||||
|
||||
|
||||
// printf("Handle 0x%04x\n", it.handle);
|
||||
|
||||
// check if value has same len as last one
|
||||
uint16_t this_pair_len = 2 + it.value_len;
|
||||
uint16_t this_uuid_len = (it.flags & ATT_PROPERTY_UUID128) ? 16 : 2;
|
||||
|
||||
// check if value has same len as last one if not first result
|
||||
if (offset > 1){
|
||||
if (pair_len != this_pair_len) {
|
||||
if (this_uuid_len != uuid_len) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// first
|
||||
if (offset == 1) {
|
||||
pair_len = this_pair_len;
|
||||
if (it.value_len == 2) {
|
||||
response_buffer[offset] = 0x01; // format
|
||||
} else {
|
||||
response_buffer[offset] = 0x02;
|
||||
}
|
||||
uuid_len = this_uuid_len;
|
||||
// set format field
|
||||
response_buffer[offset] = (it.flags & ATT_PROPERTY_UUID128) ? 0x02 : 0x01;
|
||||
offset++;
|
||||
}
|
||||
}
|
||||
|
||||
// space?
|
||||
if (offset + pair_len > response_buffer_size) {
|
||||
if (offset > 2) break;
|
||||
it.value_len = response_buffer_size - 4;
|
||||
}
|
||||
if (offset + 2 + uuid_len > response_buffer_size) break;
|
||||
|
||||
// store
|
||||
bt_store_16(response_buffer, offset, it.handle);
|
||||
offset += 2;
|
||||
uint16_t bytes_copied = att_copy_value(&it, 0, response_buffer + offset, it.value_len);
|
||||
offset += bytes_copied;
|
||||
|
||||
memcpy(response_buffer + offset, it.uuid, uuid_len);
|
||||
offset += uuid_len;
|
||||
}
|
||||
|
||||
if (offset == 1){
|
||||
|
Loading…
x
Reference in New Issue
Block a user