1 /* 2 * Copyright (c) 2024 Croxel, Inc. 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 #include "nus_internal.h" 8 9 #if defined(CONFIG_BT_ZEPHYR_NUS_DEFAULT_INSTANCE) 10 BT_NUS_INST_DEFINE(nus_def); bt_nus_inst_default(void)11struct bt_nus_inst *bt_nus_inst_default(void) 12 { 13 return &nus_def; 14 } 15 #else bt_nus_inst_default(void)16struct bt_nus_inst *bt_nus_inst_default(void) { return NULL; } 17 #endif 18 bt_nus_inst_get_from_attr(const struct bt_gatt_attr * attr)19struct bt_nus_inst *bt_nus_inst_get_from_attr(const struct bt_gatt_attr *attr) 20 { 21 STRUCT_SECTION_FOREACH(bt_nus_inst, instance) { 22 for (size_t i = 0 ; i < instance->svc->attr_count ; i++) { 23 if (attr == &instance->svc->attrs[i]) { 24 return instance; 25 } 26 } 27 } 28 29 return NULL; 30 } 31