gatt_client: add gatt_client_find_included_services_for_service_with_context

This commit is contained in:
Matthias Ringwald 2024-08-26 13:12:33 +02:00
parent 68ced5c9a3
commit aa43543a70
2 changed files with 29 additions and 3 deletions

View File

@ -2582,8 +2582,8 @@ uint8_t gatt_client_discover_characteristics_for_service(btstack_packet_handler_
gatt_client_run();
return ERROR_CODE_SUCCESS;
}
uint8_t gatt_client_find_included_services_for_service(btstack_packet_handler_t callback, hci_con_handle_t con_handle, gatt_client_service_t * service){
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;
uint8_t status = gatt_client_provide_context_for_request(con_handle, &gatt_client);
if (status != ERROR_CODE_SUCCESS){
@ -2591,6 +2591,8 @@ uint8_t gatt_client_find_included_services_for_service(btstack_packet_handler_t
}
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->state = P_W2_SEND_INCLUDED_SERVICE_QUERY;
@ -2599,6 +2601,10 @@ uint8_t gatt_client_find_included_services_for_service(btstack_packet_handler_t
return ERROR_CODE_SUCCESS;
}
uint8_t gatt_client_find_included_services_for_service(btstack_packet_handler_t callback, hci_con_handle_t con_handle, gatt_client_service_t * service) {
return gatt_client_find_included_services_for_service_with_context(callback, con_handle, service, 0, 0);
}
uint8_t gatt_client_discover_characteristics_for_handle_range_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

@ -484,7 +484,27 @@ uint8_t gatt_client_discover_primary_services_by_uuid128(btstack_packet_handler_
*/
uint8_t gatt_client_find_included_services_for_service(btstack_packet_handler_t callback, hci_con_handle_t con_handle, gatt_client_service_t * service);
/**
/**
* @brief Finds included services within the specified service.
* For each found included service a GATT_EVENT_INCLUDED_SERVICE_QUERY_RESULT event will be emitted.
* The GATT_EVENT_QUERY_COMPLETE event marks the end of discovery.
* Information about included service type (primary/secondary) can be retrieved either by sending
* an ATT find information request for the returned start group handle
* (returning the handle and the UUID for primary or secondary service) or by comparing the service
* 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
* @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_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);
/**
* @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.