mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-04-17 11:42:34 +00:00
convert GATT_CHARACTERISTIC_QUERY_RESULT
This commit is contained in:
parent
5a8b9c1f36
commit
c88ece81b6
@ -658,7 +658,6 @@ static void emit_gatt_complete_event(gatt_client_t * peripheral, uint8_t status)
|
|||||||
event.status = status;
|
event.status = status;
|
||||||
emit_event(peripheral->subclient_id, (le_event_t*)&event);
|
emit_event(peripheral->subclient_id, (le_event_t*)&event);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// @format H1
|
// @format H1
|
||||||
uint8_t packet[5];
|
uint8_t packet[5];
|
||||||
packet[0] = GATT_QUERY_COMPLETE;
|
packet[0] = GATT_QUERY_COMPLETE;
|
||||||
@ -669,6 +668,7 @@ static void emit_gatt_complete_event(gatt_client_t * peripheral, uint8_t status)
|
|||||||
}
|
}
|
||||||
|
|
||||||
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, uint16_t start_group_handle, uint16_t end_group_handle, uint8_t * uuid128){
|
||||||
|
// @format HX
|
||||||
uint8_t packet[24];
|
uint8_t packet[24];
|
||||||
packet[0] = GATT_SERVICE_QUERY_RESULT;
|
packet[0] = GATT_SERVICE_QUERY_RESULT;
|
||||||
packet[1] = sizeof(packet) - 2;
|
packet[1] = sizeof(packet) - 2;
|
||||||
@ -680,6 +680,22 @@ static void emit_gatt_service_query_result_event(gatt_client_t * peripheral, uin
|
|||||||
emit_event_new(peripheral->subclient_id, packet, sizeof(packet));
|
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
|
||||||
|
uint8_t packet[28];
|
||||||
|
packet[0] = GATT_CHARACTERISTIC_QUERY_RESULT;
|
||||||
|
packet[1] = sizeof(packet) - 2;
|
||||||
|
bt_store_16(packet, 2, peripheral->handle);
|
||||||
|
///
|
||||||
|
bt_store_16(packet, 4, start_handle);
|
||||||
|
bt_store_16(packet, 6, value_handle);
|
||||||
|
bt_store_16(packet, 8, end_handle);
|
||||||
|
bt_store_16(packet, 10, properties);
|
||||||
|
swap128(uuid128, &packet[12]);
|
||||||
|
emit_event_new(peripheral->subclient_id, packet, sizeof(packet));
|
||||||
|
}
|
||||||
|
|
||||||
///
|
///
|
||||||
|
|
||||||
static void report_gatt_services(gatt_client_t * peripheral, uint8_t * packet, uint16_t size){
|
static void report_gatt_services(gatt_client_t * peripheral, uint8_t * packet, uint16_t size){
|
||||||
@ -748,7 +764,10 @@ static void characteristic_end_found(gatt_client_t * peripheral, uint16_t end_ha
|
|||||||
// TODO: stop searching if filter and uuid found
|
// TODO: stop searching if filter and uuid found
|
||||||
|
|
||||||
if (!peripheral->characteristic_start_handle) return;
|
if (!peripheral->characteristic_start_handle) return;
|
||||||
|
|
||||||
|
emit_gatt_characteristic_query_result_event(peripheral, peripheral->characteristic_start_handle, peripheral->attribute_handle,
|
||||||
|
end_handle, peripheral->characteristic_properties, peripheral->uuid128);
|
||||||
|
#ifdef OLD
|
||||||
le_characteristic_event_t event;
|
le_characteristic_event_t event;
|
||||||
event.type = GATT_CHARACTERISTIC_QUERY_RESULT;
|
event.type = GATT_CHARACTERISTIC_QUERY_RESULT;
|
||||||
event.handle = peripheral->handle;
|
event.handle = peripheral->handle;
|
||||||
@ -760,7 +779,8 @@ static void characteristic_end_found(gatt_client_t * peripheral, uint16_t end_ha
|
|||||||
memcpy(event.characteristic.uuid128, peripheral->uuid128, 16);
|
memcpy(event.characteristic.uuid128, peripheral->uuid128, 16);
|
||||||
|
|
||||||
emit_event(peripheral->subclient_id, (le_event_t*)&event);
|
emit_event(peripheral->subclient_id, (le_event_t*)&event);
|
||||||
|
#endif
|
||||||
|
|
||||||
peripheral->characteristic_start_handle = 0;
|
peripheral->characteristic_start_handle = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -146,6 +146,7 @@ static void handle_ble_client_event_new(uint8_t packet_type, uint8_t *packet, ui
|
|||||||
if (packet_type != HCI_EVENT_PACKET) return;
|
if (packet_type != HCI_EVENT_PACKET) return;
|
||||||
uint8_t status;
|
uint8_t status;
|
||||||
le_service_t service;
|
le_service_t service;
|
||||||
|
le_characteristic_t characteristic;
|
||||||
switch (packet[0]){
|
switch (packet[0]){
|
||||||
case GATT_QUERY_COMPLETE:
|
case GATT_QUERY_COMPLETE:
|
||||||
status = packet[4];
|
status = packet[4];
|
||||||
@ -166,6 +167,19 @@ static void handle_ble_client_event_new(uint8_t packet_type, uint8_t *packet, ui
|
|||||||
services[result_index++] = service;
|
services[result_index++] = service;
|
||||||
result_counter++;
|
result_counter++;
|
||||||
break;
|
break;
|
||||||
|
case GATT_CHARACTERISTIC_QUERY_RESULT:
|
||||||
|
characteristic.start_handle = READ_BT_16(packet, 4);
|
||||||
|
characteristic.value_handle = READ_BT_16(packet, 6);
|
||||||
|
characteristic.end_handle = READ_BT_16(packet, 8);
|
||||||
|
characteristic.properties = READ_BT_16(packet, 10);
|
||||||
|
characteristic.uuid16 = 0;
|
||||||
|
swap128(&packet[12], characteristic.uuid128);
|
||||||
|
if (sdp_has_blueooth_base_uuid(characteristic.uuid128)){
|
||||||
|
characteristic.uuid16 = READ_NET_32(characteristic.uuid128, 0);
|
||||||
|
}
|
||||||
|
characteristics[result_index++] = characteristic;
|
||||||
|
result_counter++;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -174,23 +188,10 @@ 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){
|
static void handle_ble_client_event(le_event_t * event){
|
||||||
|
|
||||||
switch(event->type){
|
switch(event->type){
|
||||||
#if 0
|
|
||||||
case GATT_SERVICE_QUERY_RESULT:
|
|
||||||
services[result_index++] = ((le_service_event_t *) event)->service;
|
|
||||||
result_counter++;
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
case GATT_INCLUDED_SERVICE_QUERY_RESULT:
|
case GATT_INCLUDED_SERVICE_QUERY_RESULT:
|
||||||
included_services[result_index++] = ((le_service_event_t *) event)->service;
|
included_services[result_index++] = ((le_service_event_t *) event)->service;
|
||||||
result_counter++;
|
result_counter++;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GATT_CHARACTERISTIC_QUERY_RESULT:{
|
|
||||||
characteristics[result_index++] = ((le_characteristic_event_t *) event)->characteristic;
|
|
||||||
result_counter++;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case GATT_ALL_CHARACTERISTIC_DESCRIPTORS_QUERY_RESULT:{
|
case GATT_ALL_CHARACTERISTIC_DESCRIPTORS_QUERY_RESULT:{
|
||||||
le_characteristic_descriptor_event *descriptor_event = (le_characteristic_descriptor_event_t *) event;
|
le_characteristic_descriptor_event *descriptor_event = (le_characteristic_descriptor_event_t *) event;
|
||||||
descriptors[result_index++] = descriptor_event->characteristic_descriptor;
|
descriptors[result_index++] = descriptor_event->characteristic_descriptor;
|
||||||
@ -225,18 +226,6 @@ static void handle_ble_client_event(le_event_t * event){
|
|||||||
result_counter++;
|
result_counter++;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#if 0
|
|
||||||
case GATT_QUERY_COMPLETE:{
|
|
||||||
gatt_complete_event_t *gce = (gatt_complete_event_t *)event;
|
|
||||||
gatt_query_complete = 1;
|
|
||||||
|
|
||||||
if (gce->status != 0){
|
|
||||||
gatt_query_complete = 0;
|
|
||||||
printf("GATT_QUERY_COMPLETE failed with status 0x%02X\n", gce->status);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user