mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-02-22 06:41:17 +00:00
convert GATT_INCLUDED_SERVICE_QUERY_RESULT
This commit is contained in:
parent
c88ece81b6
commit
ad9ea7b731
@ -667,10 +667,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, 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, uint8_t type, uint16_t start_group_handle, uint16_t end_group_handle, uint8_t * uuid128){
|
||||
// @format HX
|
||||
uint8_t packet[24];
|
||||
packet[0] = GATT_SERVICE_QUERY_RESULT;
|
||||
packet[0] = type;
|
||||
packet[1] = sizeof(packet) - 2;
|
||||
bt_store_16(packet, 2, peripheral->handle);
|
||||
///
|
||||
@ -722,7 +722,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, start_group_handle, end_group_handle, uuid128);
|
||||
emit_gatt_service_query_result_event(peripheral, GATT_SERVICE_QUERY_RESULT, start_group_handle, end_group_handle, uuid128);
|
||||
|
||||
#ifdef OLD
|
||||
service.uuid16 = uuid16;
|
||||
@ -797,7 +797,20 @@ 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);
|
||||
}
|
||||
|
||||
#ifdef OLD
|
||||
le_service_t service;
|
||||
service.uuid16 = uuid16;
|
||||
if (service.uuid16){
|
||||
@ -815,6 +828,7 @@ static void report_gatt_included_service(gatt_client_t * peripheral, uint8_t *uu
|
||||
event.service = service;
|
||||
event.handle = peripheral->handle;
|
||||
emit_event(peripheral->subclient_id, (le_event_t*)&event);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void setup_characteristic_value_event(le_characteristic_value_event_t * event, uint16_t handle, uint16_t value_handle, uint8_t * value, uint16_t length, uint16_t offset, uint8_t event_type){
|
||||
@ -1340,7 +1354,7 @@ static void gatt_client_att_packet_handler(uint8_t packet_type, uint16_t handle,
|
||||
for (i = 1; i<size; i+=pair_size){
|
||||
uint16_t start_group_handle = READ_BT_16(packet,i);
|
||||
uint16_t end_group_handle = READ_BT_16(packet,i+2);
|
||||
emit_gatt_service_query_result_event(peripheral, start_group_handle, end_group_handle, peripheral->uuid128);
|
||||
emit_gatt_service_query_result_event(peripheral, GATT_SERVICE_QUERY_RESULT, start_group_handle, end_group_handle, peripheral->uuid128);
|
||||
#ifdef OLD
|
||||
service.start_group_handle = READ_BT_16(packet,i);
|
||||
service.end_group_handle = READ_BT_16(packet,i+2);
|
||||
|
@ -167,6 +167,17 @@ static void handle_ble_client_event_new(uint8_t packet_type, uint8_t *packet, ui
|
||||
services[result_index++] = service;
|
||||
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.uuid16 = 0;
|
||||
swap128(&packet[8], service.uuid128);
|
||||
if (sdp_has_blueooth_base_uuid(service.uuid128)){
|
||||
service.uuid16 = READ_NET_32(service.uuid128, 0);
|
||||
}
|
||||
included_services[result_index++] = service;
|
||||
result_counter++;
|
||||
break;
|
||||
case GATT_CHARACTERISTIC_QUERY_RESULT:
|
||||
characteristic.start_handle = READ_BT_16(packet, 4);
|
||||
characteristic.value_handle = READ_BT_16(packet, 6);
|
||||
@ -188,10 +199,6 @@ static void handle_ble_client_event_new(uint8_t packet_type, uint8_t *packet, ui
|
||||
static void handle_ble_client_event(le_event_t * event){
|
||||
|
||||
switch(event->type){
|
||||
case GATT_INCLUDED_SERVICE_QUERY_RESULT:
|
||||
included_services[result_index++] = ((le_service_event_t *) event)->service;
|
||||
result_counter++;
|
||||
break;
|
||||
case GATT_ALL_CHARACTERISTIC_DESCRIPTORS_QUERY_RESULT:{
|
||||
le_characteristic_descriptor_event *descriptor_event = (le_characteristic_descriptor_event_t *) event;
|
||||
descriptors[result_index++] = descriptor_event->characteristic_descriptor;
|
||||
|
Loading…
x
Reference in New Issue
Block a user