From 947e867f52318c1401a5a129f495eccb961e38db Mon Sep 17 00:00:00 2001 From: Ingar Kulbrandstad Date: Fri, 28 Jun 2024 13:37:44 +0200 Subject: [PATCH] Bluetooth: Mesh: Bridge Configuration Client/Server API Adding documentation and function calles for the API's in Bridge Configuration Client model and Bridge Configuration Server model. Signed-off-by: Ingar Kulbrandstad --- include/zephyr/bluetooth/mesh.h | 2 + include/zephyr/bluetooth/mesh/access.h | 4 + include/zephyr/bluetooth/mesh/brg_cfg.h | 92 ++++++ include/zephyr/bluetooth/mesh/brg_cfg_cli.h | 316 ++++++++++++++++++++ include/zephyr/bluetooth/mesh/brg_cfg_srv.h | 47 +++ subsys/bluetooth/mesh/CMakeLists.txt | 4 + subsys/bluetooth/mesh/Kconfig | 13 + subsys/bluetooth/mesh/brg_cfg_cli.c | 77 +++++ subsys/bluetooth/mesh/brg_cfg_srv.c | 35 +++ tests/bsim/bluetooth/mesh/prj.conf | 2 + 10 files changed, 592 insertions(+) create mode 100644 include/zephyr/bluetooth/mesh/brg_cfg.h create mode 100644 include/zephyr/bluetooth/mesh/brg_cfg_cli.h create mode 100644 include/zephyr/bluetooth/mesh/brg_cfg_srv.h create mode 100644 subsys/bluetooth/mesh/brg_cfg_cli.c create mode 100644 subsys/bluetooth/mesh/brg_cfg_srv.c diff --git a/include/zephyr/bluetooth/mesh.h b/include/zephyr/bluetooth/mesh.h index fc84814fa4421f..ba9272bbf40b70 100644 --- a/include/zephyr/bluetooth/mesh.h +++ b/include/zephyr/bluetooth/mesh.h @@ -48,6 +48,8 @@ #include #include #include +#include +#include #include #endif /* ZEPHYR_INCLUDE_BLUETOOTH_MESH_H_ */ diff --git a/include/zephyr/bluetooth/mesh/access.h b/include/zephyr/bluetooth/mesh/access.h index f1fca02783e87e..db477ee6206bf9 100644 --- a/include/zephyr/bluetooth/mesh/access.h +++ b/include/zephyr/bluetooth/mesh/access.h @@ -187,6 +187,10 @@ struct bt_mesh_elem { #define BT_MESH_MODEL_ID_REMOTE_PROV_SRV 0x0004 /** Remote Provisioning Client */ #define BT_MESH_MODEL_ID_REMOTE_PROV_CLI 0x0005 +/** Bridge Configuration Sever */ +#define BT_MESH_MODEL_ID_BRG_CFG_SRV 0x0008 +/** Bridge Configuration Client */ +#define BT_MESH_MODEL_ID_BRG_CFG_CLI 0x0009 /** Private Beacon Server */ #define BT_MESH_MODEL_ID_PRIV_BEACON_SRV 0x000a /** Private Beacon Client */ diff --git a/include/zephyr/bluetooth/mesh/brg_cfg.h b/include/zephyr/bluetooth/mesh/brg_cfg.h new file mode 100644 index 00000000000000..51a863e497b274 --- /dev/null +++ b/include/zephyr/bluetooth/mesh/brg_cfg.h @@ -0,0 +1,92 @@ +/* + * Copyright (c) 2024 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef ZEPHYR_INCLUDE_BLUETOOTH_MESH_BRG_CFG_H__ +#define ZEPHYR_INCLUDE_BLUETOOTH_MESH_BRG_CFG_H__ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup bt_mesh_brg_cfg Bridge Configuration common header + * @ingroup bt_mesh + * @{ + */ + +/** Subnet Bridge states */ +enum bt_mesh_subnet_bridge_state { + /** Subnet bridge functionality is disabled. */ + BT_MESH_SUBNET_BRIDGE_DISABLED, + /** Subnet bridge state functionality is enabled. */ + BT_MESH_SUBNET_BRIDGE_ENABLED, +}; + +/** Bridging Table state entry corresponding to a entry in the Bridging Table. */ +struct bridging_table_entry { + /** Allowed directions for the bridged traffic (or bridged traffic not allowed) */ + uint8_t directions; + /** NetKey Index of the first subnet */ + uint16_t net_idx1; + /** NetKey Index of the second subnet */ + uint16_t net_idx2; + /** Address of the node in the first subnet */ + uint16_t addr1; + /** Address of the node in the second subnet */ + uint16_t addr2; +}; + +/** Bridging Table Status response */ +struct bt_mesh_bridging_table_status { + /** Status Code of the requesting message */ + enum bt_mesh_subnet_bridge_state status; + /** Requested Bridging Table entry */ + struct bridging_table_entry entry; +}; + +/** Used to filter set of pairs of NetKey Indexes from the Bridging Table */ +struct bt_mesh_filter_netkey { + uint16_t filter:2, /* Filter applied to the set of pairs of NetKey Indexes */ + prohibited:2, /* Prohibited */ + net_idx:12; /* NetKey Index used for filtering or ignored */ +}; + +/** Bridged Subnets List response */ +struct bt_mesh_bridged_subnets_list { + /** Filter applied NetKey Indexes, and NetKey Index used for filtering. */ + struct bt_mesh_filter_netkey net_idx_filter; + /** Start offset in units of bridges */ + uint8_t start_idx; + /** Pointer to allocated buffer for storing filtered of NetKey Indexes */ + struct net_buf_simple *list; +}; + +/** Bridging Table List response */ +struct bt_mesh_bridging_table_list { + /** Status Code of the requesting message */ + uint8_t status; + /** NetKey Index of the first subnet */ + uint16_t net_idx1; + /** NetKey Index of the second subnet */ + uint16_t net_idx2; + /** Start offset in units of bridging table state entries */ + uint16_t start_idx; + /** Pointer to allocated buffer for storing list of bridged addresses and directions */ + struct net_buf_simple *list; +}; + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif /* ZEPHYR_INCLUDE_BLUETOOTH_MESH_BRG_CFG_H__ */ diff --git a/include/zephyr/bluetooth/mesh/brg_cfg_cli.h b/include/zephyr/bluetooth/mesh/brg_cfg_cli.h new file mode 100644 index 00000000000000..2c71e133f92baf --- /dev/null +++ b/include/zephyr/bluetooth/mesh/brg_cfg_cli.h @@ -0,0 +1,316 @@ +/* + * Copyright (c) 2024 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef ZEPHYR_INCLUDE_BLUETOOTH_MESH_BRG_CFG_CLI_H__ +#define ZEPHYR_INCLUDE_BLUETOOTH_MESH_BRG_CFG_CLI_H__ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup bt_mesh_brg_cfg_cli Bridge Configuration Client Model + * @ingroup bt_mesh + * @{ + * @brief API for the Bluetooth Mesh Bridge Configuration Client model + */ + +struct bt_mesh_brg_cfg_cli; + +/** + * @brief Bridge Configuration Client model Composition Data entry. + * + * @param _cli Pointer to a @ref bt_mesh_brg_cfg_cli instance. + */ +#define BT_MESH_MODEL_BRG_CFG_CLI(_cli) \ + BT_MESH_MODEL_CB(BT_MESH_MODEL_ID_BRG_CFG_CLI, _bt_mesh_brg_cfg_cli_op, NULL, _cli, \ + &_bt_mesh_brg_cfg_cli_cb) + +/** Mesh Bridge Configuration Client Status messages callback */ +struct bt_mesh_brg_cfg_cli_cb { + /** @brief Optional callback for Subnet Bridge Status message. + * + * Handles received Subnet Bridge Status messages from a Bridge + * Configuration Server. + + * @param cli Bridge Configuration Client context. + * @param addr Address of the sender. + * @param status Status received from the server. + */ + void (*subnet_bridge_status)(struct bt_mesh_brg_cfg_cli *cli, uint16_t addr, + enum bt_mesh_subnet_bridge_state status); + + /** @brief Optional callback for Bridging Table Size Status message. + * + * Handles received Bridging Table Size Status messages from a Bridge + * Configuration Server. + * + * @param cli Bridge Configuration Client context. + * @param addr Address of the sender. + * @param size Size received from the server. + */ + void (*bridging_table_size_status)(struct bt_mesh_brg_cfg_cli *cli, uint16_t addr, + uint16_t size); + + /** @brief Optional callback for Bridging Table Status message. + * + * Handles received Bridging Table status messages from a Bridge + * Configuration Server. + * + * @param cli Bridge Configuration Client context. + * @param addr Address of the sender. + * @param rsp Response received from the Bridging Configuration Server. + */ + void (*bridging_table_status)(struct bt_mesh_brg_cfg_cli *cli, uint16_t addr, + struct bt_mesh_bridging_table_status *rsp); + + /** @brief Optional callback for Bridged Subnets List message. + * + * Handles received Bridged Subnets List messages from a Bridge + * Configuration Server. + * + * @param cli Bridge Configuration Client context. + * @param addr Address of the sender. + * @param rsp Response received from the Bridging Configuration Server. + */ + void (*bridged_subnets_list)(struct bt_mesh_brg_cfg_cli *cli, uint16_t addr, + struct bt_mesh_bridged_subnets_list *rsp); + + /** @brief Optional callback for Bridging Table List message. + * + * Handles received Bridging Table List messages from a Bridge + * Configuration Server. + * + * @param cli Bridge Configuration Client context. + * @param addr Address of the sender. + * @param rsp Response received from the Bridging Configuration Server. + */ + void (*bridging_table_list)(struct bt_mesh_brg_cfg_cli *cli, uint16_t addr, + struct bt_mesh_bridging_table_list *rsp); +}; + +/** Bridge Configuration Client Model Context */ +struct bt_mesh_brg_cfg_cli { + /** Bridge Configuration model entry pointer */ + const struct bt_mesh_model *model; + + /** Event handler callbacks */ + const struct bt_mesh_bdg_cfg_cli_cb *cb; + + /* Internal parameters for tracking message responses. */ + struct bt_mesh_msg_ack_ctx ack_ctx; +}; + +/** @brief Sends a Subnet Bridge Get message to the given destination address + * + * This function sends a Subnet Bridge Get message to the given destination + * address to query the value of the Subnet Bridge state of a subnet. The + * Subnet Bridge state indicates whether the subnet bridged feature is enabled + * or not. The function expects a Subnet Bridge Status message as a response + * from the destination node. + * + * This method can be used asynchronously by setting @p status as NULL. This + * way the method will not wait for response and will return immediately after + * sending the command. + * + * @param net_idx Network index to encrypt the message with. + * @param addr Target node address. + * @param status Status response parameter, returns one of + * @ref BT_MESH_SUBNET_BRIDGE_DISABLED or + * @ref BT_MESH_SUBNET_BRIDGE_ENABLED on success. + * + * @return 0 on success, or (negative) error code on failure. + */ +int bt_mesh_brg_cfg_cli_subnet_bridge_get(uint16_t net_idx, uint16_t addr, + enum bt_mesh_subnet_bridge_state *status); + +/** @brief Sends a Subnet Bridge Set message to the given destination address + * with the given parameters + * + * This function sends a Subnet Bridge Set message to the given destination + * address with the given parameters to set the value of the Subnet Bridge + * state of a subnet. The Subnet Bridge state indicates whether the subnet + * bridge feature is enabled or not. The function expects a Subnet Bridge + * Status message as a response from the destination node. + * + * This method can be used asynchronously by setting @p status as NULL. This + * way the method will not wait for response and will return immediately after + * sending the command. + * + * @param net_idx Network index to encrypt the message with. + * @param addr Target node address. + * @param val Value to set the Subnet Bridge state to. Must be one of + * @ref BT_MESH_SUBNET_BRIDGE_DISABLED or + * @ref BT_MESH_SUBNET_BRIDGE_ENABLED. + * @param status Status response parameter, returns one of + * @ref BT_MESH_SUBNET_BRIDGE_DISABLED or + * @ref BT_MESH_SUBNET_BRIDGE_ENABLED on success. + * + * @return 0 on success, or (negative) error code on failure. + */ +int bt_mesh_brg_cfg_cli_subnet_bridge_set(uint16_t net_idx, uint16_t addr, + enum bt_mesh_subnet_bridge_state val, + enum bt_mesh_subnet_bridge_state *status); + +/** @brief Sends a Bridging Table Size Get message to the given destination + * address with the given parameters + * + * This function sends a Bridging Table Size Get message to the given + * destination address with the given parameters to get the size of the Bridging + * Table of the node. The Bridging Table size indicates the maximum number of + * entries that can be stored in the Bridging Table. The function expects a + * Bridging Table Size Status message as a response from the destination node. + * + * This method can be used asynchronously by setting @p size as NULL. This way + * the method will not wait for response and will return immediately after + * sending the command. + * + * @param net_idx Network index to encrypt the message with. + * @param addr Target node address. + * @param size Bridging Table size response parameter. + * + * @return 0 on success, or (negative) error code on failure. + */ +int bt_mesh_brg_cfg_cli_bridging_table_size_get(uint16_t net_idx, uint16_t addr, uint16_t *size); + +/** @brief Sends a Bridging Table Add message to the given destination address + * with the given parameters + * + * This function sends a Bridging Table Add message to the given destination + * address with the given parameters to add an entry to the Bridging Table. The + * Bridging Table contains the net keys and addresses that are authorized to be + * bridged by the node. The function expects a Bridging Table Status message as + * a response from the destination node. + * + * This method can be used asynchronously by setting @p rsp as NULL. This way + * the method will not wait for response and will return immediately after + * sending the command. + * + * @param net_idx Network index to encrypt the message with. + * @param addr Target node address. + * @param directions Allowed directions for the bridged traffic + * @param net_idx1 NetKey Index of the first subnet + * @param net_idx2 NetKey Index of the second subnet + * @param addr1 Address of the node in the first subnet + * @param addr2 Address of the node in the second subnet + * @param rsp Status response parameter + * + * @return 0 on success, or (negative) error code on failure. + */ +int bt_mesh_brg_cfg_cli_bridging_table_add(uint16_t net_idx, uint16_t addr, uint8_t directions, + uint16_t net_idx1, uint16_t net_idx2, + uint16_t addr1, uint16_t addr2, + struct bt_mesh_bridging_table_status *rsp); + +/** @brief Sends a Bridging Table Remove message to the given destination + * address with the given parameters + * + * This function sends a Bridging Table Remove message to the given destination + * address with the given parameters to remove an entry from the Bridging + * Table. The Bridging Table contains the net keys and addresses that are + * authorized to be bridged by the node. The function expects a Bridging Table + * Status message as a response from the destination node. + * + * This method can be used asynchronously by setting @p rsp as NULL. This way + * the method will not wait for response and will return immediately after + * sending the command. + * + * @param net_idx Network index to encrypt the message with. + * @param addr Target node address. + * @param net_idx1 NetKey Index of the first subnet + * @param net_idx2 NetKey Index of the second subnet + * @param addr1 Address of the node in the first subnet + * @param addr2 Address of the node in the second subnet + * @param rsp Pointer to a struct storing the received response from the + * server, or NULL to not wait for a response. + * + * @return 0 on success, or (negative) error code on failure. + */ +int bt_mesh_brg_cfg_cli_bridging_table_remove(uint16_t net_idx, uint16_t addr, uint16_t net_idx1, + uint16_t net_idx2, uint16_t addr1, uint16_t addr2, + struct bt_mesh_bridging_table_status *rsp); + +/** @brief Sends a Bridged Subnets Get message to the given destination address + * with the given parameters + * + * This function sends a Bridged Subnets Get message to the given destination + * address with the given parameters to get the list of subnets that are + * bridged by the node. The function expects a Bridged Subnets List message as + * a response from the destination node. + * + * This method can be used asynchronously by setting @p rsp as NULL. This way + * the method will not wait for response and will return immediately after + * sending the command. + * + * When @c rsp is set, the user is responsible for providing a buffer for the + * filtered set of N pairs of NetKey Indexes in + * @ref bt_mesh_bridged_subnets_list::list. If a buffer is not provided, the + * bridged subnets won't be copied. + + * @param net_idx Network index to encrypt the message with. + * @param addr Target node address. + * @param filter_net_idx Filter and NetKey Index used for filtering + * @param start_idx Start offset to read in units of Bridging Table state entries + * @param rsp Pointer to a struct storing the received response + * from the server, or NULL to not wait for a response. + * + * @return 0 on success, or (negative) error code on failure. + */ +int bt_mesh_brg_cfg_cli_bridged_subnets_get(uint16_t net_idx, uint16_t addr, + struct bt_mesh_filter_netkey filter_net_idx, + uint8_t start_idx, + struct bt_mesh_bridged_subnets_list *rsp); + +/** @brief Sends a Bridging Table Get message to the given destination address + * with the given parameters + * + * This function sends a Bridging Table Get message to the given destination + * address with the given parameters to get the contents of the Bridging Table. + * The Bridging Table contains the addresses that are authorized to be bridged + * by the node. The function expects a Bridging Table List message as a + * response from the destination node. + * + * This method can be used asynchronously by setting @p rsp as NULL. This way + * the method will not wait for response and will return immediately after + * sending the command. + * + * When @c rsp is set, the user is responsible for providing a buffer for the + * filtered set of N pairs of NetKey Indexes in + * @ref bt_mesh_bridging_table_list::list. If a buffer is not provided, the + * bridged addresses won't be copied. If a buffer size is shorter than received + * list, only those many entries that fit in the buffer will be copied from the + * list, and rest will be discarded. + * + * @param net_idx Network index to encrypt the message with. + * @param addr Target node address. + * @param net_idx1 NetKey Index of the first subnet. + * @param net_idx2 NetKey Index of the second subnet. + * @param start_idx Start offset to read in units of Bridging Table state entries. + * @param rsp Pointer to a struct storing the received response from the + * server, or NULL to not wait for a response. + * + * @return 0 on success, or (negative) error code on failure. + */ +int bt_mesh_brg_cfg_cli_bridging_table_get(uint16_t net_idx, uint16_t addr, uint16_t net_idx1, + uint16_t net_idx2, uint16_t start_idx, + struct bt_mesh_bridging_table_list *rsp); + +/** @cond INTERNAL_HIDDEN */ +extern const struct bt_mesh_model_op _bt_mesh_brg_cfg_cli_op[]; +extern const struct bt_mesh_model_cb _bt_mesh_brg_cfg_cli_cb; +/** @endcond */ + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif /* ZEPHYR_INCLUDE_BLUETOOTH_MESH_BRG_CFG_CLI_H__ */ diff --git a/include/zephyr/bluetooth/mesh/brg_cfg_srv.h b/include/zephyr/bluetooth/mesh/brg_cfg_srv.h new file mode 100644 index 00000000000000..b642cc78b42a0f --- /dev/null +++ b/include/zephyr/bluetooth/mesh/brg_cfg_srv.h @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2024 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/** @file + * @brief Bluetooth Mesh Bridge Configuration Server Model APIs. + */ +#ifndef ZEPHYR_INCLUDE_BLUETOOTH_MESH_BRG_CFG_SRV_H__ +#define ZEPHYR_INCLUDE_BLUETOOTH_MESH_BRG_CFG_SRV_H__ + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @defgroup bt_mesh_brg_cfg_srv Bridge Configuration Server Model + * @ingroup bt_mesh + * @{ + * @brief API for the Bluetooth Mesh Bridge Configuration Server model + */ + +/** + * + * @brief Bridge Configuration Server model Composition Data entry. + */ +#define BT_MESH_MODEL_BRG_CFG_SRV \ + BT_MESH_MODEL_CB(BT_MESH_MODEL_ID_BRG_CFG_SRV, bt_mesh_brg_cfg_srv_op, \ + NULL, NULL, &bt_mesh_brg_cfg_srv_cb) + +/** @cond INTERNAL_HIDDEN */ +extern const struct bt_mesh_model_op bt_mesh_brg_cfg_srv_op[]; +extern const struct bt_mesh_model_cb bt_mesh_brg_cfg_srv_cb; +/** @endcond */ + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif /* ZEPHYR_INCLUDE_BLUETOOTH_MESH_BRG_CFG_SRV_H__ */ diff --git a/subsys/bluetooth/mesh/CMakeLists.txt b/subsys/bluetooth/mesh/CMakeLists.txt index 2009601f0f8070..cbc80d0f9f96f5 100644 --- a/subsys/bluetooth/mesh/CMakeLists.txt +++ b/subsys/bluetooth/mesh/CMakeLists.txt @@ -113,6 +113,10 @@ zephyr_library_sources_ifdef(CONFIG_BT_MESH_SOL_PDU_RPL_CLI sol_pdu_rpl_cli.c) zephyr_library_sources_ifdef(CONFIG_BT_MESH_OD_PRIV_PROXY_SRV sol_pdu_rpl_srv.c) +zephyr_library_sources_ifdef(CONFIG_BT_MESH_BRG_CFG_CLI brg_cfg_cli.c) + +zephyr_library_sources_ifdef(CONFIG_BT_MESH_BRG_CFG_SRV brg_cfg_srv.c) + zephyr_library_sources_ifdef(CONFIG_BT_MESH_SOLICITATION solicitation.c) zephyr_library_sources_ifdef(CONFIG_BT_MESH_STATISTIC statistic.c) diff --git a/subsys/bluetooth/mesh/Kconfig b/subsys/bluetooth/mesh/Kconfig index bcf781e72d2441..f1e4941154f55b 100644 --- a/subsys/bluetooth/mesh/Kconfig +++ b/subsys/bluetooth/mesh/Kconfig @@ -1227,6 +1227,19 @@ config BT_MESH_SOL_PDU_RPL_CLI_TIMEOUT for a response message to arrive. This value can be changed at runtime using @ref bt_mesh_sol_pdu_rpl_cli_timeout_set. +config BT_MESH_BRG_CFG_SRV + bool "Support for Bridge Configuration Server model" + depends on BT_MESH_MODEL_EXTENSIONS + help + The Bridge Configuration Server model is used to support the configuration + of the subnet bridge functionality of a node. + +config BT_MESH_BRG_CFG_CLI + bool "Support for Bridge Configuration Client model" + help + The Bridge Configuration Client is used to support the functionality of a + node that can configure the subnet bridge functionality of another node. + endmenu # Models menu "Proxy" diff --git a/subsys/bluetooth/mesh/brg_cfg_cli.c b/subsys/bluetooth/mesh/brg_cfg_cli.c new file mode 100644 index 00000000000000..61dede289d4e58 --- /dev/null +++ b/subsys/bluetooth/mesh/brg_cfg_cli.c @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2024 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include + +#define LOG_LEVEL CONFIG_BT_MESH_MODEL_LOG_LEVEL +#include +LOG_MODULE_REGISTER(bt_mesh_brg_cfg_cli); + +const struct bt_mesh_model_op _bt_mesh_brg_cfg_cli_op[] = { + BT_MESH_MODEL_OP_END, +}; + +static int brg_cfg_cli_init(const struct bt_mesh_model *model) +{ + if (!bt_mesh_model_in_primary(model)) { + LOG_ERR("Bridge Configuration Client only allowed in primary element"); + return -EINVAL; + } + + return 0; +} + +const struct bt_mesh_model_cb _bt_mesh_brg_cfg_cli_cb = { + .init = brg_cfg_cli_init, +}; + +int bt_mesh_brg_cfg_cli_subnet_bridge_get(uint16_t net_idx, uint16_t addr, + enum bt_mesh_subnet_bridge_state *status) +{ + return 0; +} + +int bt_mesh_brg_cfg_cli_subnet_bridge_set(uint16_t net_idx, uint16_t addr, + enum bt_mesh_subnet_bridge_state val, + enum bt_mesh_subnet_bridge_state *status) +{ + return 0; +} + +int bt_mesh_brg_cfg_cli_bridging_table_size_get(uint16_t net_idx, uint16_t addr, uint16_t *size) +{ + return 0; +} + +int bt_mesh_brg_cfg_cli_bridging_table_add(uint16_t net_idx, uint16_t addr, uint8_t directions, + uint16_t net_idx1, uint16_t net_idx2, + uint16_t addr1, uint16_t addr2, + struct bt_mesh_bridging_table_status *rsp) +{ + return 0; +} + +int bt_mesh_brg_cfg_cli_bridging_table_remove(uint16_t net_idx, uint16_t addr, uint16_t net_idx1, + uint16_t net_idx2, uint16_t addr1, uint16_t addr2, + struct bt_mesh_bridging_table_status *rsp) +{ + return 0; +} + +int bt_mesh_brg_cfg_cli_bridged_subnets_get(uint16_t net_idx, uint16_t addr, + struct bt_mesh_filter_netkey filter_net_idx, + uint8_t start_idx, + struct bt_mesh_bridged_subnets_list *rsp) +{ + return 0; +} + +int bt_mesh_brg_cfg_cli_bridging_table_get(uint16_t net_idx, uint16_t addr, uint16_t net_idx1, + uint16_t net_idx2, uint16_t start_idx, + struct bt_mesh_bridging_table_list *rsp) +{ + return 0; +} diff --git a/subsys/bluetooth/mesh/brg_cfg_srv.c b/subsys/bluetooth/mesh/brg_cfg_srv.c new file mode 100644 index 00000000000000..60aef4bf02c0b7 --- /dev/null +++ b/subsys/bluetooth/mesh/brg_cfg_srv.c @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include + +#define LOG_LEVEL CONFIG_BT_MESH_MODEL_LOG_LEVEL +#include +LOG_MODULE_REGISTER(bt_mesh_brg_cfg_srv); + +const struct bt_mesh_model_op _bt_mesh_brg_cfg_srv_op[] = { + BT_MESH_MODEL_OP_END, +}; + +static int brg_cfg_srv_init(const struct bt_mesh_model *model) +{ + const struct bt_mesh_model *config_srv = + bt_mesh_model_find(bt_mesh_model_elem(model), BT_MESH_MODEL_ID_CFG_SRV); + + if (config_srv == NULL) { + LOG_ERR("Bridge Configuration Server only allowed in primary element"); + return -EINVAL; + } + + + bt_mesh_model_extend(model, config_srv); + + return 0; +} + +const struct bt_mesh_model_cb _bt_mesh_brg_cfg_srv_cb = { + .init = brg_cfg_srv_init, +}; diff --git a/tests/bsim/bluetooth/mesh/prj.conf b/tests/bsim/bluetooth/mesh/prj.conf index 1c343bb512f130..eb810ef01162bc 100644 --- a/tests/bsim/bluetooth/mesh/prj.conf +++ b/tests/bsim/bluetooth/mesh/prj.conf @@ -64,6 +64,8 @@ CONFIG_BT_MESH_PRIV_BEACON_SRV=y CONFIG_BT_MESH_PRIV_BEACON_CLI=y CONFIG_BT_MESH_OD_PRIV_PROXY_SRV=y CONFIG_BT_MESH_OD_PRIV_PROXY_CLI=y +CONFIG_BT_MESH_BRG_CFG_SRV=y +CONFIG_BT_MESH_BRG_CFG_CLI=y CONFIG_BT_MESH_COMP_PAGE_1=y CONFIG_BT_MESH_COMP_PAGE_2=y CONFIG_BT_TESTING=y