From d36697ac5320d055567e00edb03f2d2f6d82211d Mon Sep 17 00:00:00 2001 From: Ingar Kulbrandstad Date: Wed, 2 Aug 2023 16:37:20 +0200 Subject: [PATCH] Bluetooth: Mesh: Fixed OP_AGG_SRV dependency of OP_AGG_CLI The OP_AGG_SRV is dependent that the OP_AGG_CLI is add for the OP_AGG_SRV to work. Moved the define of OP_AGG_CLI so it will call op_agg_send without the OP_AGG_CLI. Signed-off-by: Ingar Kulbrandstad --- subsys/bluetooth/mesh/op_agg.c | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/subsys/bluetooth/mesh/op_agg.c b/subsys/bluetooth/mesh/op_agg.c index d3b7238128adb5..4f6baacc898e5c 100644 --- a/subsys/bluetooth/mesh/op_agg.c +++ b/subsys/bluetooth/mesh/op_agg.c @@ -18,13 +18,13 @@ LOG_MODULE_REGISTER(bt_mesh_op_agg); NET_BUF_SIMPLE_DEFINE_STATIC(sdu, BT_MESH_TX_SDU_MAX); -#ifdef CONFIG_BT_MESH_OP_AGG_CLI +#if IS_ENABLED(CONFIG_BT_MESH_OP_AGG_CLI) NET_BUF_SIMPLE_DEFINE_STATIC(srcs, BT_MESH_TX_SDU_MAX); #endif static struct op_agg_ctx agg_ctx = { .sdu = &sdu, -#ifdef CONFIG_BT_MESH_OP_AGG_CLI +#if IS_ENABLED(CONFIG_BT_MESH_OP_AGG_CLI) .srcs = &srcs, #endif }; @@ -42,11 +42,7 @@ static bool ctx_match(struct bt_mesh_msg_ctx *ctx) int bt_mesh_op_agg_accept(struct bt_mesh_msg_ctx *msg_ctx) { -#ifdef CONFIG_BT_MESH_OP_AGG_CLI return agg_ctx.initialized && ctx_match(msg_ctx); -#else - return 0; -#endif } void bt_mesh_op_agg_ctx_reinit(void) @@ -58,22 +54,23 @@ int bt_mesh_op_agg_send(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *msg, const struct bt_mesh_send_cb *cb) { - uint16_t src; int err; /* Model responded so mark this message as acknowledged */ agg_ctx.ack = true; - /* Store source address so that Opcodes Aggregator Client can match - * response with source model - */ - src = bt_mesh_model_elem(model)->addr; + if (IS_ENABLED(CONFIG_BT_MESH_OP_AGG_CLI)) { + /* Store source address so that Opcodes Aggregator Client can + * match response with source model + */ + uint16_t src = bt_mesh_model_elem(model)->addr; - if (net_buf_simple_tailroom(&srcs) < 2) { - return -ENOMEM; - } + if (net_buf_simple_tailroom(&srcs) < 2) { + return -ENOMEM; + } - net_buf_simple_add_le16(&srcs, src); + net_buf_simple_add_le16(&srcs, src); + } err = bt_mesh_op_agg_encode_msg(msg); if (err) {