gatt_client: add gatt_client_read_value_of_characteristic_using_value_handle_with_context

This commit is contained in:
Matthias Ringwald 2024-08-27 12:12:07 +02:00
parent b444aa754d
commit e38d764ed9
2 changed files with 31 additions and 3 deletions

View File

@ -2691,7 +2691,11 @@ uint8_t gatt_client_discover_characteristic_descriptors(btstack_packet_handler_t
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){
uint8_t gatt_client_read_value_of_characteristic_using_value_handle_with_context(btstack_packet_handler_t callback,
hci_con_handle_t con_handle,
uint16_t value_handle,
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){
@ -2699,6 +2703,8 @@ uint8_t gatt_client_read_value_of_characteristic_using_value_handle(btstack_pack
}
gatt_client->callback = callback;
gatt_client->service_id = service_id;
gatt_client->connection_id = connection_id;
gatt_client->attribute_handle = value_handle;
gatt_client->attribute_offset = 0;
gatt_client->state = P_W2_SEND_READ_CHARACTERISTIC_VALUE_QUERY;
@ -2706,6 +2712,11 @@ uint8_t gatt_client_read_value_of_characteristic_using_value_handle(btstack_pack
return ERROR_CODE_SUCCESS;
}
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){
return gatt_client_read_value_of_characteristic_using_value_handle_with_context(callback, con_handle, value_handle, 0, 0);
}
uint8_t gatt_client_read_value_of_characteristics_by_uuid16(btstack_packet_handler_t callback, hci_con_handle_t con_handle, uint16_t start_handle, uint16_t end_handle, uint16_t uuid16){
gatt_client_t * gatt_client;
uint8_t status = gatt_client_provide_context_for_request(con_handle, &gatt_client);

View File

@ -654,6 +654,23 @@ uint8_t gatt_client_read_value_of_characteristic(btstack_packet_handler_t callba
*/
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);
/**
* @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.
* The GATT_EVENT_QUERY_COMPLETE event marks the end of read.
* @param callback
* @param con_handle
* @param value_handle
* @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_read_value_of_characteristic_using_value_handle_with_context(btstack_packet_handler_t callback,
hci_con_handle_t con_handle,
uint16_t value_handle,
uint16_t service_id,
uint16_t connection_id);
/**
* @brief Reads the characteric value of all characteristics with the uuid.
* For each characteristic value found a GATT_EVENT_CHARACTERISTIC_VALUE_QUERY_RESULT event will be emitted.
@ -814,8 +831,8 @@ uint8_t gatt_client_write_value_of_characteristic(btstack_packet_handler_t callb
* @param value_handle
* @param value_length
* @param value is not copied, make sure memory is accessible until write is done, i.e. GATT_EVENT_QUERY_COMPLETE is received
* @param service_id
* @param connection_id
* @param service_id - context provided to callback in events
* @param connection_id - contest provided to callback in events
* @return status ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER if no HCI connection for con_handle is found
* BTSTACK_MEMORY_ALLOC_FAILED if no GATT client for con_handle could be allocated
* GATT_CLIENT_IN_WRONG_STATE if GATT client is not ready