diff --git a/include/zephyr/bluetooth/mesh/access.h b/include/zephyr/bluetooth/mesh/access.h index aa623549814..45042b87d9b 100644 --- a/include/zephyr/bluetooth/mesh/access.h +++ b/include/zephyr/bluetooth/mesh/access.h @@ -31,10 +31,11 @@ #endif #ifdef CONFIG_BT_MESH_MODEL_EXTENSIONS -#define BT_MESH_MODEL_NEXT_UNASSIGNED() \ - .next = (const struct bt_mesh_model *[]){ NULL }, +#define BT_MESH_MODEL_RUNTIME_INIT(_user_data) \ + .rt = (void *)(void *[]){ NULL, NULL, (_user_data) }, #else -#define BT_MESH_MODEL_NEXT_UNASSIGNED() +#define BT_MESH_MODEL_RUNTIME_INIT(_user_data) \ + .rt = (void *)(void *[]){ NULL, (_user_data) }, #endif /** @@ -432,9 +433,7 @@ struct bt_mesh_model_op { #define BT_MESH_MODEL_CNT_CB(_id, _op, _pub, _user_data, _keys, _grps, _cb) \ { \ .id = (_id), \ - .elem_idx = (uint8_t []) { 0 }, \ - .mod_idx = (uint8_t []) { 0 }, \ - .flags = (uint16_t []) { 0 }, \ + BT_MESH_MODEL_RUNTIME_INIT(_user_data) \ .pub = _pub, \ .keys = (uint16_t []) BT_MESH_MODEL_KEYS_UNUSED(_keys), \ .keys_cnt = _keys, \ @@ -443,8 +442,6 @@ struct bt_mesh_model_op { BT_MESH_MODEL_UUIDS_UNASSIGNED() \ .op = _op, \ .cb = _cb, \ - BT_MESH_MODEL_NEXT_UNASSIGNED() \ - .user_data = (void *[]){ _user_data }, \ } /** @@ -469,9 +466,7 @@ struct bt_mesh_model_op { { \ .vnd.company = (_company), \ .vnd.id = (_id), \ - .elem_idx = (uint8_t []) { 0 }, \ - .mod_idx = (uint8_t []) { 0 }, \ - .flags = (uint16_t []) { 0 }, \ + BT_MESH_MODEL_RUNTIME_INIT(_user_data) \ .op = _op, \ .pub = _pub, \ .keys = (uint16_t []) BT_MESH_MODEL_KEYS_UNUSED(_keys), \ @@ -479,8 +474,6 @@ struct bt_mesh_model_op { .groups = (uint16_t []) BT_MESH_MODEL_GROUPS_UNASSIGNED(_grps), \ .groups_cnt = _grps, \ BT_MESH_MODEL_UUIDS_UNASSIGNED() \ - BT_MESH_MODEL_NEXT_UNASSIGNED() \ - .user_data = (void *[]){ _user_data }, \ .cb = _cb, \ } @@ -520,9 +513,7 @@ struct bt_mesh_model_op { #define BT_MESH_MODEL_METADATA_CB(_id, _op, _pub, _user_data, _cb, _metadata) \ { \ .id = (_id), \ - .elem_idx = (uint8_t []) { 0 }, \ - .mod_idx = (uint8_t []) { 0 }, \ - .flags = (uint16_t []) { 0 }, \ + BT_MESH_MODEL_RUNTIME_INIT(_user_data) \ .pub = _pub, \ .keys = (uint16_t []) BT_MESH_MODEL_KEYS_UNUSED(CONFIG_BT_MESH_MODEL_KEY_COUNT), \ .keys_cnt = CONFIG_BT_MESH_MODEL_KEY_COUNT, \ @@ -531,8 +522,6 @@ struct bt_mesh_model_op { BT_MESH_MODEL_UUIDS_UNASSIGNED() \ .op = _op, \ .cb = _cb, \ - BT_MESH_MODEL_NEXT_UNASSIGNED() \ - .user_data = (void *[]){ _user_data }, \ .metadata = _metadata, \ } #else @@ -578,9 +567,7 @@ struct bt_mesh_model_op { { \ .vnd.company = (_company), \ .vnd.id = (_id), \ - .elem_idx = (uint8_t []) { 0 }, \ - .mod_idx = (uint8_t []) { 0 }, \ - .flags = (uint16_t []) { 0 }, \ + BT_MESH_MODEL_RUNTIME_INIT(_user_data) \ .op = _op, \ .pub = _pub, \ .keys = (uint16_t []) BT_MESH_MODEL_KEYS_UNUSED(CONFIG_BT_MESH_MODEL_KEY_COUNT), \ @@ -588,8 +575,6 @@ struct bt_mesh_model_op { .groups = (uint16_t []) BT_MESH_MODEL_GROUPS_UNASSIGNED(CONFIG_BT_MESH_MODEL_GROUP_COUNT), \ .groups_cnt = CONFIG_BT_MESH_MODEL_GROUP_COUNT, \ BT_MESH_MODEL_UUIDS_UNASSIGNED() \ - BT_MESH_MODEL_NEXT_UNASSIGNED() \ - .user_data = (void *[]){ _user_data }, \ .cb = _cb, \ .metadata = _metadata, \ } @@ -900,10 +885,19 @@ struct bt_mesh_model { const struct bt_mesh_mod_id_vnd vnd; }; - /* Internal information, mainly for persistent storage */ - uint8_t * const elem_idx; /* Belongs to Nth element */ - uint8_t * const mod_idx; /* Is the Nth model in the element */ - uint16_t * const flags; /* Model flags for internal bookkeeping */ + /* Model runtime information */ + struct { + uint8_t elem_idx; /* Belongs to Nth element */ + uint8_t mod_idx; /* Is the Nth model in the element */ + uint16_t flags; /* Model flags for internal bookkeeping */ + +#ifdef CONFIG_BT_MESH_MODEL_EXTENSIONS + /* Pointer to the next model in a model extension list. */ + const struct bt_mesh_model *next; +#endif + /** Model-specific user data */ + void *user_data; + } * const rt; /** Model Publication */ struct bt_mesh_model_pub * const pub; @@ -927,18 +921,10 @@ struct bt_mesh_model { /** Model callback structure. */ const struct bt_mesh_model_cb * const cb; -#ifdef CONFIG_BT_MESH_MODEL_EXTENSIONS - /* Pointer to the next model in a model extension list. */ - const struct bt_mesh_model ** const next; -#endif - #if defined(CONFIG_BT_MESH_LARGE_COMP_DATA_SRV) || defined(__DOXYGEN__) /* Pointer to the array of model metadata entries. */ struct bt_mesh_models_metadata_entry **metadata; #endif - - /** Model-specific user data */ - void ** const user_data; }; /** Callback structure for monitoring model message sending */ @@ -1048,7 +1034,7 @@ const struct bt_mesh_model *bt_mesh_model_find_vnd(const struct bt_mesh_elem *el */ static inline bool bt_mesh_model_in_primary(const struct bt_mesh_model *mod) { - return (*(mod->elem_idx) == 0); + return (mod->rt->elem_idx == 0); } /** @brief Immediately store the model's user data in persistent storage. diff --git a/samples/boards/nrf/mesh/onoff-app/src/main.c b/samples/boards/nrf/mesh/onoff-app/src/main.c index 817d2c023a6..71b787fe497 100644 --- a/samples/boards/nrf/mesh/onoff-app/src/main.c +++ b/samples/boards/nrf/mesh/onoff-app/src/main.c @@ -286,7 +286,7 @@ static int gen_onoff_get(const struct bt_mesh_model *model, struct net_buf_simple *buf) { NET_BUF_SIMPLE_DEFINE(msg, 2 + 1 + 4); - struct led_onoff_state *onoff_state = *(model->user_data); + struct led_onoff_state *onoff_state = model->rt->user_data; printk("addr 0x%04x onoff 0x%02x\n", bt_mesh_model_elem(model)->addr, onoff_state->current); @@ -305,7 +305,7 @@ static int gen_onoff_set_unack(const struct bt_mesh_model *model, struct net_buf_simple *buf) { struct net_buf_simple *msg = model->pub->msg; - struct led_onoff_state *onoff_state = *(model->user_data); + struct led_onoff_state *onoff_state = model->rt->user_data; int err; onoff_state->current = net_buf_simple_pull_u8(buf); diff --git a/samples/boards/nrf/mesh/onoff_level_lighting_vnd_app/src/mesh/device_composition.c b/samples/boards/nrf/mesh/onoff_level_lighting_vnd_app/src/mesh/device_composition.c index 54a5a2c8af7..775c793bb37 100644 --- a/samples/boards/nrf/mesh/onoff_level_lighting_vnd_app/src/mesh/device_composition.c +++ b/samples/boards/nrf/mesh/onoff_level_lighting_vnd_app/src/mesh/device_composition.c @@ -991,7 +991,7 @@ static int vnd_get(const struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ct struct net_buf_simple *buf) { struct net_buf_simple *msg = NET_BUF_SIMPLE(3 + 6 + 4); - struct vendor_state *state = *(model->user_data); + struct vendor_state *state = model->rt->user_data; /* This is dummy response for demo purpose */ state->response = 0xA578FEB3; @@ -1014,7 +1014,7 @@ static int vnd_set_unack(const struct bt_mesh_model *model, uint8_t tid; int current; int64_t now; - struct vendor_state *state = *(model->user_data); + struct vendor_state *state = model->rt->user_data; current = net_buf_simple_pull_le16(buf); tid = net_buf_simple_pull_u8(buf); diff --git a/samples/boards/reel_board/mesh_badge/src/mesh.c b/samples/boards/reel_board/mesh_badge/src/mesh.c index ae219387cf5..61af8cc0b6d 100644 --- a/samples/boards/reel_board/mesh_badge/src/mesh.c +++ b/samples/boards/reel_board/mesh_badge/src/mesh.c @@ -184,7 +184,7 @@ static int gen_onoff_get(const struct bt_mesh_model *model, struct net_buf_simple *buf) { NET_BUF_SIMPLE_DEFINE(msg, 2 + 1 + 4); - struct led_onoff_state *state = *(model->user_data); + struct led_onoff_state *state = model->rt->user_data; printk("addr 0x%04x onoff 0x%02x\n", bt_mesh_model_elem(model)->addr, state->current); @@ -203,7 +203,7 @@ static int gen_onoff_set_unack(const struct bt_mesh_model *model, struct net_buf_simple *buf) { struct net_buf_simple *msg = model->pub->msg; - struct led_onoff_state *state = *(model->user_data); + struct led_onoff_state *state = model->rt->user_data; int err; uint8_t tid, onoff; int64_t now; diff --git a/subsys/bluetooth/mesh/access.c b/subsys/bluetooth/mesh/access.c index 2911a42c7af..4b6a45ae5c8 100644 --- a/subsys/bluetooth/mesh/access.c +++ b/subsys/bluetooth/mesh/access.c @@ -92,12 +92,12 @@ static struct mod_relation mod_rel_list[MOD_REL_LIST_SIZE]; (idx)++) #define IS_MOD_BASE(mod, idx, offset) \ - (mod_rel_list[(idx)].elem_base == *((mod)->elem_idx) && \ - mod_rel_list[(idx)].idx_base == *((mod)->mod_idx) + (offset)) + (mod_rel_list[(idx)].elem_base == mod->rt->elem_idx && \ + mod_rel_list[(idx)].idx_base == mod->rt->mod_idx + (offset)) #define IS_MOD_EXTENSION(mod, idx, offset) \ - (mod_rel_list[(idx)].elem_ext == *((mod)->elem_idx) && \ - mod_rel_list[(idx)].idx_ext == *((mod)->mod_idx) + (offset)) + (mod_rel_list[(idx)].elem_ext == mod->rt->elem_idx && \ + mod_rel_list[(idx)].idx_ext == mod->rt->mod_idx + (offset)) #define RELATION_TYPE_EXT 0xFF @@ -533,7 +533,7 @@ static void add_items_to_page(struct net_buf_simple *buf, const struct bt_mesh_m MOD_REL_LIST_FOR_EACH(i) { if (IS_MOD_EXTENSION(mod, i, sig_offset) && mod_rel_list[i].type == RELATION_TYPE_EXT) { - elem_offset = *(mod->elem_idx) - mod_rel_list[i].elem_base; + elem_offset = mod->rt->elem_idx - mod_rel_list[i].elem_base; mod_idx = mod_rel_list[i].idx_base; if (ext_mod_cnt < 32 && elem_offset < 4 && @@ -569,7 +569,7 @@ static size_t mod_items_size(const struct bt_mesh_model *mod, uint8_t sig_offset MOD_REL_LIST_FOR_EACH(i) { if (IS_MOD_EXTENSION(mod, i, sig_offset)) { - offset = *(mod->elem_idx) - mod_rel_list[i].elem_base; + offset = mod->rt->elem_idx - mod_rel_list[i].elem_base; temp_size += (ext_mod_cnt < 32 && offset < 4 && offset > -5) ? 1 : 2; } } @@ -901,7 +901,7 @@ static void mod_publish(struct k_work *work) struct bt_mesh_elem *bt_mesh_model_elem(const struct bt_mesh_model *mod) { - return &dev_comp->elem[*(mod->elem_idx)]; + return &dev_comp->elem[mod->rt->elem_idx]; } const struct bt_mesh_model *bt_mesh_model_get(bool vnd, uint8_t elem_idx, uint8_t mod_idx) @@ -975,9 +975,9 @@ static void mod_init(const struct bt_mesh_model *mod, struct bt_mesh_elem *elem, mod->keys[i] = BT_MESH_KEY_UNUSED; } - *(mod->elem_idx) = elem - dev_comp->elem; + mod->rt->elem_idx = elem - dev_comp->elem; if (vnd) { - *(mod->mod_idx) = mod - elem->vnd_models; + mod->rt->mod_idx = mod - elem->vnd_models; if (IS_ENABLED(CONFIG_BT_MESH_MODEL_VND_MSG_CID_FORCE)) { *err = bt_mesh_vnd_mod_msg_cid_check(mod); @@ -987,7 +987,7 @@ static void mod_init(const struct bt_mesh_model *mod, struct bt_mesh_elem *elem, } } else { - *(mod->mod_idx) = mod - elem->models; + mod->rt->mod_idx = mod - elem->models; } if (mod->cb && mod->cb->init) { @@ -1107,7 +1107,7 @@ static enum bt_mesh_walk find_group_mod_visitor(const struct bt_mesh_model *mod, { struct find_group_visitor_ctx *ctx = user_data; - if (*(mod->elem_idx) != *(ctx->mod->elem_idx)) { + if (mod->rt->elem_idx != ctx->mod->rt->elem_idx) { return BT_MESH_WALK_CONTINUE; } @@ -1165,7 +1165,7 @@ static enum bt_mesh_walk find_uuid_mod_visitor(const struct bt_mesh_model *mod, { struct find_uuid_visitor_ctx *ctx = user_data; - if (*(mod->elem_idx) != *(ctx->mod->elem_idx)) { + if (mod->rt->elem_idx != ctx->mod->rt->elem_idx) { return BT_MESH_WALK_CONTINUE; } @@ -1315,11 +1315,11 @@ bool bt_mesh_model_has_key(const struct bt_mesh_model *mod, uint16_t key) static bool model_has_dst(const struct bt_mesh_model *mod, uint16_t dst, const uint8_t *uuid) { if (BT_MESH_ADDR_IS_UNICAST(dst)) { - return (dev_comp->elem[*(mod->elem_idx)].addr == dst); + return (dev_comp->elem[mod->rt->elem_idx].addr == dst); } else if (BT_MESH_ADDR_IS_VIRTUAL(dst)) { return !!bt_mesh_model_find_uuid(&mod, uuid); } else if (BT_MESH_ADDR_IS_GROUP(dst) || - (BT_MESH_ADDR_IS_FIXED_GROUP(dst) && *(mod->elem_idx) != 0)) { + (BT_MESH_ADDR_IS_FIXED_GROUP(dst) && mod->rt->elem_idx != 0)) { return !!bt_mesh_model_find_group(&mod, dst); } @@ -1327,7 +1327,7 @@ static bool model_has_dst(const struct bt_mesh_model *mod, uint16_t dst, const u * the lower layers have already confirmed that we are subscribing to * it. All models on the primary element should receive the message. */ - return *(mod->elem_idx) == 0; + return mod->rt->elem_idx == 0; } static const struct bt_mesh_model_op *find_op(struct bt_mesh_elem *elem, @@ -1607,12 +1607,12 @@ void bt_mesh_model_extensions_walk(const struct bt_mesh_model *model, #else const struct bt_mesh_model *it; - if (cb(model, user_data) == BT_MESH_WALK_STOP || !*(model->next)) { + if (cb(model, user_data) == BT_MESH_WALK_STOP || !model->rt->next) { return; } /* List is circular. Step through all models until we reach the start: */ - for (it = *(model->next); it != model; it = *(it->next)) { + for (it = model->rt->next; it != model; it = it->rt->next) { if (cb(it, user_data) == BT_MESH_WALK_STOP) { return; } @@ -1643,10 +1643,10 @@ static int mod_rel_register(const struct bt_mesh_model *base, { LOG_DBG(""); struct mod_relation extension = { - *(base->elem_idx), - *(base->mod_idx) + get_sig_offset(base), - *(ext->elem_idx), - *(ext->mod_idx) + get_sig_offset(ext), + base->rt->elem_idx, + base->rt->mod_idx + get_sig_offset(base), + ext->rt->elem_idx, + ext->rt->mod_idx + get_sig_offset(ext), type, }; int i; @@ -1670,18 +1670,18 @@ int bt_mesh_model_extend(const struct bt_mesh_model *extending_mod, { const struct bt_mesh_model *a = extending_mod; const struct bt_mesh_model *b = base_mod; - const struct bt_mesh_model *a_next = *(a->next); - const struct bt_mesh_model *b_next = *(b->next); + const struct bt_mesh_model *a_next = a->rt->next; + const struct bt_mesh_model *b_next = b->rt->next; const struct bt_mesh_model *it; - *(base_mod->flags) |= BT_MESH_MOD_EXTENDED; + base_mod->rt->flags |= BT_MESH_MOD_EXTENDED; if (a == b) { return 0; } /* Check if a's list contains b */ - for (it = a; (it != NULL) && (*(it->next) != a); it = *(it->next)) { + for (it = a; (it != NULL) && (it->rt->next != a); it = it->rt->next) { if (it == b) { goto register_extension; } @@ -1689,15 +1689,15 @@ int bt_mesh_model_extend(const struct bt_mesh_model *extending_mod, /* Merge lists */ if (a_next) { - *(b->next) = a_next; + b->rt->next = a_next; } else { - *(b->next) = a; + b->rt->next = a; } if (b_next) { - *(a->next) = b_next; + a->rt->next = b_next; } else { - *(a->next) = b; + a->rt->next = b; } register_extension: @@ -1745,7 +1745,7 @@ int bt_mesh_model_correspond(const struct bt_mesh_model *corresponding_mod, bool bt_mesh_model_is_extended(const struct bt_mesh_model *model) { - return *(model->flags) & BT_MESH_MOD_EXTENDED; + return model->rt->flags & BT_MESH_MOD_EXTENDED; } static int mod_set_bind(const struct bt_mesh_model *mod, size_t len_rd, @@ -2041,7 +2041,7 @@ BT_MESH_SETTINGS_DEFINE(comp, "cmp", comp_set); static void encode_mod_path(const struct bt_mesh_model *mod, bool vnd, const char *key, char *path, size_t path_len) { - uint16_t mod_key = (((uint16_t)*(mod->elem_idx) << 8) | *(mod->mod_idx)); + uint16_t mod_key = (((uint16_t)mod->rt->elem_idx << 8) | mod->rt->mod_idx); if (vnd) { snprintk(path, path_len, "bt/mesh/v/%x/%s", mod_key, key); @@ -2174,28 +2174,28 @@ static void store_pending_mod(const struct bt_mesh_model *mod, struct bt_mesh_elem *elem, bool vnd, bool primary, void *user_data) { - if (!*(mod->flags)) { + if (!mod->rt->flags) { return; } - if (*(mod->flags) & BT_MESH_MOD_BIND_PENDING) { - *(mod->flags) &= ~BT_MESH_MOD_BIND_PENDING; + if (mod->rt->flags & BT_MESH_MOD_BIND_PENDING) { + mod->rt->flags &= ~BT_MESH_MOD_BIND_PENDING; store_pending_mod_bind(mod, vnd); } - if (*(mod->flags) & BT_MESH_MOD_SUB_PENDING) { - *(mod->flags) &= ~BT_MESH_MOD_SUB_PENDING; + if (mod->rt->flags & BT_MESH_MOD_SUB_PENDING) { + mod->rt->flags &= ~BT_MESH_MOD_SUB_PENDING; store_pending_mod_sub(mod, vnd); store_pending_mod_sub_va(mod, vnd); } - if (*(mod->flags) & BT_MESH_MOD_PUB_PENDING) { - *(mod->flags) &= ~BT_MESH_MOD_PUB_PENDING; + if (mod->rt->flags & BT_MESH_MOD_PUB_PENDING) { + mod->rt->flags &= ~BT_MESH_MOD_PUB_PENDING; store_pending_mod_pub(mod, vnd); } - if (*(mod->flags) & BT_MESH_MOD_DATA_PENDING) { - *(mod->flags) &= ~BT_MESH_MOD_DATA_PENDING; + if (mod->rt->flags & BT_MESH_MOD_DATA_PENDING) { + mod->rt->flags &= ~BT_MESH_MOD_DATA_PENDING; mod->cb->pending_store(mod); } } @@ -2207,19 +2207,19 @@ void bt_mesh_model_pending_store(void) void bt_mesh_model_bind_store(const struct bt_mesh_model *mod) { - *(mod->flags) |= BT_MESH_MOD_BIND_PENDING; + mod->rt->flags |= BT_MESH_MOD_BIND_PENDING; bt_mesh_settings_store_schedule(BT_MESH_SETTINGS_MOD_PENDING); } void bt_mesh_model_sub_store(const struct bt_mesh_model *mod) { - *(mod->flags) |= BT_MESH_MOD_SUB_PENDING; + mod->rt->flags |= BT_MESH_MOD_SUB_PENDING; bt_mesh_settings_store_schedule(BT_MESH_SETTINGS_MOD_PENDING); } void bt_mesh_model_pub_store(const struct bt_mesh_model *mod) { - *(mod->flags) |= BT_MESH_MOD_PUB_PENDING; + mod->rt->flags |= BT_MESH_MOD_PUB_PENDING; bt_mesh_settings_store_schedule(BT_MESH_SETTINGS_MOD_PENDING); } @@ -2584,7 +2584,7 @@ void bt_mesh_model_settings_commit(void) void bt_mesh_model_data_store_schedule(const struct bt_mesh_model *mod) { - *(mod->flags) |= BT_MESH_MOD_DATA_PENDING; + mod->rt->flags |= BT_MESH_MOD_DATA_PENDING; bt_mesh_settings_store_schedule(BT_MESH_SETTINGS_MOD_PENDING); } diff --git a/subsys/bluetooth/mesh/blob_cli.c b/subsys/bluetooth/mesh/blob_cli.c index 4fd0fe7bac9..f96a9af0653 100644 --- a/subsys/bluetooth/mesh/blob_cli.c +++ b/subsys/bluetooth/mesh/blob_cli.c @@ -1207,7 +1207,7 @@ static void rx_block_status(struct bt_mesh_blob_cli *cli, static int handle_xfer_status(const struct bt_mesh_model *mod, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf) { - struct bt_mesh_blob_cli *cli = *(mod->user_data); + struct bt_mesh_blob_cli *cli = mod->rt->user_data; enum bt_mesh_blob_xfer_phase expected_phase; struct bt_mesh_blob_target *target; struct bt_mesh_blob_xfer_info info = { 0 }; @@ -1279,7 +1279,7 @@ static int handle_xfer_status(const struct bt_mesh_model *mod, struct bt_mesh_ms static int handle_block_report(const struct bt_mesh_model *mod, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf) { - struct bt_mesh_blob_cli *cli = *(mod->user_data); + struct bt_mesh_blob_cli *cli = mod->rt->user_data; struct block_status status = { .status = BT_MESH_BLOB_SUCCESS, .block.number = cli->block.number, @@ -1333,7 +1333,7 @@ static int handle_block_report(const struct bt_mesh_model *mod, struct bt_mesh_m static int handle_block_status(const struct bt_mesh_model *mod, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf) { - struct bt_mesh_blob_cli *cli = *(mod->user_data); + struct bt_mesh_blob_cli *cli = mod->rt->user_data; struct bt_mesh_blob_target *target; struct block_status status = { 0 }; uint8_t status_and_format; @@ -1404,7 +1404,7 @@ static int handle_block_status(const struct bt_mesh_model *mod, struct bt_mesh_m static int handle_info_status(const struct bt_mesh_model *mod, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf) { - struct bt_mesh_blob_cli *cli = *(mod->user_data); + struct bt_mesh_blob_cli *cli = mod->rt->user_data; struct bt_mesh_blob_cli_caps caps; enum bt_mesh_blob_status status; struct bt_mesh_blob_target *target; @@ -1460,7 +1460,7 @@ const struct bt_mesh_model_op _bt_mesh_blob_cli_op[] = { static int blob_cli_init(const struct bt_mesh_model *mod) { - struct bt_mesh_blob_cli *cli = *(mod->user_data); + struct bt_mesh_blob_cli *cli = mod->rt->user_data; cli->mod = mod; @@ -1473,7 +1473,7 @@ static int blob_cli_init(const struct bt_mesh_model *mod) static void blob_cli_reset(const struct bt_mesh_model *mod) { - struct bt_mesh_blob_cli *cli = *(mod->user_data); + struct bt_mesh_blob_cli *cli = mod->rt->user_data; cli_state_reset(cli); } diff --git a/subsys/bluetooth/mesh/blob_srv.c b/subsys/bluetooth/mesh/blob_srv.c index 2fee121415d..3773a17e9af 100644 --- a/subsys/bluetooth/mesh/blob_srv.c +++ b/subsys/bluetooth/mesh/blob_srv.c @@ -418,7 +418,7 @@ static void block_status_rsp(struct bt_mesh_blob_srv *srv, static int handle_xfer_get(const struct bt_mesh_model *mod, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf) { - struct bt_mesh_blob_srv *srv = *(mod->user_data); + struct bt_mesh_blob_srv *srv = mod->rt->user_data; LOG_DBG(""); @@ -438,7 +438,7 @@ static int handle_xfer_get(const struct bt_mesh_model *mod, struct bt_mesh_msg_c static int handle_xfer_start(const struct bt_mesh_model *mod, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf) { - struct bt_mesh_blob_srv *srv = *(mod->user_data); + struct bt_mesh_blob_srv *srv = mod->rt->user_data; enum bt_mesh_blob_status status; enum bt_mesh_blob_xfer_mode mode; uint64_t id; @@ -570,7 +570,7 @@ static int handle_xfer_cancel(const struct bt_mesh_model *mod, struct bt_mesh_ms struct net_buf_simple *buf) { enum bt_mesh_blob_status status = BT_MESH_BLOB_SUCCESS; - struct bt_mesh_blob_srv *srv = *(mod->user_data); + struct bt_mesh_blob_srv *srv = mod->rt->user_data; uint64_t id; id = net_buf_simple_pull_le64(buf); @@ -598,7 +598,7 @@ static int handle_block_get(const struct bt_mesh_model *mod, struct bt_mesh_msg_ struct net_buf_simple *buf) { enum bt_mesh_blob_status status; - struct bt_mesh_blob_srv *srv = *(mod->user_data); + struct bt_mesh_blob_srv *srv = mod->rt->user_data; switch (srv->phase) { case BT_MESH_BLOB_XFER_PHASE_WAITING_FOR_BLOCK: @@ -628,7 +628,7 @@ static int handle_block_get(const struct bt_mesh_model *mod, struct bt_mesh_msg_ static int handle_block_start(const struct bt_mesh_model *mod, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf) { - struct bt_mesh_blob_srv *srv = *(mod->user_data); + struct bt_mesh_blob_srv *srv = mod->rt->user_data; enum bt_mesh_blob_status status; uint16_t block_number, chunk_size; int err; @@ -723,7 +723,7 @@ rsp: static int handle_chunk(const struct bt_mesh_model *mod, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf) { - struct bt_mesh_blob_srv *srv = *(mod->user_data); + struct bt_mesh_blob_srv *srv = mod->rt->user_data; struct bt_mesh_blob_chunk chunk; size_t expected_size = 0; uint16_t idx; @@ -813,7 +813,7 @@ static int handle_chunk(const struct bt_mesh_model *mod, struct bt_mesh_msg_ctx static int handle_info_get(const struct bt_mesh_model *mod, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf) { - struct bt_mesh_blob_srv *srv = *(mod->user_data); + struct bt_mesh_blob_srv *srv = mod->rt->user_data; LOG_DBG(""); @@ -849,7 +849,7 @@ const struct bt_mesh_model_op _bt_mesh_blob_srv_op[] = { static int blob_srv_init(const struct bt_mesh_model *mod) { - struct bt_mesh_blob_srv *srv = *(mod->user_data); + struct bt_mesh_blob_srv *srv = mod->rt->user_data; srv->mod = mod; srv->state.ttl = BT_MESH_TTL_DEFAULT; @@ -865,7 +865,7 @@ static int blob_srv_settings_set(const struct bt_mesh_model *mod, const char *na size_t len_rd, settings_read_cb read_cb, void *cb_arg) { - struct bt_mesh_blob_srv *srv = *(mod->user_data); + struct bt_mesh_blob_srv *srv = mod->rt->user_data; ssize_t len; if (len_rd < offsetof(struct bt_mesh_blob_srv_state, blocks)) { @@ -905,7 +905,7 @@ static int blob_srv_settings_set(const struct bt_mesh_model *mod, const char *na static int blob_srv_start(const struct bt_mesh_model *mod) { - struct bt_mesh_blob_srv *srv = *(mod->user_data); + struct bt_mesh_blob_srv *srv = mod->rt->user_data; int err = -ENOTSUP; if (srv->phase == BT_MESH_BLOB_XFER_PHASE_INACTIVE) { @@ -933,7 +933,7 @@ static int blob_srv_start(const struct bt_mesh_model *mod) static void blob_srv_reset(const struct bt_mesh_model *mod) { - struct bt_mesh_blob_srv *srv = *(mod->user_data); + struct bt_mesh_blob_srv *srv = mod->rt->user_data; phase_set(srv, BT_MESH_BLOB_XFER_PHASE_INACTIVE); srv->state.xfer.mode = BT_MESH_BLOB_XFER_MODE_NONE; diff --git a/subsys/bluetooth/mesh/cfg_cli.c b/subsys/bluetooth/mesh/cfg_cli.c index 2f05fea2f15..aa762e9b906 100644 --- a/subsys/bluetooth/mesh/cfg_cli.c +++ b/subsys/bluetooth/mesh/cfg_cli.c @@ -1094,12 +1094,12 @@ static int cfg_cli_init(const struct bt_mesh_model *model) return -EINVAL; } - if (!*(model->user_data)) { + if (!model->rt->user_data) { LOG_ERR("No Configuration Client context provided"); return -EINVAL; } - cli = *(model->user_data); + cli = model->rt->user_data; cli->model = model; msg_timeout = CONFIG_BT_MESH_CFG_CLI_TIMEOUT; @@ -1108,7 +1108,7 @@ static int cfg_cli_init(const struct bt_mesh_model *model) * and remote keys are allowed to access this model. */ model->keys[0] = BT_MESH_KEY_DEV_ANY; - *(model->flags) |= BT_MESH_MOD_DEVKEY_ONLY; + model->rt->flags |= BT_MESH_MOD_DEVKEY_ONLY; bt_mesh_msg_ack_ctx_init(&cli->ack_ctx); diff --git a/subsys/bluetooth/mesh/cfg_srv.c b/subsys/bluetooth/mesh/cfg_srv.c index 5920ecd6dc1..04374977421 100644 --- a/subsys/bluetooth/mesh/cfg_srv.c +++ b/subsys/bluetooth/mesh/cfg_srv.c @@ -1238,7 +1238,7 @@ static enum bt_mesh_walk mod_sub_list_visitor(const struct bt_mesh_model *mod, v int count = 0; int i; - if (*(mod->elem_idx) != visit->elem_idx) { + if (mod->rt->elem_idx != visit->elem_idx) { return BT_MESH_WALK_CONTINUE; } @@ -1257,7 +1257,7 @@ static enum bt_mesh_walk mod_sub_list_visitor(const struct bt_mesh_model *mod, v count++; } - LOG_DBG("sublist: model %u:%x: %u groups", *(mod->elem_idx), mod->id, count); + LOG_DBG("sublist: model %u:%x: %u groups", mod->rt->elem_idx, mod->id, count); return BT_MESH_WALK_CONTINUE; } @@ -1306,7 +1306,7 @@ static int mod_sub_get(const struct bt_mesh_model *model, net_buf_simple_add_le16(&msg, id); visit_ctx.msg = &msg; - visit_ctx.elem_idx = *(mod->elem_idx); + visit_ctx.elem_idx = mod->rt->elem_idx; bt_mesh_model_extensions_walk(mod, mod_sub_list_visitor, &visit_ctx); send_list: @@ -1365,7 +1365,7 @@ static int mod_sub_get_vnd(const struct bt_mesh_model *model, net_buf_simple_add_le16(&msg, id); visit_ctx.msg = &msg; - visit_ctx.elem_idx = *(mod->elem_idx); + visit_ctx.elem_idx = mod->rt->elem_idx; bt_mesh_model_extensions_walk(mod, mod_sub_list_visitor, &visit_ctx); send_list: @@ -1881,7 +1881,7 @@ static int mod_app_bind(const struct bt_mesh_model *model, } /* Some models only allow device key based access */ - if (*(mod->flags) & BT_MESH_MOD_DEVKEY_ONLY) { + if (mod->rt->flags & BT_MESH_MOD_DEVKEY_ONLY) { LOG_ERR("Client tried to bind AppKey to DevKey based model"); status = STATUS_CANNOT_BIND; goto send_status; @@ -2520,7 +2520,7 @@ static int cfg_srv_init(const struct bt_mesh_model *model) * device-key is allowed to access this model. */ model->keys[0] = BT_MESH_KEY_DEV_LOCAL; - *(model->flags) |= BT_MESH_MOD_DEVKEY_ONLY; + model->rt->flags |= BT_MESH_MOD_DEVKEY_ONLY; return 0; } diff --git a/subsys/bluetooth/mesh/dfd_srv.c b/subsys/bluetooth/mesh/dfd_srv.c index 245052b58f8..54184acd9b8 100644 --- a/subsys/bluetooth/mesh/dfd_srv.c +++ b/subsys/bluetooth/mesh/dfd_srv.c @@ -116,7 +116,7 @@ static int handle_receivers_add(const struct bt_mesh_model *mod, struct bt_mesh_ struct net_buf_simple *buf) { enum bt_mesh_dfd_status status = BT_MESH_DFD_SUCCESS; - struct bt_mesh_dfd_srv *srv = *(mod->user_data); + struct bt_mesh_dfd_srv *srv = mod->rt->user_data; if (buf->len % 3) { return -EINVAL; @@ -146,7 +146,7 @@ static int handle_receivers_add(const struct bt_mesh_model *mod, struct bt_mesh_ static int handle_receivers_delete_all(const struct bt_mesh_model *mod, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf) { - struct bt_mesh_dfd_srv *srv = *(mod->user_data); + struct bt_mesh_dfd_srv *srv = mod->rt->user_data; receivers_status_rsp(srv, ctx, bt_mesh_dfd_srv_receivers_delete_all(srv)); @@ -156,7 +156,7 @@ static int handle_receivers_delete_all(const struct bt_mesh_model *mod, struct b static int handle_receivers_get(const struct bt_mesh_model *mod, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf) { - struct bt_mesh_dfd_srv *srv = *(mod->user_data); + struct bt_mesh_dfd_srv *srv = mod->rt->user_data; uint16_t first, cnt; uint8_t progress; int i; @@ -226,7 +226,7 @@ static int handle_capabilities_get(const struct bt_mesh_model *mod, struct bt_me net_buf_simple_add_le32(&rsp, CONFIG_BT_MESH_DFD_SRV_SLOT_SPACE - size); #ifdef CONFIG_BT_MESH_DFD_SRV_OOB_UPLOAD - struct bt_mesh_dfd_srv *srv = *(mod->user_data); + struct bt_mesh_dfd_srv *srv = mod->rt->user_data; if (srv->oob_schemes.count > 0) { net_buf_simple_add_u8(&rsp, 1); @@ -271,7 +271,7 @@ static void status_rsp(struct bt_mesh_dfd_srv *srv, struct bt_mesh_msg_ctx *ctx, static int handle_get(const struct bt_mesh_model *mod, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf) { - struct bt_mesh_dfd_srv *srv = *(mod->user_data); + struct bt_mesh_dfd_srv *srv = mod->rt->user_data; status_rsp(srv, ctx, BT_MESH_DFD_SUCCESS); @@ -281,7 +281,7 @@ static int handle_get(const struct bt_mesh_model *mod, struct bt_mesh_msg_ctx *c static int handle_start(const struct bt_mesh_model *mod, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf) { - struct bt_mesh_dfd_srv *srv = *(mod->user_data); + struct bt_mesh_dfd_srv *srv = mod->rt->user_data; struct bt_mesh_dfd_start_params params; uint8_t byte; @@ -314,7 +314,7 @@ static int handle_suspend(const struct bt_mesh_model *mod, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf) { - struct bt_mesh_dfd_srv *srv = *(mod->user_data); + struct bt_mesh_dfd_srv *srv = mod->rt->user_data; status_rsp(srv, ctx, bt_mesh_dfd_srv_suspend(srv)); @@ -324,7 +324,7 @@ static int handle_suspend(const struct bt_mesh_model *mod, static int handle_cancel(const struct bt_mesh_model *mod, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf) { - struct bt_mesh_dfd_srv *srv = *(mod->user_data); + struct bt_mesh_dfd_srv *srv = mod->rt->user_data; bt_mesh_dfd_srv_cancel(srv, ctx); @@ -334,7 +334,7 @@ static int handle_cancel(const struct bt_mesh_model *mod, struct bt_mesh_msg_ctx static int handle_apply(const struct bt_mesh_model *mod, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf) { - struct bt_mesh_dfd_srv *srv = *(mod->user_data); + struct bt_mesh_dfd_srv *srv = mod->rt->user_data; status_rsp(srv, ctx, bt_mesh_dfd_srv_apply(srv)); @@ -396,7 +396,7 @@ static void upload_status_rsp(struct bt_mesh_dfd_srv *srv, static int handle_upload_get(const struct bt_mesh_model *mod, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf) { - struct bt_mesh_dfd_srv *srv = *(mod->user_data); + struct bt_mesh_dfd_srv *srv = mod->rt->user_data; upload_status_rsp(srv, ctx, BT_MESH_DFD_SUCCESS); @@ -441,7 +441,7 @@ static inline int set_upload_fwid(struct bt_mesh_dfd_srv *srv, struct bt_mesh_ms static int handle_upload_start(const struct bt_mesh_model *mod, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf) { - struct bt_mesh_dfd_srv *srv = *(mod->user_data); + struct bt_mesh_dfd_srv *srv = mod->rt->user_data; size_t meta_len, fwid_len, size; const uint8_t *meta, *fwid; uint16_t timeout_base; @@ -563,7 +563,7 @@ static int handle_upload_start(const struct bt_mesh_model *mod, struct bt_mesh_m static int handle_upload_start_oob(const struct bt_mesh_model *mod, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf) { - struct bt_mesh_dfd_srv *srv = *(mod->user_data); + struct bt_mesh_dfd_srv *srv = mod->rt->user_data; uint8_t uri_len; uint8_t *uri; uint16_t fwid_len; @@ -654,7 +654,7 @@ static int handle_upload_start_oob(const struct bt_mesh_model *mod, struct bt_me static int handle_upload_cancel(const struct bt_mesh_model *mod, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf) { - struct bt_mesh_dfd_srv *srv = *(mod->user_data); + struct bt_mesh_dfd_srv *srv = mod->rt->user_data; srv->upload.phase = BT_MESH_DFD_UPLOAD_PHASE_IDLE; #ifdef CONFIG_BT_MESH_DFD_SRV_OOB_UPLOAD @@ -693,7 +693,7 @@ static void fw_status_rsp(struct bt_mesh_dfd_srv *srv, static int handle_fw_get(const struct bt_mesh_model *mod, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf) { - struct bt_mesh_dfd_srv *srv = *(mod->user_data); + struct bt_mesh_dfd_srv *srv = mod->rt->user_data; struct bt_mesh_dfu_slot *slot; const uint8_t *fwid; size_t fwid_len; @@ -717,7 +717,7 @@ static int handle_fw_get(const struct bt_mesh_model *mod, struct bt_mesh_msg_ctx static int handle_fw_get_by_index(const struct bt_mesh_model *mod, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf) { - struct bt_mesh_dfd_srv *srv = *(mod->user_data); + struct bt_mesh_dfd_srv *srv = mod->rt->user_data; const struct bt_mesh_dfu_slot *slot; uint16_t idx; @@ -738,7 +738,7 @@ static int handle_fw_get_by_index(const struct bt_mesh_model *mod, struct bt_mes static int handle_fw_delete(const struct bt_mesh_model *mod, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf) { - struct bt_mesh_dfd_srv *srv = *(mod->user_data); + struct bt_mesh_dfd_srv *srv = mod->rt->user_data; const uint8_t *fwid; size_t fwid_len; @@ -767,7 +767,7 @@ static enum bt_mesh_dfu_iter slot_del_cb(const struct bt_mesh_dfu_slot *slot, static int handle_fw_delete_all(const struct bt_mesh_model *mod, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf) { - struct bt_mesh_dfd_srv *srv = *(mod->user_data); + struct bt_mesh_dfd_srv *srv = mod->rt->user_data; fw_status_rsp(srv, ctx, bt_mesh_dfd_srv_fw_delete_all(srv), 0xffff, NULL, 0); @@ -925,7 +925,7 @@ const struct bt_mesh_blob_srv_cb _bt_mesh_dfd_srv_blob_cb = { static int dfd_srv_init(const struct bt_mesh_model *mod) { - struct bt_mesh_dfd_srv *srv = *(mod->user_data); + struct bt_mesh_dfd_srv *srv = mod->rt->user_data; srv->mod = mod; @@ -938,7 +938,7 @@ static int dfd_srv_init(const struct bt_mesh_model *mod) static void dfd_srv_reset(const struct bt_mesh_model *mod) { - struct bt_mesh_dfd_srv *srv = *(mod->user_data); + struct bt_mesh_dfd_srv *srv = mod->rt->user_data; dfd_phase_set(srv, BT_MESH_DFD_PHASE_IDLE); srv->upload.phase = BT_MESH_DFD_UPLOAD_PHASE_IDLE; diff --git a/subsys/bluetooth/mesh/dfu_cli.c b/subsys/bluetooth/mesh/dfu_cli.c index 70b03f4e814..2345ef8e33b 100644 --- a/subsys/bluetooth/mesh/dfu_cli.c +++ b/subsys/bluetooth/mesh/dfu_cli.c @@ -702,7 +702,7 @@ static void cancelled(struct bt_mesh_blob_cli *b) static int handle_status(const struct bt_mesh_model *mod, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf) { - struct bt_mesh_dfu_cli *cli = *(mod->user_data); + struct bt_mesh_dfu_cli *cli = mod->rt->user_data; enum bt_mesh_dfu_status status; enum bt_mesh_dfu_phase phase; struct bt_mesh_dfu_target *target; @@ -828,7 +828,7 @@ static int handle_status(const struct bt_mesh_model *mod, struct bt_mesh_msg_ctx static int handle_info_status(const struct bt_mesh_model *mod, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf) { - struct bt_mesh_dfu_cli *cli = *(mod->user_data); + struct bt_mesh_dfu_cli *cli = mod->rt->user_data; struct bt_mesh_dfu_target *target; enum bt_mesh_dfu_iter it = BT_MESH_DFU_ITER_CONTINUE; uint8_t img_cnt, idx; @@ -927,7 +927,7 @@ static int handle_info_status(const struct bt_mesh_model *mod, struct bt_mesh_ms static int handle_metadata_status(const struct bt_mesh_model *mod, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf) { - struct bt_mesh_dfu_cli *cli = *(mod->user_data); + struct bt_mesh_dfu_cli *cli = mod->rt->user_data; struct bt_mesh_dfu_metadata_status *rsp = cli->req.params; uint8_t hdr, idx; @@ -963,9 +963,9 @@ const struct bt_mesh_model_op _bt_mesh_dfu_cli_op[] = { static int dfu_cli_init(const struct bt_mesh_model *mod) { - struct bt_mesh_dfu_cli *cli = *(mod->user_data); + struct bt_mesh_dfu_cli *cli = mod->rt->user_data; - if (*(mod->elem_idx) != 0) { + if (mod->rt->elem_idx != 0) { LOG_ERR("DFU update client must be instantiated on first elem"); return -EINVAL; } @@ -983,7 +983,7 @@ static int dfu_cli_init(const struct bt_mesh_model *mod) static void dfu_cli_reset(const struct bt_mesh_model *mod) { - struct bt_mesh_dfu_cli *cli = *(mod->user_data); + struct bt_mesh_dfu_cli *cli = mod->rt->user_data; cli->req.type = REQ_NONE; cli->req.addr = BT_MESH_ADDR_UNASSIGNED; diff --git a/subsys/bluetooth/mesh/dfu_srv.c b/subsys/bluetooth/mesh/dfu_srv.c index edd61e6da40..f8e87e29da9 100644 --- a/subsys/bluetooth/mesh/dfu_srv.c +++ b/subsys/bluetooth/mesh/dfu_srv.c @@ -128,7 +128,7 @@ static void verify(struct bt_mesh_dfu_srv *srv) static int handle_info_get(const struct bt_mesh_model *mod, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf) { - struct bt_mesh_dfu_srv *srv = *(mod->user_data); + struct bt_mesh_dfu_srv *srv = mod->rt->user_data; uint8_t idx, limit; if (srv->update.phase == BT_MESH_DFU_PHASE_APPLYING) { @@ -190,7 +190,7 @@ static int handle_info_get(const struct bt_mesh_model *mod, struct bt_mesh_msg_c static int handle_metadata_check(const struct bt_mesh_model *mod, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf) { - struct bt_mesh_dfu_srv *srv = *(mod->user_data); + struct bt_mesh_dfu_srv *srv = mod->rt->user_data; enum bt_mesh_dfu_status status; enum bt_mesh_dfu_effect effect; uint8_t idx; @@ -242,7 +242,7 @@ static void update_status_rsp(struct bt_mesh_dfu_srv *srv, static int handle_get(const struct bt_mesh_model *mod, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf) { - struct bt_mesh_dfu_srv *srv = *(mod->user_data); + struct bt_mesh_dfu_srv *srv = mod->rt->user_data; LOG_DBG(""); @@ -265,7 +265,7 @@ static inline bool is_active_update(struct bt_mesh_dfu_srv *srv, uint8_t idx, static int handle_start(const struct bt_mesh_model *mod, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf) { - struct bt_mesh_dfu_srv *srv = *(mod->user_data); + struct bt_mesh_dfu_srv *srv = mod->rt->user_data; const struct bt_mesh_blob_io *io; uint16_t timeout_base, meta_checksum; enum bt_mesh_dfu_status status; @@ -374,7 +374,7 @@ rsp: static int handle_cancel(const struct bt_mesh_model *mod, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf) { - struct bt_mesh_dfu_srv *srv = *(mod->user_data); + struct bt_mesh_dfu_srv *srv = mod->rt->user_data; if (srv->update.idx == UPDATE_IDX_NONE) { goto rsp; @@ -395,7 +395,7 @@ rsp: static int handle_apply(const struct bt_mesh_model *mod, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf) { - struct bt_mesh_dfu_srv *srv = *(mod->user_data); + struct bt_mesh_dfu_srv *srv = mod->rt->user_data; static const struct bt_mesh_send_cb send_cb = { .start = apply_rsp_sending, .end = apply_rsp_sent, @@ -437,7 +437,7 @@ const struct bt_mesh_model_op _bt_mesh_dfu_srv_op[] = { static int dfu_srv_init(const struct bt_mesh_model *mod) { - struct bt_mesh_dfu_srv *srv = *(mod->user_data); + struct bt_mesh_dfu_srv *srv = mod->rt->user_data; srv->mod = mod; srv->update.idx = UPDATE_IDX_NONE; @@ -459,7 +459,7 @@ static int dfu_srv_settings_set(const struct bt_mesh_model *mod, const char *nam size_t len_rd, settings_read_cb read_cb, void *cb_arg) { - struct bt_mesh_dfu_srv *srv = *(mod->user_data); + struct bt_mesh_dfu_srv *srv = mod->rt->user_data; ssize_t len; if (len_rd < sizeof(srv->update)) { @@ -486,7 +486,7 @@ static int dfu_srv_settings_set(const struct bt_mesh_model *mod, const char *nam static void dfu_srv_reset(const struct bt_mesh_model *mod) { - struct bt_mesh_dfu_srv *srv = *(mod->user_data); + struct bt_mesh_dfu_srv *srv = mod->rt->user_data; srv->update.phase = BT_MESH_DFU_PHASE_IDLE; erase_state(srv); diff --git a/subsys/bluetooth/mesh/health_cli.c b/subsys/bluetooth/mesh/health_cli.c index d34d869e243..16d2a79a53a 100644 --- a/subsys/bluetooth/mesh/health_cli.c +++ b/subsys/bluetooth/mesh/health_cli.c @@ -40,7 +40,7 @@ static int health_fault_status(const struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf) { - struct bt_mesh_health_cli *cli = *(model->user_data); + struct bt_mesh_health_cli *cli = model->rt->user_data; struct health_fault_param *param; uint8_t test_id; uint16_t cid; @@ -93,7 +93,7 @@ static int health_current_status(const struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf) { - struct bt_mesh_health_cli *cli = *(model->user_data); + struct bt_mesh_health_cli *cli = model->rt->user_data; uint8_t test_id; uint16_t cid; @@ -121,7 +121,7 @@ static int health_period_status(const struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf) { - struct bt_mesh_health_cli *cli = *(model->user_data); + struct bt_mesh_health_cli *cli = model->rt->user_data; struct health_period_param *param; uint8_t divisor; @@ -155,7 +155,7 @@ static int health_attention_status(const struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf) { - struct bt_mesh_health_cli *cli = *(model->user_data); + struct bt_mesh_health_cli *cli = model->rt->user_data; struct health_attention_param *param; uint8_t attention; @@ -404,7 +404,7 @@ void bt_mesh_health_cli_timeout_set(int32_t timeout) static int health_cli_init(const struct bt_mesh_model *model) { - struct bt_mesh_health_cli *cli = *(model->user_data); + struct bt_mesh_health_cli *cli = model->rt->user_data; LOG_DBG("primary %u", bt_mesh_model_in_primary(model)); @@ -425,7 +425,7 @@ static int health_cli_init(const struct bt_mesh_model *model) static void health_cli_reset(const struct bt_mesh_model *model) { - struct bt_mesh_health_cli *cli = *(model->user_data); + struct bt_mesh_health_cli *cli = model->rt->user_data; net_buf_simple_reset(cli->pub.msg); } diff --git a/subsys/bluetooth/mesh/health_srv.c b/subsys/bluetooth/mesh/health_srv.c index 4ae55266ebf..5292967d469 100644 --- a/subsys/bluetooth/mesh/health_srv.c +++ b/subsys/bluetooth/mesh/health_srv.c @@ -35,7 +35,7 @@ static void health_get_registered(const struct bt_mesh_model *mod, uint16_t company_id, struct net_buf_simple *msg) { - struct bt_mesh_health_srv *srv = *(mod->user_data); + struct bt_mesh_health_srv *srv = mod->rt->user_data; uint8_t *test_id; LOG_DBG("Company ID 0x%04x", company_id); @@ -67,7 +67,7 @@ static void health_get_registered(const struct bt_mesh_model *mod, static size_t health_get_current(const struct bt_mesh_model *mod, struct net_buf_simple *msg) { - struct bt_mesh_health_srv *srv = *(mod->user_data); + struct bt_mesh_health_srv *srv = mod->rt->user_data; const struct bt_mesh_comp *comp; uint8_t *test_id, *company_ptr; uint16_t company_id; @@ -129,7 +129,7 @@ static int health_fault_clear_unrel(const struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf) { - struct bt_mesh_health_srv *srv = *(model->user_data); + struct bt_mesh_health_srv *srv = model->rt->user_data; uint16_t company_id; company_id = net_buf_simple_pull_le16(buf); @@ -148,7 +148,7 @@ static int health_fault_clear(const struct bt_mesh_model *model, struct net_buf_simple *buf) { NET_BUF_SIMPLE_DEFINE(sdu, BT_MESH_TX_SDU_MAX); - struct bt_mesh_health_srv *srv = *(model->user_data); + struct bt_mesh_health_srv *srv = model->rt->user_data; uint16_t company_id; company_id = net_buf_simple_pull_le16(buf); @@ -177,7 +177,7 @@ static int health_fault_test_unrel(const struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf) { - struct bt_mesh_health_srv *srv = *(model->user_data); + struct bt_mesh_health_srv *srv = model->rt->user_data; uint16_t company_id; uint8_t test_id; @@ -198,7 +198,7 @@ static int health_fault_test(const struct bt_mesh_model *model, struct net_buf_simple *buf) { NET_BUF_SIMPLE_DEFINE(sdu, BT_MESH_TX_SDU_MAX); - struct bt_mesh_health_srv *srv = *(model->user_data); + struct bt_mesh_health_srv *srv = model->rt->user_data; uint16_t company_id; uint8_t test_id; @@ -233,7 +233,7 @@ static int send_attention_status(const struct bt_mesh_model *model, { /* Needed size: opcode (2 bytes) + msg + MIC */ BT_MESH_MODEL_BUF_DEFINE(msg, OP_ATTENTION_STATUS, 1); - struct bt_mesh_health_srv *srv = *(model->user_data); + struct bt_mesh_health_srv *srv = model->rt->user_data; uint8_t time; time = k_ticks_to_ms_floor32( @@ -420,7 +420,7 @@ static void attention_off(struct k_work *work) static int health_srv_init(const struct bt_mesh_model *model) { - struct bt_mesh_health_srv *srv = *(model->user_data); + struct bt_mesh_health_srv *srv = model->rt->user_data; if (!srv) { LOG_ERR("No Health Server context provided"); @@ -462,7 +462,7 @@ void bt_mesh_attention(const struct bt_mesh_model *model, uint8_t time) model = srv->model; } else { - srv = *(model->user_data); + srv = model->rt->user_data; } if ((time > 0) && srv->cb && srv->cb->attn_on) { diff --git a/subsys/bluetooth/mesh/large_comp_data_cli.c b/subsys/bluetooth/mesh/large_comp_data_cli.c index dc1152f415f..3aa688523f9 100644 --- a/subsys/bluetooth/mesh/large_comp_data_cli.c +++ b/subsys/bluetooth/mesh/large_comp_data_cli.c @@ -108,9 +108,9 @@ static int large_comp_data_cli_init(const struct bt_mesh_model *model) } model->keys[0] = BT_MESH_KEY_DEV_ANY; - *(model->flags) |= BT_MESH_MOD_DEVKEY_ONLY; + model->rt->flags |= BT_MESH_MOD_DEVKEY_ONLY; - cli = *(model->user_data); + cli = model->rt->user_data; cli->model = model; msg_timeout = 5000; diff --git a/subsys/bluetooth/mesh/large_comp_data_srv.c b/subsys/bluetooth/mesh/large_comp_data_srv.c index 5d724b9f083..f47947b9b92 100644 --- a/subsys/bluetooth/mesh/large_comp_data_srv.c +++ b/subsys/bluetooth/mesh/large_comp_data_srv.c @@ -177,7 +177,7 @@ static int large_comp_data_srv_init(const struct bt_mesh_model *model) /* Large Composition Data Server model shall use the device key */ model->keys[0] = BT_MESH_KEY_DEV; - *(model->flags) |= BT_MESH_MOD_DEVKEY_ONLY; + model->rt->flags |= BT_MESH_MOD_DEVKEY_ONLY; srv.model = model; diff --git a/subsys/bluetooth/mesh/od_priv_proxy_cli.c b/subsys/bluetooth/mesh/od_priv_proxy_cli.c index f2844d2ecc6..bd4e796b8e2 100644 --- a/subsys/bluetooth/mesh/od_priv_proxy_cli.c +++ b/subsys/bluetooth/mesh/od_priv_proxy_cli.c @@ -100,10 +100,10 @@ static int on_demand_proxy_cli_init(const struct bt_mesh_model *mod) return -EINVAL; } - cli = *(mod->user_data); + cli = mod->rt->user_data; cli->model = mod; mod->keys[0] = BT_MESH_KEY_DEV_ANY; - *(mod->flags) |= BT_MESH_MOD_DEVKEY_ONLY; + mod->rt->flags |= BT_MESH_MOD_DEVKEY_ONLY; msg_timeout = CONFIG_BT_MESH_OD_PRIV_PROXY_CLI_TIMEOUT; bt_mesh_msg_ack_ctx_init(&cli->ack_ctx); diff --git a/subsys/bluetooth/mesh/od_priv_proxy_srv.c b/subsys/bluetooth/mesh/od_priv_proxy_srv.c index e671a80e9de..e54ed88fa0c 100644 --- a/subsys/bluetooth/mesh/od_priv_proxy_srv.c +++ b/subsys/bluetooth/mesh/od_priv_proxy_srv.c @@ -98,7 +98,7 @@ static int od_priv_proxy_srv_init(const struct bt_mesh_model *mod) } mod->keys[0] = BT_MESH_KEY_DEV_LOCAL; - *(mod->flags) |= BT_MESH_MOD_DEVKEY_ONLY; + mod->rt->flags |= BT_MESH_MOD_DEVKEY_ONLY; if (IS_ENABLED(CONFIG_BT_MESH_MODEL_EXTENSIONS)) { bt_mesh_model_extend(mod, priv_beacon_srv); diff --git a/subsys/bluetooth/mesh/priv_beacon_cli.c b/subsys/bluetooth/mesh/priv_beacon_cli.c index fd48ef0583b..0611aeb7705 100644 --- a/subsys/bluetooth/mesh/priv_beacon_cli.c +++ b/subsys/bluetooth/mesh/priv_beacon_cli.c @@ -141,11 +141,11 @@ static int priv_beacon_cli_init(const struct bt_mesh_model *model) return -EINVAL; } - cli = *(model->user_data); + cli = model->rt->user_data; cli->model = model; msg_timeout = 2 * MSEC_PER_SEC; model->keys[0] = BT_MESH_KEY_DEV_ANY; - *(model->flags) |= BT_MESH_MOD_DEVKEY_ONLY; + model->rt->flags |= BT_MESH_MOD_DEVKEY_ONLY; bt_mesh_msg_ack_ctx_init(&cli->ack_ctx); diff --git a/subsys/bluetooth/mesh/rpr_cli.c b/subsys/bluetooth/mesh/rpr_cli.c index 7a1dd493b87..cbb92e75b40 100644 --- a/subsys/bluetooth/mesh/rpr_cli.c +++ b/subsys/bluetooth/mesh/rpr_cli.c @@ -94,7 +94,7 @@ static int handle_extended_scan_report(const struct bt_mesh_model *mod, struct b struct net_buf_simple *buf) { struct bt_mesh_rpr_node srv = RPR_NODE(ctx); - struct bt_mesh_rpr_cli *cli = *(mod->user_data); + struct bt_mesh_rpr_cli *cli = mod->rt->user_data; struct bt_mesh_rpr_unprov dev = { 0 }; enum bt_mesh_rpr_status status; bool found_dev = false; @@ -127,7 +127,7 @@ static int handle_link_report(const struct bt_mesh_model *mod, struct bt_mesh_ms struct net_buf_simple *buf) { struct bt_mesh_rpr_node srv = RPR_NODE(ctx); - struct bt_mesh_rpr_cli *cli = *(mod->user_data); + struct bt_mesh_rpr_cli *cli = mod->rt->user_data; struct bt_mesh_rpr_link link; uint8_t reason = PROV_BEARER_LINK_STATUS_SUCCESS; @@ -164,7 +164,7 @@ static int handle_link_report(const struct bt_mesh_model *mod, struct bt_mesh_ms static int handle_link_status(const struct bt_mesh_model *mod, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf) { - struct bt_mesh_rpr_cli *cli = *(mod->user_data); + struct bt_mesh_rpr_cli *cli = mod->rt->user_data; struct bt_mesh_rpr_node srv = RPR_NODE(ctx); struct bt_mesh_rpr_link *rsp; struct bt_mesh_rpr_link link; @@ -198,7 +198,7 @@ static int handle_link_status(const struct bt_mesh_model *mod, struct bt_mesh_ms static int handle_pdu_outbound_report(const struct bt_mesh_model *mod, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf) { - struct bt_mesh_rpr_cli *cli = *(mod->user_data); + struct bt_mesh_rpr_cli *cli = mod->rt->user_data; struct bt_mesh_rpr_node srv = RPR_NODE(ctx); void *cb_data; uint8_t num; @@ -229,7 +229,7 @@ static int handle_pdu_outbound_report(const struct bt_mesh_model *mod, struct bt static int handle_pdu_report(const struct bt_mesh_model *mod, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf) { - struct bt_mesh_rpr_cli *cli = *(mod->user_data); + struct bt_mesh_rpr_cli *cli = mod->rt->user_data; struct bt_mesh_rpr_node srv = RPR_NODE(ctx); struct pb_remote_ctx cb_ctx = { cli, @@ -260,7 +260,7 @@ static int handle_pdu_report(const struct bt_mesh_model *mod, struct bt_mesh_msg static int handle_scan_caps_status(const struct bt_mesh_model *mod, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf) { - struct bt_mesh_rpr_cli *cli = *(mod->user_data); + struct bt_mesh_rpr_cli *cli = mod->rt->user_data; struct bt_mesh_rpr_node srv = RPR_NODE(ctx); struct bt_mesh_rpr_caps *caps; @@ -284,7 +284,7 @@ static int handle_scan_caps_status(const struct bt_mesh_model *mod, struct bt_me static int handle_scan_report(const struct bt_mesh_model *mod, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf) { - struct bt_mesh_rpr_cli *cli = *(mod->user_data); + struct bt_mesh_rpr_cli *cli = mod->rt->user_data; struct bt_mesh_rpr_node srv = RPR_NODE(ctx); struct bt_mesh_rpr_unprov dev = { 0 }; @@ -316,7 +316,7 @@ static int handle_scan_report(const struct bt_mesh_model *mod, struct bt_mesh_ms static int handle_scan_status(const struct bt_mesh_model *mod, struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf) { - struct bt_mesh_rpr_cli *cli = *(mod->user_data); + struct bt_mesh_rpr_cli *cli = mod->rt->user_data; struct bt_mesh_rpr_scan_status *status; struct bt_mesh_rpr_node srv = RPR_NODE(ctx); @@ -363,13 +363,13 @@ static void link_timeout(struct k_work *work) static int rpr_cli_init(const struct bt_mesh_model *mod) { - if (*(mod->elem_idx)) { + if (mod->rt->elem_idx) { LOG_ERR("Remote provisioning client must be initialized " "on first element"); return -EINVAL; } - struct bt_mesh_rpr_cli *cli = *(mod->user_data); + struct bt_mesh_rpr_cli *cli = mod->rt->user_data; cli->mod = mod; cli->link.time = LINK_TIMEOUT_SECONDS_DEFAULT; @@ -378,7 +378,7 @@ static int rpr_cli_init(const struct bt_mesh_model *mod) bt_mesh_msg_ack_ctx_init(&cli->prov_ack_ctx); k_work_init_delayable(&cli->link.timeout, link_timeout); mod->keys[0] = BT_MESH_KEY_DEV_ANY; - *(mod->flags) |= BT_MESH_MOD_DEVKEY_ONLY; + mod->rt->flags |= BT_MESH_MOD_DEVKEY_ONLY; return 0; } diff --git a/subsys/bluetooth/mesh/rpr_srv.c b/subsys/bluetooth/mesh/rpr_srv.c index e008aa0a8b1..9813842a367 100644 --- a/subsys/bluetooth/mesh/rpr_srv.c +++ b/subsys/bluetooth/mesh/rpr_srv.c @@ -1305,7 +1305,7 @@ static struct bt_le_scan_cb scan_cb = { static int rpr_srv_init(const struct bt_mesh_model *mod) { - if (*(mod->elem_idx) || srv.mod) { + if (mod->rt->elem_idx || srv.mod) { LOG_ERR("Remote provisioning server must be initialized " "on first element"); return -EINVAL; @@ -1320,7 +1320,7 @@ static int rpr_srv_init(const struct bt_mesh_model *mod) k_work_init(&srv.link.report, link_report_send_and_clear); bt_le_scan_cb_register(&scan_cb); mod->keys[0] = BT_MESH_KEY_DEV_LOCAL; - *(mod->flags) |= BT_MESH_MOD_DEVKEY_ONLY; + mod->rt->flags |= BT_MESH_MOD_DEVKEY_ONLY; return 0; } diff --git a/subsys/bluetooth/mesh/sar_cfg_cli.c b/subsys/bluetooth/mesh/sar_cfg_cli.c index aaf07451e1d..52239c95be4 100644 --- a/subsys/bluetooth/mesh/sar_cfg_cli.c +++ b/subsys/bluetooth/mesh/sar_cfg_cli.c @@ -94,17 +94,17 @@ static int bt_mesh_sar_cfg_cli_init(const struct bt_mesh_model *model) return -EINVAL; } - if (!*(model->user_data)) { + if (!model->rt->user_data) { LOG_ERR("No SAR Configuration Client context provided"); return -EINVAL; } - cli = *(model->user_data); + cli = model->rt->user_data; cli->model = model; cli->timeout = 2 * MSEC_PER_SEC; model->keys[0] = BT_MESH_KEY_DEV_ANY; - *(model->flags) |= BT_MESH_MOD_DEVKEY_ONLY; + model->rt->flags |= BT_MESH_MOD_DEVKEY_ONLY; bt_mesh_msg_ack_ctx_init(&cli->ack_ctx); @@ -115,7 +115,7 @@ static void bt_mesh_sar_cfg_cli_reset(const struct bt_mesh_model *model) { struct bt_mesh_sar_cfg_cli *model_cli; - model_cli = *(model->user_data); + model_cli = model->rt->user_data; bt_mesh_msg_ack_ctx_clear(&model_cli->ack_ctx); } diff --git a/subsys/bluetooth/mesh/sar_cfg_srv.c b/subsys/bluetooth/mesh/sar_cfg_srv.c index 59ec36907c5..2943ce02ddd 100644 --- a/subsys/bluetooth/mesh/sar_cfg_srv.c +++ b/subsys/bluetooth/mesh/sar_cfg_srv.c @@ -155,7 +155,7 @@ static int sar_cfg_srv_init(const struct bt_mesh_model *model) * device-key is allowed to access this model. */ model->keys[0] = BT_MESH_KEY_DEV_LOCAL; - *(model->flags) |= BT_MESH_MOD_DEVKEY_ONLY; + model->rt->flags |= BT_MESH_MOD_DEVKEY_ONLY; return 0; } diff --git a/subsys/bluetooth/mesh/shell/blob.c b/subsys/bluetooth/mesh/shell/blob.c index ed0f4fbd458..a6888da4270 100644 --- a/subsys/bluetooth/mesh/shell/blob.c +++ b/subsys/bluetooth/mesh/shell/blob.c @@ -351,7 +351,7 @@ static int cmd_tx(const struct shell *sh, size_t argc, char *argv[]) "pull", blob_cli_xfer.xfer.size, group); - err = bt_mesh_blob_cli_send((struct bt_mesh_blob_cli *)*(mod_cli->user_data), + err = bt_mesh_blob_cli_send((struct bt_mesh_blob_cli *)mod_cli->rt->user_data, &blob_cli_xfer.inputs, &blob_cli_xfer.xfer, bt_mesh_shell_blob_io); if (err) { @@ -421,7 +421,7 @@ static int cmd_caps(const struct shell *sh, size_t argc, char *argv[]) blob_cli_inputs_prepare(group); - err = bt_mesh_blob_cli_caps_get((struct bt_mesh_blob_cli *)*(mod_cli->user_data), + err = bt_mesh_blob_cli_caps_get((struct bt_mesh_blob_cli *)mod_cli->rt->user_data, &blob_cli_xfer.inputs); if (err) { shell_print(sh, "Boundary check start failed (err: %d)", err); @@ -438,7 +438,7 @@ static int cmd_tx_cancel(const struct shell *sh, size_t argc, } shell_print(sh, "Cancelling transfer"); - bt_mesh_blob_cli_cancel((struct bt_mesh_blob_cli *)*(mod_cli->user_data)); + bt_mesh_blob_cli_cancel((struct bt_mesh_blob_cli *)mod_cli->rt->user_data); return 0; } @@ -465,7 +465,7 @@ static int cmd_tx_get(const struct shell *sh, size_t argc, char *argv[]) blob_cli_inputs_prepare(group); - err = bt_mesh_blob_cli_xfer_progress_get((struct bt_mesh_blob_cli *)*(mod_cli->user_data), + err = bt_mesh_blob_cli_xfer_progress_get((struct bt_mesh_blob_cli *)mod_cli->rt->user_data, &blob_cli_xfer.inputs); if (err) { shell_print(sh, "ERR %d", err); @@ -482,7 +482,7 @@ static int cmd_tx_suspend(const struct shell *sh, size_t argc, } shell_print(sh, "Suspending transfer"); - bt_mesh_blob_cli_suspend((struct bt_mesh_blob_cli *)*(mod_cli->user_data)); + bt_mesh_blob_cli_suspend((struct bt_mesh_blob_cli *)mod_cli->rt->user_data); return 0; } @@ -494,7 +494,7 @@ static int cmd_tx_resume(const struct shell *sh, size_t argc, char *argv[]) } shell_print(sh, "Resuming transfer"); - bt_mesh_blob_cli_resume((struct bt_mesh_blob_cli *)*(mod_cli->user_data)); + bt_mesh_blob_cli_resume((struct bt_mesh_blob_cli *)mod_cli->rt->user_data); return 0; } @@ -530,7 +530,7 @@ static int cmd_rx(const struct shell *sh, size_t argc, char *argv[]) } shell_print(sh, "Receive BLOB 0x%x", id); - err = bt_mesh_blob_srv_recv((struct bt_mesh_blob_srv *)*(mod_srv->user_data), + err = bt_mesh_blob_srv_recv((struct bt_mesh_blob_srv *)mod_srv->rt->user_data, id, bt_mesh_shell_blob_io, BT_MESH_TTL_MAX, timeout_base); if (err) { shell_print(sh, "BLOB RX setup failed (%d)", err); @@ -548,7 +548,7 @@ static int cmd_rx_cancel(const struct shell *sh, size_t argc, char *argv[]) } shell_print(sh, "Cancelling BLOB rx"); - err = bt_mesh_blob_srv_cancel((struct bt_mesh_blob_srv *)*(mod_srv->user_data)); + err = bt_mesh_blob_srv_cancel((struct bt_mesh_blob_srv *)mod_srv->rt->user_data); if (err) { shell_print(sh, "BLOB cancel failed (%d)", err); } diff --git a/subsys/bluetooth/mesh/shell/dfd.c b/subsys/bluetooth/mesh/shell/dfd.c index 464a5340342..4b3d4970282 100644 --- a/subsys/bluetooth/mesh/shell/dfd.c +++ b/subsys/bluetooth/mesh/shell/dfd.c @@ -70,7 +70,7 @@ static int cmd_dfd_receivers_add(const struct shell *sh, size_t argc, char *argv return -ENODEV; } - struct bt_mesh_dfd_srv *dfd_srv = *(mod->user_data); + struct bt_mesh_dfd_srv *dfd_srv = mod->rt->user_data; if (bt_mesh_dfu_cli_is_busy(&dfd_srv->dfu)) { print_receivers_status(sh, dfd_srv, @@ -122,7 +122,7 @@ static int cmd_dfd_receivers_delete_all(const struct shell *sh, size_t argc, cha return -ENODEV; } - struct bt_mesh_dfd_srv *dfd_srv = *(mod->user_data); + struct bt_mesh_dfd_srv *dfd_srv = mod->rt->user_data; enum bt_mesh_dfd_status status = bt_mesh_dfd_srv_receivers_delete_all( dfd_srv); @@ -142,7 +142,7 @@ static int cmd_dfd_receivers_get(const struct shell *sh, size_t argc, char *argv return -ENODEV; } - struct bt_mesh_dfd_srv *dfd_srv = *(mod->user_data); + struct bt_mesh_dfd_srv *dfd_srv = mod->rt->user_data; int err = 0; uint16_t first = shell_strtoul(argv[1], 0, &err); @@ -197,7 +197,7 @@ static int cmd_dfd_get(const struct shell *sh, size_t argc, char *argv[]) return -ENODEV; } - struct bt_mesh_dfd_srv *dfd_srv = *(mod->user_data); + struct bt_mesh_dfd_srv *dfd_srv = mod->rt->user_data; print_dfd_status(sh, dfd_srv, BT_MESH_DFD_SUCCESS); @@ -210,7 +210,7 @@ static int cmd_dfd_start(const struct shell *sh, size_t argc, char *argv[]) return -ENODEV; } - struct bt_mesh_dfd_srv *dfd_srv = *(mod->user_data); + struct bt_mesh_dfd_srv *dfd_srv = mod->rt->user_data; struct bt_mesh_dfd_start_params params; int err = 0; @@ -267,7 +267,7 @@ static int cmd_dfd_suspend(const struct shell *sh, size_t argc, char *argv[]) return -ENODEV; } - struct bt_mesh_dfd_srv *dfd_srv = *(mod->user_data); + struct bt_mesh_dfd_srv *dfd_srv = mod->rt->user_data; enum bt_mesh_dfd_status status = bt_mesh_dfd_srv_suspend(dfd_srv); @@ -285,7 +285,7 @@ static int cmd_dfd_cancel(const struct shell *sh, size_t argc, char *argv[]) return -ENODEV; } - struct bt_mesh_dfd_srv *dfd_srv = *(mod->user_data); + struct bt_mesh_dfd_srv *dfd_srv = mod->rt->user_data; enum bt_mesh_dfd_status status = bt_mesh_dfd_srv_cancel(dfd_srv, NULL); @@ -303,7 +303,7 @@ static int cmd_dfd_apply(const struct shell *sh, size_t argc, char *argv[]) return -ENODEV; } - struct bt_mesh_dfd_srv *dfd_srv = *(mod->user_data); + struct bt_mesh_dfd_srv *dfd_srv = mod->rt->user_data; enum bt_mesh_dfd_status status = bt_mesh_dfd_srv_apply(dfd_srv); @@ -364,7 +364,7 @@ static int cmd_dfd_fw_delete(const struct shell *sh, size_t argc, char *argv[]) return -ENODEV; } - struct bt_mesh_dfd_srv *dfd_srv = *(mod->user_data); + struct bt_mesh_dfd_srv *dfd_srv = mod->rt->user_data; uint8_t fwid_buf[CONFIG_BT_MESH_DFU_FWID_MAXLEN]; size_t hexlen = strlen(argv[1]); @@ -394,7 +394,7 @@ static int cmd_dfd_fw_delete_all(const struct shell *sh, size_t argc, char *argv return -ENODEV; } - struct bt_mesh_dfd_srv *dfd_srv = *(mod->user_data); + struct bt_mesh_dfd_srv *dfd_srv = mod->rt->user_data; enum bt_mesh_dfd_status status = bt_mesh_dfd_srv_fw_delete_all(dfd_srv); diff --git a/subsys/bluetooth/mesh/shell/dfu.c b/subsys/bluetooth/mesh/shell/dfu.c index 22c60dc17c8..6b7df4a8bd4 100644 --- a/subsys/bluetooth/mesh/shell/dfu.c +++ b/subsys/bluetooth/mesh/shell/dfu.c @@ -587,7 +587,7 @@ static int cmd_dfu_target_state(const struct shell *sh, size_t argc, char *argv[ return -ENODEV; } - err = bt_mesh_dfu_cli_status_get((struct bt_mesh_dfu_cli *)*(mod_cli->user_data), + err = bt_mesh_dfu_cli_status_get((struct bt_mesh_dfu_cli *)mod_cli->rt->user_data, &ctx, &rsp); if (err) { shell_print(sh, "Failed getting target status (err: %d)", @@ -654,7 +654,7 @@ static int cmd_dfu_target_imgs(const struct shell *sh, size_t argc, char *argv[] shell_print(sh, "Requesting DFU images in 0x%04x", bt_mesh_shell_target_ctx.dst); - err = bt_mesh_dfu_cli_imgs_get((struct bt_mesh_dfu_cli *)*(mod_cli->user_data), + err = bt_mesh_dfu_cli_imgs_get((struct bt_mesh_dfu_cli *)mod_cli->rt->user_data, &ctx, dfu_img_cb, NULL, img_cnt); if (err) { shell_print(sh, "Request failed (err: %d)", err); @@ -694,7 +694,7 @@ static int cmd_dfu_target_check(const struct shell *sh, size_t argc, char *argv[ return 0; } - err = bt_mesh_dfu_cli_metadata_check((struct bt_mesh_dfu_cli *)*(mod_cli->user_data), + err = bt_mesh_dfu_cli_metadata_check((struct bt_mesh_dfu_cli *)mod_cli->rt->user_data, &ctx, img_idx, slot, &rsp); if (err) { shell_print(sh, "Metadata check failed. err: %d", err); @@ -765,7 +765,7 @@ static int cmd_dfu_send(const struct shell *sh, size_t argc, char *argv[]) dfu_tx.inputs.app_idx = bt_mesh_shell_target_ctx.app_idx; dfu_tx.inputs.ttl = BT_MESH_TTL_DEFAULT; - err = bt_mesh_dfu_cli_send((struct bt_mesh_dfu_cli *)*(mod_cli->user_data), + err = bt_mesh_dfu_cli_send((struct bt_mesh_dfu_cli *)mod_cli->rt->user_data, &dfu_tx.inputs, bt_mesh_shell_blob_io, &xfer); if (err) { shell_print(sh, "Failed (err: %d)", err); @@ -800,7 +800,7 @@ static int cmd_dfu_tx_cancel(const struct shell *sh, size_t argc, char *argv[]) shell_print(sh, "Cancelling DFU"); } - err = bt_mesh_dfu_cli_cancel((struct bt_mesh_dfu_cli *)*(mod_cli->user_data), + err = bt_mesh_dfu_cli_cancel((struct bt_mesh_dfu_cli *)mod_cli->rt->user_data, (argc == 2) ? &ctx : NULL); if (err) { shell_print(sh, "Failed (err: %d)", err); @@ -819,7 +819,7 @@ static int cmd_dfu_apply(const struct shell *sh, size_t argc, char *argv[]) shell_print(sh, "Applying DFU"); - err = bt_mesh_dfu_cli_apply((struct bt_mesh_dfu_cli *)*(mod_cli->user_data)); + err = bt_mesh_dfu_cli_apply((struct bt_mesh_dfu_cli *)mod_cli->rt->user_data); if (err) { shell_print(sh, "Failed (err: %d)", err); } @@ -837,7 +837,7 @@ static int cmd_dfu_confirm(const struct shell *sh, size_t argc, char *argv[]) shell_print(sh, "Confirming DFU"); - err = bt_mesh_dfu_cli_confirm((struct bt_mesh_dfu_cli *)*(mod_cli->user_data)); + err = bt_mesh_dfu_cli_confirm((struct bt_mesh_dfu_cli *)mod_cli->rt->user_data); if (err) { shell_print(sh, "Failed (err: %d)", err); } @@ -855,7 +855,7 @@ static int cmd_dfu_suspend(const struct shell *sh, size_t argc, char *argv[]) shell_print(sh, "Suspending DFU"); - err = bt_mesh_dfu_cli_suspend((struct bt_mesh_dfu_cli *)*(mod_cli->user_data)); + err = bt_mesh_dfu_cli_suspend((struct bt_mesh_dfu_cli *)mod_cli->rt->user_data); if (err) { shell_print(sh, "Failed (err: %d)", err); } @@ -873,7 +873,7 @@ static int cmd_dfu_resume(const struct shell *sh, size_t argc, char *argv[]) shell_print(sh, "Resuming DFU"); - err = bt_mesh_dfu_cli_resume((struct bt_mesh_dfu_cli *)*(mod_cli->user_data)); + err = bt_mesh_dfu_cli_resume((struct bt_mesh_dfu_cli *)mod_cli->rt->user_data); if (err) { shell_print(sh, "Failed (err: %d)", err); } @@ -888,7 +888,7 @@ static int cmd_dfu_tx_progress(const struct shell *sh, size_t argc, char *argv[] } shell_print(sh, "DFU progress: %u %%", - bt_mesh_dfu_cli_progress((struct bt_mesh_dfu_cli *)*(mod_cli->user_data))); + bt_mesh_dfu_cli_progress((struct bt_mesh_dfu_cli *)mod_cli->rt->user_data)); return 0; } @@ -904,7 +904,7 @@ static int cmd_dfu_applied(const struct shell *sh, size_t argc, char *argv[]) return -ENODEV; } - bt_mesh_dfu_srv_applied((struct bt_mesh_dfu_srv *)*(mod_srv->user_data)); + bt_mesh_dfu_srv_applied((struct bt_mesh_dfu_srv *)mod_srv->rt->user_data); return 0; } @@ -914,7 +914,7 @@ static int cmd_dfu_rx_cancel(const struct shell *sh, size_t argc, char *argv[]) return -ENODEV; } - bt_mesh_dfu_srv_cancel((struct bt_mesh_dfu_srv *)*(mod_srv->user_data)); + bt_mesh_dfu_srv_cancel((struct bt_mesh_dfu_srv *)mod_srv->rt->user_data); return 0; } @@ -925,7 +925,7 @@ static int cmd_dfu_rx_progress(const struct shell *sh, size_t argc, char *argv[] } shell_print(sh, "DFU progress: %u %%", - bt_mesh_dfu_srv_progress((struct bt_mesh_dfu_srv *)*(mod_srv->user_data))); + bt_mesh_dfu_srv_progress((struct bt_mesh_dfu_srv *)mod_srv->rt->user_data)); return 0; } diff --git a/subsys/bluetooth/mesh/shell/health.c b/subsys/bluetooth/mesh/shell/health.c index a0ca150ae15..21480c6a66e 100644 --- a/subsys/bluetooth/mesh/shell/health.c +++ b/subsys/bluetooth/mesh/shell/health.c @@ -40,7 +40,7 @@ static int cmd_fault_get(const struct shell *sh, size_t argc, char *argv[]) return -ENODEV; } - struct bt_mesh_health_cli *cli = *(mod->user_data); + struct bt_mesh_health_cli *cli = mod->rt->user_data; struct bt_mesh_msg_ctx ctx = BT_MESH_MSG_CTX_INIT_APP(bt_mesh_shell_target_ctx.app_idx, bt_mesh_shell_target_ctx.dst); uint8_t faults[32]; @@ -74,7 +74,7 @@ static int fault_clear(const struct shell *sh, size_t argc, char *argv[], bool a return -ENODEV; } - struct bt_mesh_health_cli *cli = *(mod->user_data); + struct bt_mesh_health_cli *cli = mod->rt->user_data; struct bt_mesh_msg_ctx ctx = BT_MESH_MSG_CTX_INIT_APP(bt_mesh_shell_target_ctx.app_idx, bt_mesh_shell_target_ctx.dst); uint8_t test_id; @@ -126,7 +126,7 @@ static int fault_test(const struct shell *sh, size_t argc, char *argv[], bool ac return -ENODEV; } - struct bt_mesh_health_cli *cli = *(mod->user_data); + struct bt_mesh_health_cli *cli = mod->rt->user_data; struct bt_mesh_msg_ctx ctx = BT_MESH_MSG_CTX_INIT_APP(bt_mesh_shell_target_ctx.app_idx, bt_mesh_shell_target_ctx.dst); uint8_t test_id; @@ -179,7 +179,7 @@ static int cmd_period_get(const struct shell *sh, size_t argc, char *argv[]) return -ENODEV; } - struct bt_mesh_health_cli *cli = *(mod->user_data); + struct bt_mesh_health_cli *cli = mod->rt->user_data; struct bt_mesh_msg_ctx ctx = BT_MESH_MSG_CTX_INIT_APP(bt_mesh_shell_target_ctx.app_idx, bt_mesh_shell_target_ctx.dst); uint8_t divisor; @@ -201,7 +201,7 @@ static int period_set(const struct shell *sh, size_t argc, char *argv[], bool ac return -ENODEV; } - struct bt_mesh_health_cli *cli = *(mod->user_data); + struct bt_mesh_health_cli *cli = mod->rt->user_data; struct bt_mesh_msg_ctx ctx = BT_MESH_MSG_CTX_INIT_APP(bt_mesh_shell_target_ctx.app_idx, bt_mesh_shell_target_ctx.dst); uint8_t divisor; @@ -251,7 +251,7 @@ static int cmd_attention_get(const struct shell *sh, size_t argc, char *argv[]) return -ENODEV; } - struct bt_mesh_health_cli *cli = *(mod->user_data); + struct bt_mesh_health_cli *cli = mod->rt->user_data; struct bt_mesh_msg_ctx ctx = BT_MESH_MSG_CTX_INIT_APP(bt_mesh_shell_target_ctx.app_idx, bt_mesh_shell_target_ctx.dst); uint8_t attention; @@ -273,7 +273,7 @@ static int attention_set(const struct shell *sh, size_t argc, char *argv[], bool return -ENODEV; } - struct bt_mesh_health_cli *cli = *(mod->user_data); + struct bt_mesh_health_cli *cli = mod->rt->user_data; struct bt_mesh_msg_ctx ctx = BT_MESH_MSG_CTX_INIT_APP(bt_mesh_shell_target_ctx.app_idx, bt_mesh_shell_target_ctx.dst); uint8_t attention; diff --git a/subsys/bluetooth/mesh/shell/rpr.c b/subsys/bluetooth/mesh/shell/rpr.c index 1ddb11f497d..870fc7c5d37 100644 --- a/subsys/bluetooth/mesh/shell/rpr.c +++ b/subsys/bluetooth/mesh/shell/rpr.c @@ -108,7 +108,7 @@ static int cmd_scan(const struct shell *sh, size_t argc, char *argv[]) hex2bin(argv[2], strlen(argv[2]), uuid, 16); } - err = bt_mesh_rpr_scan_start((struct bt_mesh_rpr_cli *)*(mod->user_data), + err = bt_mesh_rpr_scan_start((struct bt_mesh_rpr_cli *)mod->rt->user_data, &srv, argc > 2 ? uuid : NULL, timeout, BT_MESH_RPR_SCAN_MAX_DEVS_ANY, &rsp); if (err) { @@ -153,7 +153,7 @@ static int cmd_scan_ext(const struct shell *sh, size_t argc, char *argv[]) return err; } - err = bt_mesh_rpr_scan_start_ext((struct bt_mesh_rpr_cli *)*(mod->user_data), + err = bt_mesh_rpr_scan_start_ext((struct bt_mesh_rpr_cli *)mod->rt->user_data, &srv, uuid, timeout, ad_types, (argc - 3)); if (err) { @@ -189,7 +189,7 @@ static int cmd_scan_srv(const struct shell *sh, size_t argc, char *argv[]) return err; } - err = bt_mesh_rpr_scan_start_ext((struct bt_mesh_rpr_cli *)*(mod->user_data), + err = bt_mesh_rpr_scan_start_ext((struct bt_mesh_rpr_cli *)mod->rt->user_data, &srv, NULL, 0, ad_types, (argc - 1)); if (err) { shell_print(sh, "Scan start failed: %d", err); @@ -213,7 +213,7 @@ static int cmd_scan_caps(const struct shell *sh, size_t argc, char *argv[]) return -ENODEV; } - err = bt_mesh_rpr_scan_caps_get((struct bt_mesh_rpr_cli *)*(mod->user_data), &srv, &caps); + err = bt_mesh_rpr_scan_caps_get((struct bt_mesh_rpr_cli *)mod->rt->user_data, &srv, &caps); if (err) { shell_print(sh, "Scan capabilities get failed: %d", err); return err; @@ -241,7 +241,7 @@ static int cmd_scan_get(const struct shell *sh, size_t argc, char *argv[]) return -ENODEV; } - err = bt_mesh_rpr_scan_get((struct bt_mesh_rpr_cli *)*(mod->user_data), &srv, &rsp); + err = bt_mesh_rpr_scan_get((struct bt_mesh_rpr_cli *)mod->rt->user_data, &srv, &rsp); if (err) { shell_print(sh, "Scan get failed: %d", err); return err; @@ -269,7 +269,7 @@ static int cmd_scan_stop(const struct shell *sh, size_t argc, char *argv[]) return -ENODEV; } - err = bt_mesh_rpr_scan_stop((struct bt_mesh_rpr_cli *)*(mod->user_data), &srv, &rsp); + err = bt_mesh_rpr_scan_stop((struct bt_mesh_rpr_cli *)mod->rt->user_data, &srv, &rsp); if (err || rsp.status) { shell_print(sh, "Scan stop failed: %d %u", err, rsp.status); return err; @@ -294,7 +294,7 @@ static int cmd_link_get(const struct shell *sh, size_t argc, char *argv[]) return -ENODEV; } - err = bt_mesh_rpr_link_get((struct bt_mesh_rpr_cli *)*(mod->user_data), &srv, &rsp); + err = bt_mesh_rpr_link_get((struct bt_mesh_rpr_cli *)mod->rt->user_data, &srv, &rsp); if (err) { shell_print(sh, "Link get failed: %d %u", err, rsp.status); return err; @@ -316,7 +316,7 @@ static int cmd_link_close(const struct shell *sh, size_t argc, char *argv[]) }; int err; - err = bt_mesh_rpr_link_close((struct bt_mesh_rpr_cli *)*(mod->user_data), &srv, &rsp); + err = bt_mesh_rpr_link_close((struct bt_mesh_rpr_cli *)mod->rt->user_data, &srv, &rsp); if (err) { shell_print(sh, "Link close failed: %d %u", err, rsp.status); return err; @@ -355,7 +355,7 @@ static int cmd_provision_remote(const struct shell *sh, size_t argc, char *argv[ return err; } - err = bt_mesh_provision_remote((struct bt_mesh_rpr_cli *)*(mod->user_data), + err = bt_mesh_provision_remote((struct bt_mesh_rpr_cli *)mod->rt->user_data, &srv, uuid, net_idx, addr); if (err) { shell_print(sh, "Prov remote start failed: %d", err); @@ -396,7 +396,7 @@ static int cmd_reprovision_remote(const struct shell *sh, size_t argc, char *arg return err; } - err = bt_mesh_reprovision_remote((struct bt_mesh_rpr_cli *)*(mod->user_data), + err = bt_mesh_reprovision_remote((struct bt_mesh_rpr_cli *)mod->rt->user_data, &srv, addr, composition_changed); if (err) { shell_print(sh, "Reprovisioning failed: %d", err); diff --git a/subsys/bluetooth/mesh/shell/utils.c b/subsys/bluetooth/mesh/shell/utils.c index 1d8ab79951d..1ccb0e25212 100644 --- a/subsys/bluetooth/mesh/shell/utils.c +++ b/subsys/bluetooth/mesh/shell/utils.c @@ -60,7 +60,7 @@ int bt_mesh_shell_mdl_print_all(const struct shell *sh, uint16_t mod_id) if (mod) { shell_print(sh, "Client model instance found at addr 0x%.4X. Element index: %d", - comp->elem[i].addr, *(mod->elem_idx)); + comp->elem[i].addr, mod->rt->elem_idx); } } diff --git a/subsys/bluetooth/mesh/sol_pdu_rpl_cli.c b/subsys/bluetooth/mesh/sol_pdu_rpl_cli.c index 05457eff338..dd809b59996 100644 --- a/subsys/bluetooth/mesh/sol_pdu_rpl_cli.c +++ b/subsys/bluetooth/mesh/sol_pdu_rpl_cli.c @@ -169,7 +169,7 @@ static int sol_pdu_rpl_cli_init(const struct bt_mesh_model *mod) msg_timeout = CONFIG_BT_MESH_SOL_PDU_RPL_CLI_TIMEOUT; - cli = *(mod->user_data); + cli = mod->rt->user_data; cli->model = mod; bt_mesh_msg_ack_ctx_init(&cli->ack_ctx); return 0; diff --git a/tests/bsim/bluetooth/mesh/src/test_access.c b/tests/bsim/bluetooth/mesh/src/test_access.c index dacc30c741e..14ee6b03428 100644 --- a/tests/bsim/bluetooth/mesh/src/test_access.c +++ b/tests/bsim/bluetooth/mesh/src/test_access.c @@ -261,7 +261,7 @@ static int model3_init(const struct bt_mesh_model *model) ASSERT_OK(bt_mesh_model_extend(model, model - 2)); ASSERT_OK(bt_mesh_model_extend(model, model - 1)); - if (*(model->elem_idx) == 1) { + if (model->rt->elem_idx == 1) { ASSERT_OK(bt_mesh_model_extend(model, &models[4])); } diff --git a/tests/bsim/bluetooth/mesh/src/test_lcd.c b/tests/bsim/bluetooth/mesh/src/test_lcd.c index 7e1d9ffca3c..337edaddc54 100644 --- a/tests/bsim/bluetooth/mesh/src/test_lcd.c +++ b/tests/bsim/bluetooth/mesh/src/test_lcd.c @@ -31,19 +31,10 @@ LOG_MODULE_REGISTER(test_lcd, LOG_LEVEL_INF); LCD_STATUS_FIELDS_LEN - \ BT_MESH_MIC_SHORT) /* 378 bytes */ -#ifdef CONFIG_BT_MESH_MODEL_EXTENSIONS -#define BT_MESH_MODEL_NEXT_UNASSIGNED() \ - .next = (const struct bt_mesh_model *[]){ NULL }, -#else -#define BT_MESH_MODEL_NEXT_UNASSIGNED() -#endif - #define TEST_MODEL_CNT_CB(_dummy_op, _metadata) \ { \ .id = 0x1234, \ - .elem_idx = (uint8_t []) { 0 }, \ - .mod_idx = (uint8_t []) { 0 }, \ - .flags = (uint16_t []) { 0 }, \ + BT_MESH_MODEL_RUNTIME_INIT(NULL) \ .pub = NULL, \ .keys = NULL, \ .keys_cnt = 0, \ @@ -51,8 +42,6 @@ LOG_MODULE_REGISTER(test_lcd, LOG_LEVEL_INF); .groups_cnt = 0, \ .op = _dummy_op, \ .cb = NULL, \ - BT_MESH_MODEL_NEXT_UNASSIGNED() \ - .user_data = (void *[]){ NULL }, \ .metadata = _metadata, \ } diff --git a/tests/bsim/bluetooth/mesh/src/test_provision.c b/tests/bsim/bluetooth/mesh/src/test_provision.c index 80eb9ff38cd..63b8d89416c 100644 --- a/tests/bsim/bluetooth/mesh/src/test_provision.c +++ b/tests/bsim/bluetooth/mesh/src/test_provision.c @@ -171,7 +171,7 @@ static const struct bt_mesh_model_op model_rpr_op1[] = { static int mock_model_init(const struct bt_mesh_model *mod) { mod->keys[0] = BT_MESH_KEY_DEV_LOCAL; - *(mod->flags) |= BT_MESH_MOD_DEVKEY_ONLY; + mod->rt->flags |= BT_MESH_MOD_DEVKEY_ONLY; return 0; }