mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-03-23 19:20:51 +00:00
att_db: add gatt_server_get_database_hash
This commit is contained in:
parent
c24eef3424
commit
00b4f875b0
@ -42,6 +42,7 @@
|
||||
#include "ble/att_db.h"
|
||||
#include "ble/core.h"
|
||||
#include "bluetooth.h"
|
||||
#include "bluetooth_gatt.h"
|
||||
#include "btstack_debug.h"
|
||||
#include "btstack_util.h"
|
||||
|
||||
@ -1644,6 +1645,28 @@ bool gatt_server_get_included_service_with_uuid16(uint16_t start_handle, uint16_
|
||||
return false;
|
||||
}
|
||||
|
||||
bool gatt_server_get_database_hash(uint8_t * hash) {
|
||||
att_iterator_t it;
|
||||
att_iterator_init(&it);
|
||||
uint16_t value_handle = 0xffff;
|
||||
while (att_iterator_has_next(&it)){
|
||||
att_iterator_fetch_next(&it);
|
||||
// Find Characteristic declaration for Database Hash
|
||||
if ((it.value_len == 5u) && (att_iterator_match_uuid16(&it, GATT_CHARACTERISTICS_UUID))){
|
||||
uint16_t characteristic_uuid = little_endian_read_16(it.value, 3);
|
||||
if (characteristic_uuid == ORG_BLUETOOTH_CHARACTERISTIC_DATABASE_HASH){
|
||||
value_handle = little_endian_read_16(it.value, 1);
|
||||
}
|
||||
}
|
||||
// Find Characteristic Value for Database Hash and get value
|
||||
if ((it.handle == value_handle) && (it.value_len == 16u)){
|
||||
att_copy_value(&it, 0, hash, 16, HCI_CON_HANDLE_INVALID);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// 1-item cache to optimize query during write_callback
|
||||
static void att_persistent_ccc_cache(att_iterator_t * it){
|
||||
att_persistent_ccc_handle = it->handle;
|
||||
|
@ -420,6 +420,14 @@ uint16_t gatt_server_get_value_handle_for_characteristic_with_uuid128(uint16_t s
|
||||
*/
|
||||
uint16_t gatt_server_get_client_configuration_handle_for_characteristic_with_uuid128(uint16_t start_handle, uint16_t end_handle, const uint8_t * uuid128);
|
||||
|
||||
/**
|
||||
* @brief Get Database Hash provided via GATT Database Hash characteristic
|
||||
* @note Used by att_server to discard stored CCCD values for bonded devices if hash has changed
|
||||
* @param hash
|
||||
* @return true if hash is available
|
||||
*/
|
||||
bool gatt_server_get_database_hash(uint8_t * hash);
|
||||
|
||||
/* API_END */
|
||||
|
||||
// non-user functionality for att_server
|
||||
|
Loading…
x
Reference in New Issue
Block a user