gatt_client: add gatt_client_discover_primary_services_by_uuid16_with_context

This commit is contained in:
Matthias Ringwald 2024-08-26 11:18:47 +02:00
parent d578995f60
commit 68ced5c9a3
2 changed files with 25 additions and 2 deletions

View File

@ -2525,7 +2525,8 @@ uint8_t gatt_client_discover_secondary_services(btstack_packet_handler_t callbac
return ERROR_CODE_SUCCESS;
}
uint8_t gatt_client_discover_primary_services_by_uuid16(btstack_packet_handler_t callback, hci_con_handle_t con_handle, uint16_t uuid16){
uint8_t gatt_client_discover_primary_services_by_uuid16_with_context(btstack_packet_handler_t callback, hci_con_handle_t con_handle,
uint16_t uuid16, 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){
@ -2533,6 +2534,8 @@ uint8_t gatt_client_discover_primary_services_by_uuid16(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 = 0x0001;
gatt_client->end_group_handle = 0xffff;
gatt_client->state = P_W2_SEND_SERVICE_WITH_UUID_QUERY;
@ -2542,6 +2545,10 @@ uint8_t gatt_client_discover_primary_services_by_uuid16(btstack_packet_handler_t
return ERROR_CODE_SUCCESS;
}
uint8_t gatt_client_discover_primary_services_by_uuid16(btstack_packet_handler_t callback, hci_con_handle_t con_handle, uint16_t uuid16){
return gatt_client_discover_primary_services_by_uuid16_with_context(callback, con_handle, uuid16, 0, 0);
}
uint8_t gatt_client_discover_primary_services_by_uuid128(btstack_packet_handler_t callback, hci_con_handle_t con_handle, const uint8_t * uuid128){
gatt_client_t * gatt_client;
uint8_t status = gatt_client_provide_context_for_request(con_handle, &gatt_client);

View File

@ -438,7 +438,23 @@ uint8_t gatt_client_discover_secondary_services(btstack_packet_handler_t callbac
*/
uint8_t gatt_client_discover_primary_services_by_uuid16(btstack_packet_handler_t callback, hci_con_handle_t con_handle, uint16_t uuid16);
/**
/**
* @brief Discovers a specific primary service given its UUID. This service may exist multiple times.
* For each found service a GATT_EVENT_SERVICE_QUERY_RESULT event will be emitted.
* The GATT_EVENT_QUERY_COMPLETE event marks the end of discovery.
* @param callback
* @param con_handle
* @param uuid16
* @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_primary_services_by_uuid16_with_context(btstack_packet_handler_t callback, hci_con_handle_t con_handle,
uint16_t uuid16, uint16_t service_id, uint16_t connection_id);
/**
* @brief Discovers a specific primary service given its UUID. This service may exist multiple times.
* For each found service a GATT_EVENT_SERVICE_QUERY_RESULT event will be emitted.
* The GATT_EVENT_QUERY_COMPLETE event marks the end of discovery.