From 12f6b6060094d5fe59a2d6abf718a8827ac6553a Mon Sep 17 00:00:00 2001 From: Alex McHugh Date: Sat, 14 Dec 2024 03:41:03 +1300 Subject: [PATCH] att_db_util: Add API to specify next attribute handle. (#647) Co-authored-by: Alex McHugh --- src/ble/att_db_util.c | 5 +++++ src/ble/att_db_util.h | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/src/ble/att_db_util.c b/src/ble/att_db_util.c index 29cb2b234..bb2e319a2 100644 --- a/src/ble/att_db_util.c +++ b/src/ble/att_db_util.c @@ -89,6 +89,11 @@ void att_db_util_init(void){ att_db_util_set_end_tag(); } +void att_db_util_set_next_handle(uint16_t handle){ + btstack_assert(handle >= att_db_next_handle); // do not reuse assigned handles + att_db_next_handle = handle; +} + static bool att_db_util_hash_include_with_value(uint16_t uuid16){ /* «Primary Service», «Secondary Service», «Included Service», «Characteristic», or «Characteristic Extended Properties» */ switch (uuid16){ diff --git a/src/ble/att_db_util.h b/src/ble/att_db_util.h index 9055f63a2..f8b11c6b2 100644 --- a/src/ble/att_db_util.h +++ b/src/ble/att_db_util.h @@ -61,6 +61,13 @@ extern "C" { */ void att_db_util_init(void); +/** + * @brief Set handle value for next table entry + * @param handle + * @note new handle must be >= previous to avoid reusing assigned handles + */ +void att_db_util_set_next_handle(uint16_t handle); + /** * @brief Add primary service for 16-bit UUID * @param uuid16