unsigned int num_of_res;
};
-static void find_by_type(void *data, void *user_data)
+static void find_by_type(struct gatt_db_attribute *attribute, void *user_data)
{
struct find_by_type_value_data *search_data = user_data;
- struct gatt_db_service *service = data;
- struct gatt_db_attribute *attribute;
+ struct gatt_db_service *service = attribute->service;
int i;
if (!service->active)
data.func = func;
data.user_data = user_data;
- queue_foreach(db->services, find_by_type, &data);
+ gatt_db_foreach_service_in_range(db, NULL, find_by_type, &data,
+ start_handle, end_handle);
return data.num_of_res;
}
data.value = value;
data.value_len = value_len;
- queue_foreach(db->services, find_by_type, &data);
+ gatt_db_foreach_service_in_range(db, NULL, find_by_type, &data,
+ start_handle, end_handle);
return data.num_of_res;
}
uint16_t end_handle;
};
-static void read_by_type(void *data, void *user_data)
+static void read_by_type(struct gatt_db_attribute *attribute, void *user_data)
{
struct read_by_type_data *search_data = user_data;
- struct gatt_db_service *service = data;
- struct gatt_db_attribute *attribute;
+ struct gatt_db_service *service = attribute->service;
int i;
if (!service->active)
data.end_handle = end_handle;
data.queue = queue;
- queue_foreach(db->services, read_by_type, &data);
+ gatt_db_foreach_service_in_range(db, NULL, read_by_type, &data,
+ start_handle, end_handle);
}
uint16_t end_handle;
};
-static void find_information(void *data, void *user_data)
+static void find_information(struct gatt_db_attribute *attribute,
+ void *user_data)
{
struct find_information_data *search_data = user_data;
- struct gatt_db_service *service = data;
- struct gatt_db_attribute *attribute;
+ struct gatt_db_service *service = attribute->service;
int i;
if (!service->active)
return;
- /* Check if service is in range */
- if ((service->attributes[0]->handle + service->num_handles - 1) <
- search_data->start_handle)
- return;
-
for (i = 0; i < service->num_handles; i++) {
attribute = service->attributes[i];
if (!attribute)
data.end_handle = end_handle;
data.queue = queue;
- queue_foreach(db->services, find_information, &data);
+ gatt_db_foreach_service_in_range(db, NULL, find_information, &data,
+ start_handle, end_handle);
}
void gatt_db_foreach_service(struct gatt_db *db, const bt_uuid_t *uuid,
{
struct gatt_db_service *service = data;
struct foreach_data *foreach_data = user_data;
- uint16_t svc_start;
+ uint16_t svc_start, svc_end;
bt_uuid_t uuid;
- svc_start = get_handle_at_index(service, 0);
+ gatt_db_service_get_handles(service, &svc_start, &svc_end);
- if (svc_start > foreach_data->end || svc_start < foreach_data->start)
+ /* Check if service is within requested range */
+ if (svc_start > foreach_data->end || svc_end < foreach_data->start)
return;
if (foreach_data->uuid) {