att_db: read const value for given handle

This commit is contained in:
Milanka Ringwald 2023-06-13 15:10:26 +02:00
parent 6314722e05
commit 6f74cd091e
2 changed files with 24 additions and 1 deletions

View File

@ -194,13 +194,27 @@ uint16_t att_uuid_for_handle(uint16_t attribute_handle){
att_iterator_t it;
int ok = att_find_handle(&it, attribute_handle);
if (!ok){
return 0;
return 0u;
}
if ((it.flags & (uint16_t)ATT_PROPERTY_UUID128) != 0u){
return 0u;
}
return little_endian_read_16(it.uuid, 0);
}
const uint8_t * gatt_server_get_const_value_for_handle(uint16_t attribute_handle, uint16_t * out_value_len){
att_iterator_t it;
int ok = att_find_handle(&it, attribute_handle);
if (!ok){
return 0u;
}
if ((it.flags & (uint16_t)ATT_PROPERTY_DYNAMIC) != 0u){
return 0u;
}
*out_value_len = it.value_len;
return it.value;
}
// end of client API
static void att_update_value_len(att_iterator_t *it, uint16_t offset, hci_con_handle_t con_handle) {

View File

@ -298,6 +298,15 @@ uint16_t att_read_callback_handle_byte(uint8_t value, uint16_t offset, uint8_t *
*/
uint16_t att_uuid_for_handle(uint16_t attribute_handle);
/**
* @brief Get const value for handle
* @param attribute_handle
* @param out_value_len output variable that hold value len
* @return value
*/
const uint8_t * gatt_server_get_const_value_for_handle(uint16_t attribute_handle, uint16_t * out_value_len);
// experimental GATT Server API
/**