zephyr/subsys/bluetooth/services/nus/nus_inst.c
Luis Ubieda 92e0d0bbfc bluetooth: nus: Change Kconfigs prefix to BT_ZEPHYR_NUS
To prevent future conflicts with NCS's NUS implementation, whose
Kconfig's are prefixed with BT_NUS.

Signed-off-by: Luis Ubieda <luisf@croxel.com>
2024-04-02 10:36:01 +03:00

31 lines
621 B
C

/*
* Copyright (c) 2024 Croxel, Inc.
*
* SPDX-License-Identifier: Apache-2.0
*/
#include "nus_internal.h"
#if defined(CONFIG_BT_ZEPHYR_NUS_DEFAULT_INSTANCE)
BT_NUS_INST_DEFINE(nus_def);
struct bt_nus_inst *bt_nus_inst_default(void)
{
return &nus_def;
}
#else
struct bt_nus_inst *bt_nus_inst_default(void) { return NULL; }
#endif
struct bt_nus_inst *bt_nus_inst_get_from_attr(const struct bt_gatt_attr *attr)
{
STRUCT_SECTION_FOREACH(bt_nus_inst, instance) {
for (size_t i = 0 ; i < instance->svc->attr_count ; i++) {
if (attr == &instance->svc->attrs[i]) {
return instance;
}
}
}
return NULL;
}