gatt_client: add gatt_client_discover_characteristics_for_service_with_context

This commit is contained in:
Matthias Ringwald 2024-08-26 13:15:58 +02:00
parent aa43543a70
commit 8183ac30e3
2 changed files with 26 additions and 2 deletions

View File

@ -2566,7 +2566,8 @@ uint8_t gatt_client_discover_primary_services_by_uuid128(btstack_packet_handler_
return ERROR_CODE_SUCCESS;
}
uint8_t gatt_client_discover_characteristics_for_service(btstack_packet_handler_t callback, hci_con_handle_t con_handle, gatt_client_service_t * service){
uint8_t gatt_client_discover_characteristics_for_service_with_context(btstack_packet_handler_t callback, hci_con_handle_t con_handle, gatt_client_service_t * service,
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){
@ -2574,6 +2575,8 @@ uint8_t gatt_client_discover_characteristics_for_service(btstack_packet_handler_
}
gatt_client->callback = callback;
gatt_client->service_id = service_id;
gatt_client->connection_id = connection_id;
gatt_client->start_group_handle = service->start_group_handle;
gatt_client->end_group_handle = service->end_group_handle;
gatt_client->filter_with_uuid = false;
@ -2582,6 +2585,11 @@ uint8_t gatt_client_discover_characteristics_for_service(btstack_packet_handler_
gatt_client_run();
return ERROR_CODE_SUCCESS;
}
uint8_t gatt_client_discover_characteristics_for_service(btstack_packet_handler_t callback, hci_con_handle_t con_handle, gatt_client_service_t * service){
return gatt_client_discover_characteristics_for_service_with_context(callback, con_handle, service, 0, 0);
}
uint8_t gatt_client_find_included_services_for_service_with_context(btstack_packet_handler_t callback, hci_con_handle_t con_handle,
gatt_client_service_t * service, uint16_t service_id, uint16_t connection_id){
gatt_client_t * gatt_client;

View File

@ -517,7 +517,23 @@ uint8_t gatt_client_find_included_services_for_service_with_context(btstack_pack
*/
uint8_t gatt_client_discover_characteristics_for_service(btstack_packet_handler_t callback, hci_con_handle_t con_handle, gatt_client_service_t * service);
/**
/**
* @brief Discovers all characteristics within the specified service.
* For each found characteristic a GATT_EVENT_CHARACTERISTIC_QUERY_RESULT event will be emited.
* The GATT_EVENT_QUERY_COMPLETE event marks the end of discovery.
* @param callback
* @param con_handle
* @param service
* @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_characteristics_for_service_with_context(btstack_packet_handler_t callback, hci_con_handle_t con_handle, gatt_client_service_t * service,
uint16_t service_id, uint16_t connection_id);
/**
* @brief The following four functions are used to discover all characteristics within
* the specified service or handle range, and return those that match the given UUID.
*