mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-02-07 15:39:51 +00:00
add include handle to include service query result event and show in pts test
This commit is contained in:
parent
3ed70f740d
commit
48b1b78d97
@ -516,10 +516,10 @@ static void emit_gatt_complete_event(gatt_client_t * peripheral, uint8_t status)
|
||||
emit_event_new(peripheral->subclient_id, packet, sizeof(packet));
|
||||
}
|
||||
|
||||
static void emit_gatt_service_query_result_event(gatt_client_t * peripheral, uint8_t type, uint16_t start_group_handle, uint16_t end_group_handle, uint8_t * uuid128){
|
||||
static void emit_gatt_service_query_result_event(gatt_client_t * peripheral, uint16_t start_group_handle, uint16_t end_group_handle, uint8_t * uuid128){
|
||||
// @format HX
|
||||
uint8_t packet[24];
|
||||
packet[0] = type;
|
||||
packet[0] = GATT_SERVICE_QUERY_RESULT;
|
||||
packet[1] = sizeof(packet) - 2;
|
||||
bt_store_16(packet, 2, peripheral->handle);
|
||||
///
|
||||
@ -529,6 +529,21 @@ static void emit_gatt_service_query_result_event(gatt_client_t * peripheral, uin
|
||||
emit_event_new(peripheral->subclient_id, packet, sizeof(packet));
|
||||
}
|
||||
|
||||
static void emit_gatt_included_service_query_result_event(gatt_client_t * peripheral, uint16_t include_handle, uint16_t start_group_handle, uint16_t end_group_handle, uint8_t * uuid128){
|
||||
// @format HX
|
||||
uint8_t packet[26];
|
||||
packet[0] = GATT_INCLUDED_SERVICE_QUERY_RESULT;
|
||||
packet[1] = sizeof(packet) - 2;
|
||||
bt_store_16(packet, 2, peripheral->handle);
|
||||
///
|
||||
bt_store_16(packet, 4, include_handle);
|
||||
//
|
||||
bt_store_16(packet, 6, start_group_handle);
|
||||
bt_store_16(packet, 8, end_group_handle);
|
||||
swap128(uuid128, &packet[10]);
|
||||
emit_event_new(peripheral->subclient_id, packet, sizeof(packet));
|
||||
}
|
||||
|
||||
static void emit_gatt_characteristic_query_result_event(gatt_client_t * peripheral, uint16_t start_handle, uint16_t value_handle, uint16_t end_handle,
|
||||
uint16_t properties, uint8_t * uuid128){
|
||||
// @format HY
|
||||
@ -576,7 +591,7 @@ static void report_gatt_services(gatt_client_t * peripheral, uint8_t * packet,
|
||||
} else {
|
||||
swap128(&packet[i+4], uuid128);
|
||||
}
|
||||
emit_gatt_service_query_result_event(peripheral, GATT_SERVICE_QUERY_RESULT, start_group_handle, end_group_handle, uuid128);
|
||||
emit_gatt_service_query_result_event(peripheral, start_group_handle, end_group_handle, uuid128);
|
||||
}
|
||||
// log_info("report_gatt_services for %02X done", peripheral->handle);
|
||||
}
|
||||
@ -628,18 +643,16 @@ static void report_gatt_characteristics(gatt_client_t * peripheral, uint8_t * pa
|
||||
}
|
||||
}
|
||||
|
||||
// pre: uuid16 != 0 OR uuid128 != NULL
|
||||
// maybe inline this into the two callers
|
||||
static void report_gatt_included_service(gatt_client_t * peripheral, uint8_t *uuid128, uint16_t uuid16){
|
||||
if (uuid16){
|
||||
uint8_t normalized_uuid128[16];
|
||||
sdp_normalize_uuid(normalized_uuid128, uuid16);
|
||||
emit_gatt_service_query_result_event(peripheral, GATT_INCLUDED_SERVICE_QUERY_RESULT, peripheral->query_start_handle,
|
||||
peripheral->query_end_handle, normalized_uuid128);
|
||||
} else if (uuid128){
|
||||
emit_gatt_service_query_result_event(peripheral, GATT_INCLUDED_SERVICE_QUERY_RESULT, peripheral->query_start_handle,
|
||||
peripheral->query_end_handle, uuid128);
|
||||
}
|
||||
static void report_gatt_included_service_uuid16(gatt_client_t * peripheral, uint16_t include_handle, uint16_t uuid16){
|
||||
uint8_t normalized_uuid128[16];
|
||||
sdp_normalize_uuid(normalized_uuid128, uuid16);
|
||||
emit_gatt_included_service_query_result_event(peripheral, include_handle, peripheral->query_start_handle,
|
||||
peripheral->query_end_handle, normalized_uuid128);
|
||||
}
|
||||
|
||||
static void report_gatt_included_service_uuid128(gatt_client_t * peripheral, uint16_t include_handle, uint8_t *uuid128){
|
||||
emit_gatt_included_service_query_result_event(peripheral, include_handle, peripheral->query_start_handle,
|
||||
peripheral->query_end_handle, uuid128);
|
||||
}
|
||||
|
||||
// @returns packet pointer
|
||||
@ -1105,10 +1118,11 @@ static void gatt_client_att_packet_handler(uint8_t packet_type, uint16_t handle,
|
||||
|
||||
uint16_t offset;
|
||||
for (offset = 2; offset < size; offset += pair_size){
|
||||
uint16_t include_handle = READ_BT_16(packet, offset);
|
||||
peripheral->query_start_handle = READ_BT_16(packet,offset+2);
|
||||
peripheral->query_end_handle = READ_BT_16(packet,offset+4);
|
||||
uuid16 = READ_BT_16(packet, offset+6);
|
||||
report_gatt_included_service(peripheral, NULL, uuid16);
|
||||
report_gatt_included_service_uuid16(peripheral, include_handle, uuid16);
|
||||
}
|
||||
|
||||
trigger_next_included_service_query(peripheral, get_last_result_handle_from_included_services_list(packet, size));
|
||||
@ -1140,7 +1154,7 @@ static void gatt_client_att_packet_handler(uint8_t packet_type, uint16_t handle,
|
||||
case P_W4_INCLUDED_SERVICE_UUID_WITH_QUERY_RESULT: {
|
||||
uint8_t uuid128[16];
|
||||
swap128(&packet[1], uuid128);
|
||||
report_gatt_included_service(peripheral, uuid128, 0);
|
||||
report_gatt_included_service_uuid128(peripheral, peripheral->start_group_handle, uuid128);
|
||||
trigger_next_included_service_query(peripheral, peripheral->start_group_handle);
|
||||
// GATT_QUERY_COMPLETE is emitted by trigger_next_xxx when done
|
||||
break;
|
||||
@ -1171,7 +1185,7 @@ static void gatt_client_att_packet_handler(uint8_t packet_type, uint16_t handle,
|
||||
for (i = 1; i<size; i+=pair_size){
|
||||
start_group_handle = READ_BT_16(packet,i);
|
||||
end_group_handle = READ_BT_16(packet,i+2);
|
||||
emit_gatt_service_query_result_event(peripheral, GATT_SERVICE_QUERY_RESULT, start_group_handle, end_group_handle, peripheral->uuid128);
|
||||
emit_gatt_service_query_result_event(peripheral, start_group_handle, end_group_handle, peripheral->uuid128);
|
||||
}
|
||||
trigger_next_service_by_uuid_query(peripheral, end_group_handle);
|
||||
// GATT_QUERY_COMPLETE is emitted by trigger_next_xxx when done
|
||||
|
@ -490,8 +490,9 @@ extern "C" {
|
||||
#define GATT_CHARACTERISTIC_QUERY_RESULT 0xA2
|
||||
|
||||
/**
|
||||
* @format HX
|
||||
* @format H2X
|
||||
* @param handle
|
||||
* @param include_handle
|
||||
* @param service
|
||||
*/
|
||||
#define GATT_INCLUDED_SERVICE_QUERY_RESULT 0xA3
|
||||
|
@ -169,10 +169,10 @@ static void handle_ble_client_event(uint8_t packet_type, uint8_t *packet, uint16
|
||||
result_counter++;
|
||||
break;
|
||||
case GATT_INCLUDED_SERVICE_QUERY_RESULT:
|
||||
service.start_group_handle = READ_BT_16(packet, 4);
|
||||
service.end_group_handle = READ_BT_16(packet, 6);
|
||||
service.start_group_handle = READ_BT_16(packet, 6);
|
||||
service.end_group_handle = READ_BT_16(packet, 8);
|
||||
service.uuid16 = 0;
|
||||
swap128(&packet[8], service.uuid128);
|
||||
swap128(&packet[10], service.uuid128);
|
||||
if (sdp_has_blueooth_base_uuid(service.uuid128)){
|
||||
service.uuid16 = READ_NET_32(service.uuid128, 0);
|
||||
}
|
||||
|
@ -412,11 +412,11 @@ void use_public_pts_address(void){
|
||||
current_pts_address_type = public_pts_address_type;
|
||||
}
|
||||
|
||||
void extract_service(le_service_t * service, uint8_t * packet){
|
||||
service->start_group_handle = READ_BT_16(packet, 4);
|
||||
service->end_group_handle = READ_BT_16(packet, 6);
|
||||
void extract_service(le_service_t * service, uint8_t * data){
|
||||
service->start_group_handle = READ_BT_16(data, 0);
|
||||
service->end_group_handle = READ_BT_16(data, 2);
|
||||
service->uuid16 = 0;
|
||||
swap128(&packet[8], service->uuid128);
|
||||
swap128(&data[4], service->uuid128);
|
||||
if (sdp_has_blueooth_base_uuid(service->uuid128)){
|
||||
service->uuid16 = READ_NET_32(service->uuid128, 0);
|
||||
}
|
||||
@ -452,7 +452,7 @@ void handle_gatt_client_event(uint8_t packet_type, uint8_t *packet, uint16_t siz
|
||||
case GATT_SERVICE_QUERY_RESULT:
|
||||
switch (central_state){
|
||||
case CENTRAL_W4_PRIMARY_SERVICES:
|
||||
extract_service(&service, packet);
|
||||
extract_service(&service, &packet[4]);
|
||||
printf("Primary Service with UUID ");
|
||||
printUUID(service.uuid128, service.uuid16);
|
||||
printf(", start group handle 0x%04x, end group handle 0x%04x\n", service.start_group_handle, service.end_group_handle);
|
||||
@ -462,10 +462,12 @@ void handle_gatt_client_event(uint8_t packet_type, uint8_t *packet, uint16_t siz
|
||||
}
|
||||
break;
|
||||
case GATT_INCLUDED_SERVICE_QUERY_RESULT:
|
||||
extract_service(&service, packet);
|
||||
printf("Included Service with UUID ");
|
||||
value_handle = READ_BT_16(packet, 4);
|
||||
extract_service(&service, &packet[6]);
|
||||
printf("Included Service at 0x%004x: ", value_handle);
|
||||
printf("start group handle 0x%04x, end group handle 0x%04x with UUID ", service.start_group_handle, service.end_group_handle);
|
||||
printUUID(service.uuid128, service.uuid16);
|
||||
printf(", start group handle 0x%04x, end group handle 0x%04x\n", service.start_group_handle, service.end_group_handle);
|
||||
printf("\n");
|
||||
break;
|
||||
case GATT_CHARACTERISTIC_QUERY_RESULT:
|
||||
extract_characteristic(&characteristic, packet);
|
||||
|
Loading…
x
Reference in New Issue
Block a user