att_db: search included service within handle range

This commit is contained in:
Milanka Ringwald 2022-01-11 20:36:51 +01:00
parent 57687e95a5
commit 32e1ff05bd
3 changed files with 42 additions and 0 deletions

View File

@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
### Added
- GAP: support extended advertising with ENABLE_LE_EXTENDED_ADVERTISING
- ATT DB: provide gatt_server_get_handle_range_for_service_with_uuid16 to find included service within handle range
### Fixed
- GAP: disable scanning, advertising, connection before updating random address

View File

@ -1542,6 +1542,34 @@ uint16_t gatt_server_get_client_configuration_handle_for_characteristic_with_uui
}
bool gatt_server_get_included_service_with_uuid16(uint16_t start_handle, uint16_t end_handle, uint16_t uuid16,
uint16_t * out_included_service_handle, uint16_t * out_included_service_start_handle, uint16_t * out_included_service_end_handle){
att_iterator_t it;
att_iterator_init(&it);
while (att_iterator_has_next(&it)){
att_iterator_fetch_next(&it);
if ((it.handle != 0u) && (it.handle < start_handle)){
continue;
}
if (it.handle > end_handle){
break; // (1)
}
if (it.handle == 0u){
break;
}
if ((it.value_len == 6) && (att_iterator_match_uuid16(&it, GATT_INCLUDE_SERVICE_UUID))){
if (little_endian_read_16(it.value, 4) == uuid16){
*out_included_service_handle = it.handle;
*out_included_service_start_handle = little_endian_read_16(it.value, 0);
*out_included_service_end_handle = little_endian_read_16(it.value, 2);
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;

View File

@ -309,6 +309,19 @@ uint16_t att_uuid_for_handle(uint16_t attribute_handle);
*/
bool gatt_server_get_handle_range_for_service_with_uuid16(uint16_t uuid16, uint16_t * start_handle, uint16_t * end_handle);
/**
* @brief Get handle range for included service.
* @param start_handle
* @param end_handle
* @param uuid16
* @param out_included_service_handle
* @param out_included_service_start_handle
* @param out_included_service_end_handle
* @return false if not found
*/
bool gatt_server_get_included_service_with_uuid16(uint16_t start_handle, uint16_t end_handle, uint16_t uuid16,
uint16_t * out_included_service_handle, uint16_t * out_included_service_start_handle, uint16_t * out_included_service_end_handle);
/**
* @brief Get value handle for characteristic.
* @param start_handle