gatt_client: add gatt_client_write_long_value_of_characteristic_with_context

This commit is contained in:
Matthias Ringwald 2024-08-27 14:12:39 +02:00
parent e38d764ed9
commit b538fb896c
2 changed files with 33 additions and 2 deletions

View File

@ -2867,8 +2867,20 @@ uint8_t gatt_client_write_long_value_of_characteristic_with_offset(btstack_packe
return ERROR_CODE_SUCCESS;
}
uint8_t gatt_client_write_long_value_of_characteristic_with_context(btstack_packet_handler_t callback, hci_con_handle_t con_handle, uint16_t value_handle, uint16_t value_length, uint8_t * value, uint16_t service_id, uint16_t connection_id){
// TODO: move into gatt_client_write_long_value_of_characteristic_with_offset once gatt_client_write_long_value_of_characteristic_with_offset_with_context exists
gatt_client_t * gatt_client;
uint8_t status = gatt_client_provide_context_for_request(con_handle, &gatt_client);
if (status != ERROR_CODE_SUCCESS){
return status;
}
gatt_client->service_id = service_id;
gatt_client->connection_id = connection_id;
return gatt_client_write_long_value_of_characteristic_with_offset(callback, con_handle, value_handle, 0, value_length, value);
}
uint8_t gatt_client_write_long_value_of_characteristic(btstack_packet_handler_t callback, hci_con_handle_t con_handle, uint16_t value_handle, uint16_t value_length, uint8_t * value){
return gatt_client_write_long_value_of_characteristic_with_offset(callback, con_handle, value_handle, 0, value_length, value);
return gatt_client_write_long_value_of_characteristic_with_context(callback, con_handle, value_handle, value_length, value, 0, 0);
}
uint8_t gatt_client_reliable_write_long_value_of_characteristic(btstack_packet_handler_t callback, hci_con_handle_t con_handle, uint16_t value_handle, uint16_t value_length, uint8_t * value){

View File

@ -857,7 +857,26 @@ uint8_t gatt_client_write_value_of_characteristic_with_context(btstack_packet_ha
*/
uint8_t gatt_client_write_long_value_of_characteristic(btstack_packet_handler_t callback, hci_con_handle_t con_handle, uint16_t value_handle, uint16_t value_length, uint8_t * value);
/**
/**
* @brief Writes the characteristic value using the characteristic's value handle.
* 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 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 - 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
* ERROR_CODE_SUCCESS if query is successfully registered
*/
uint8_t gatt_client_write_long_value_of_characteristic_with_context(btstack_packet_handler_t callback, hci_con_handle_t con_handle, uint16_t value_handle,
uint16_t value_length, uint8_t * value, uint16_t service_id, uint16_t connection_id);
/**
* @brief Writes the characteristic value using the characteristic's value handle.
* 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).