gatt_client: add gatt_client_write_client_characteristic_configuration_with_context

This commit is contained in:
Matthias Ringwald 2024-08-26 13:27:19 +02:00
parent a94d23eaeb
commit cb5b2b64b6
2 changed files with 32 additions and 1 deletions

View File

@ -2872,7 +2872,8 @@ uint8_t gatt_client_reliable_write_long_value_of_characteristic(btstack_packet_h
return ERROR_CODE_SUCCESS;
}
uint8_t gatt_client_write_client_characteristic_configuration(btstack_packet_handler_t callback, hci_con_handle_t con_handle, gatt_client_characteristic_t * characteristic, uint16_t configuration){
uint8_t gatt_client_write_client_characteristic_configuration_with_context(btstack_packet_handler_t callback, hci_con_handle_t con_handle,
gatt_client_characteristic_t * characteristic, uint16_t configuration, 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){
@ -2894,6 +2895,8 @@ uint8_t gatt_client_write_client_characteristic_configuration(btstack_packet_han
}
gatt_client->callback = callback;
gatt_client->service_id = service_id;
gatt_client->connection_id = connection_id;
gatt_client->start_group_handle = characteristic->value_handle;
gatt_client->end_group_handle = characteristic->end_handle;
little_endian_store_16(gatt_client->client_characteristic_configuration_value, 0, configuration);
@ -2907,6 +2910,10 @@ uint8_t gatt_client_write_client_characteristic_configuration(btstack_packet_han
return ERROR_CODE_SUCCESS;
}
uint8_t gatt_client_write_client_characteristic_configuration(btstack_packet_handler_t callback, hci_con_handle_t con_handle, gatt_client_characteristic_t * characteristic, uint16_t configuration){
return gatt_client_write_client_characteristic_configuration_with_context(callback, con_handle, characteristic, configuration, 0, 0);
}
uint8_t gatt_client_read_characteristic_descriptor_using_descriptor_handle(btstack_packet_handler_t callback, hci_con_handle_t con_handle, uint16_t descriptor_handle){
gatt_client_t * gatt_client;
uint8_t status = gatt_client_provide_context_for_request(con_handle, &gatt_client);

View File

@ -1026,6 +1026,30 @@ uint8_t gatt_client_write_long_characteristic_descriptor_using_descriptor_handle
*/
uint8_t gatt_client_write_client_characteristic_configuration(btstack_packet_handler_t callback, hci_con_handle_t con_handle, gatt_client_characteristic_t * characteristic, uint16_t configuration);
/**
* @brief Writes the client characteristic configuration of the specified characteristic.
* It is used to subscribe for notifications or indications of the characteristic value.
* For notifications or indications specify: GATT_CLIENT_CHARACTERISTICS_CONFIGURATION_NOTIFICATION
* resp. GATT_CLIENT_CHARACTERISTICS_CONFIGURATION_INDICATION as configuration value.
* The GATT_EVENT_QUERY_COMPLETE event marks the end of write.
* The write is successfully performed if the event's att_status field is set to ATT_ERROR_SUCCESS (see bluetooth.h for ATT_ERROR codes).
* @param callback
* @param con_handle
* @param characteristic
* @param configuration GATT_CLIENT_CHARACTERISTICS_CONFIGURATION_NOTIFICATION, GATT_CLIENT_CHARACTERISTICS_CONFIGURATION_INDICATION
* @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
* GATT_CLIENT_CHARACTERISTIC_NOTIFICATION_NOT_SUPPORTED if configuring notification, but characteristic has no notification property set
* GATT_CLIENT_CHARACTERISTIC_INDICATION_NOT_SUPPORTED if configuring indication, but characteristic has no indication property set
* ERROR_CODE_UNSUPPORTED_FEATURE_OR_PARAMETER_VALUE if configuration is invalid
* ERROR_CODE_SUCCESS if query is successfully registered
*/
uint8_t gatt_client_write_client_characteristic_configuration_with_context(btstack_packet_handler_t callback, hci_con_handle_t con_handle,
gatt_client_characteristic_t * characteristic, uint16_t configuration, uint16_t service_id, uint16_t connection_id);
/**
* @brief Register for changes to the Service Changed and Database Hash Characteristics of the remote GATT Service
* *