gatt_client: add gatt_client_discover_characteristic_descriptors_with_context

This commit is contained in:
Matthias Ringwald 2024-08-26 13:22:50 +02:00
parent 8183ac30e3
commit a94d23eaeb
2 changed files with 29 additions and 3 deletions

View File

@ -2660,13 +2660,17 @@ uint8_t gatt_client_discover_characteristics_for_service_by_uuid128(btstack_pack
return gatt_client_discover_characteristics_for_handle_range_by_uuid128(callback, con_handle, service->start_group_handle, service->end_group_handle, uuid128);
}
uint8_t gatt_client_discover_characteristic_descriptors(btstack_packet_handler_t callback, hci_con_handle_t con_handle, gatt_client_characteristic_t * characteristic){
uint8_t gatt_client_discover_characteristic_descriptors_with_context(btstack_packet_handler_t callback, hci_con_handle_t con_handle,
gatt_client_characteristic_t * characteristic, uint16_t service_id, uint16_t connection_id){
gatt_client_t * gatt_client;
uint8_t status = gatt_client_provide_context_for_request(con_handle, &gatt_client);
if (status != ERROR_CODE_SUCCESS){
return status;
}
gatt_client->service_id = service_id;
gatt_client->connection_id = connection_id;
// check if there is space for characteristics descriptors
if (characteristic->end_handle > characteristic->value_handle){
gatt_client->callback = callback;
@ -2683,6 +2687,10 @@ uint8_t gatt_client_discover_characteristic_descriptors(btstack_packet_handler_t
return ERROR_CODE_SUCCESS;
}
uint8_t gatt_client_discover_characteristic_descriptors(btstack_packet_handler_t callback, hci_con_handle_t con_handle, gatt_client_characteristic_t * characteristic){
return gatt_client_discover_characteristic_descriptors_with_context(callback, con_handle, characteristic, 0, 0);
}
uint8_t gatt_client_read_value_of_characteristic_using_value_handle(btstack_packet_handler_t callback, hci_con_handle_t con_handle, uint16_t value_handle){
gatt_client_t * gatt_client;
uint8_t status = gatt_client_provide_context_for_request(con_handle, &gatt_client);

View File

@ -494,8 +494,8 @@ uint8_t gatt_client_find_included_services_for_service(btstack_packet_handler_t
* to the list of all primary services.
* @param callback
* @param con_handle
* @param service_id - context provided to callback in events
* @param connection_id - contest provided to callback in events
* @param service_id - context provided to callback in events
* @param connection_id - contest provided to callback in events
* @param service_id
* @return status BTSTACK_MEMORY_ALLOC_FAILED, if no GATT client for con_handle is found
* GATT_CLIENT_IN_WRONG_STATE , if GATT client is not ready
@ -610,6 +610,24 @@ uint8_t gatt_client_discover_characteristics_for_service_by_uuid128(btstack_pack
*/
uint8_t gatt_client_discover_characteristic_descriptors(btstack_packet_handler_t callback, hci_con_handle_t con_handle, gatt_client_characteristic_t * characteristic);
/**
* @brief Discovers attribute handle and UUID of a characteristic descriptor within the specified characteristic.
* For each found descriptor a GATT_EVENT_ALL_CHARACTERISTIC_DESCRIPTORS_QUERY_RESULT event will be emitted.
*
* The GATT_EVENT_QUERY_COMPLETE event marks the end of discovery.
* @param callback
* @param con_handle
* @param characteristic
* @param service_id - context provided to callback in events
* @param connection_id - contest provided to callback in events
* @return status BTSTACK_MEMORY_ALLOC_FAILED, if no GATT client for con_handle is found
* GATT_CLIENT_IN_WRONG_STATE , if GATT client is not ready
* ERROR_CODE_SUCCESS , if query is successfully registered
*/
uint8_t gatt_client_discover_characteristic_descriptors_with_context(btstack_packet_handler_t callback, hci_con_handle_t con_handle,
gatt_client_characteristic_t * characteristic, uint16_t service_id, uint16_t connection_it);
/**
* @brief Reads the characteristic value using the characteristic's value handle.
* If the characteristic value is found a GATT_EVENT_CHARACTERISTIC_VALUE_QUERY_RESULT event will be emitted.