Skip to content

Commit

Permalink
Bluetooth: Mesh: Fixed OP_AGG_SRV dependency of OP_AGG_CLI
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
Balaklaka authored and jhedberg committed Aug 9, 2023
1 parent eafa2bb commit d36697a
Showing 1 changed file with 12 additions and 15 deletions.
27 changes: 12 additions & 15 deletions subsys/bluetooth/mesh/op_agg.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
};
Expand All @@ -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)
Expand All @@ -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) {
Expand Down

0 comments on commit d36697a

Please sign in to comment.