Bluetooth: Mesh: Make bt_mesh_model as rodata
Since model struct most of member should not change at run time, so mark as const will be suitable and safely. Signed-off-by: Lingao Meng <menglingao@xiaomi.com>
This commit is contained in:
parent
df7114456e
commit
ab08f34fd9
79 changed files with 929 additions and 887 deletions
|
@ -48,7 +48,7 @@ static void node_reset_pending_handler(struct k_work *work)
|
|||
|
||||
static K_WORK_DEFINE(node_reset_pending, node_reset_pending_handler);
|
||||
|
||||
static int dev_comp_data_get(struct bt_mesh_model *model,
|
||||
static int dev_comp_data_get(const struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
|
@ -86,7 +86,7 @@ static int dev_comp_data_get(struct bt_mesh_model *model,
|
|||
return err;
|
||||
}
|
||||
|
||||
static struct bt_mesh_model *get_model(struct bt_mesh_elem *elem,
|
||||
static const struct bt_mesh_model *get_model(struct bt_mesh_elem *elem,
|
||||
struct net_buf_simple *buf, bool *vnd)
|
||||
{
|
||||
if (buf->len < 4) {
|
||||
|
@ -113,9 +113,9 @@ static struct bt_mesh_model *get_model(struct bt_mesh_elem *elem,
|
|||
}
|
||||
}
|
||||
|
||||
static uint8_t _mod_pub_set(struct bt_mesh_model *model, uint16_t pub_addr, const uint8_t *uuid,
|
||||
uint16_t app_idx, uint8_t cred_flag, uint8_t ttl, uint8_t period,
|
||||
uint8_t retransmit, bool store)
|
||||
static uint8_t _mod_pub_set(const struct bt_mesh_model *model, uint16_t pub_addr,
|
||||
const uint8_t *uuid, uint16_t app_idx, uint8_t cred_flag,
|
||||
uint8_t ttl, uint8_t period, uint8_t retransmit, bool store)
|
||||
{
|
||||
if (!model->pub) {
|
||||
return STATUS_NVAL_PUB_PARAM;
|
||||
|
@ -199,7 +199,7 @@ static uint8_t _mod_pub_set(struct bt_mesh_model *model, uint16_t pub_addr, cons
|
|||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static uint8_t mod_bind(struct bt_mesh_model *model, uint16_t key_idx)
|
||||
static uint8_t mod_bind(const struct bt_mesh_model *model, uint16_t key_idx)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
@ -232,7 +232,7 @@ static uint8_t mod_bind(struct bt_mesh_model *model, uint16_t key_idx)
|
|||
return STATUS_INSUFF_RESOURCES;
|
||||
}
|
||||
|
||||
static uint8_t mod_unbind(struct bt_mesh_model *model, uint16_t key_idx, bool store)
|
||||
static uint8_t mod_unbind(const struct bt_mesh_model *model, uint16_t key_idx, bool store)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
@ -284,7 +284,7 @@ static void key_idx_pack_list(struct net_buf_simple *buf, uint16_t *arr, size_t
|
|||
|
||||
}
|
||||
|
||||
static int send_app_key_status(struct bt_mesh_model *model,
|
||||
static int send_app_key_status(const struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
uint8_t status,
|
||||
uint16_t app_idx, uint16_t net_idx)
|
||||
|
@ -302,7 +302,7 @@ static int send_app_key_status(struct bt_mesh_model *model,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int app_key_add(struct bt_mesh_model *model,
|
||||
static int app_key_add(const struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
|
@ -318,7 +318,7 @@ static int app_key_add(struct bt_mesh_model *model,
|
|||
return send_app_key_status(model, ctx, status, key_app_idx, key_net_idx);
|
||||
}
|
||||
|
||||
static int app_key_update(struct bt_mesh_model *model,
|
||||
static int app_key_update(const struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
|
@ -335,7 +335,7 @@ static int app_key_update(struct bt_mesh_model *model,
|
|||
return send_app_key_status(model, ctx, status, key_app_idx, key_net_idx);
|
||||
}
|
||||
|
||||
static void mod_app_key_del(struct bt_mesh_model *mod,
|
||||
static void mod_app_key_del(const struct bt_mesh_model *mod,
|
||||
struct bt_mesh_elem *elem, bool vnd, bool primary,
|
||||
void *user_data)
|
||||
{
|
||||
|
@ -354,7 +354,7 @@ static void app_key_evt(uint16_t app_idx, uint16_t net_idx,
|
|||
|
||||
BT_MESH_APP_KEY_CB_DEFINE(app_key_evt);
|
||||
|
||||
static int app_key_del(struct bt_mesh_model *model,
|
||||
static int app_key_del(const struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
|
@ -373,7 +373,7 @@ static int app_key_del(struct bt_mesh_model *model,
|
|||
/* Index list length: 3 bytes for every pair and 2 bytes for an odd idx */
|
||||
#define IDX_LEN(num) (((num) / 2) * 3 + ((num) % 2) * 2)
|
||||
|
||||
static int app_key_get(struct bt_mesh_model *model,
|
||||
static int app_key_get(const struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
|
@ -422,7 +422,7 @@ send_status:
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int beacon_get(struct bt_mesh_model *model,
|
||||
static int beacon_get(const struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
|
@ -441,7 +441,7 @@ static int beacon_get(struct bt_mesh_model *model,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int beacon_set(struct bt_mesh_model *model,
|
||||
static int beacon_set(const struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
|
@ -467,7 +467,7 @@ static int beacon_set(struct bt_mesh_model *model,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int default_ttl_get(struct bt_mesh_model *model,
|
||||
static int default_ttl_get(const struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
|
@ -486,7 +486,7 @@ static int default_ttl_get(struct bt_mesh_model *model,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int default_ttl_set(struct bt_mesh_model *model,
|
||||
static int default_ttl_set(const struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
|
@ -512,7 +512,7 @@ static int default_ttl_set(struct bt_mesh_model *model,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int send_gatt_proxy_status(struct bt_mesh_model *model,
|
||||
static int send_gatt_proxy_status(const struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx)
|
||||
{
|
||||
BT_MESH_MODEL_BUF_DEFINE(msg, OP_GATT_PROXY_STATUS, 1);
|
||||
|
@ -527,7 +527,7 @@ static int send_gatt_proxy_status(struct bt_mesh_model *model,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int gatt_proxy_get(struct bt_mesh_model *model,
|
||||
static int gatt_proxy_get(const struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
|
@ -537,7 +537,7 @@ static int gatt_proxy_get(struct bt_mesh_model *model,
|
|||
return send_gatt_proxy_status(model, ctx);
|
||||
}
|
||||
|
||||
static int gatt_proxy_set(struct bt_mesh_model *model,
|
||||
static int gatt_proxy_set(const struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
|
@ -561,7 +561,7 @@ static int gatt_proxy_set(struct bt_mesh_model *model,
|
|||
return send_gatt_proxy_status(model, ctx);
|
||||
}
|
||||
|
||||
static int net_transmit_get(struct bt_mesh_model *model,
|
||||
static int net_transmit_get(const struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
|
@ -580,7 +580,7 @@ static int net_transmit_get(struct bt_mesh_model *model,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int net_transmit_set(struct bt_mesh_model *model,
|
||||
static int net_transmit_set(const struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
|
@ -604,7 +604,7 @@ static int net_transmit_set(struct bt_mesh_model *model,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int relay_get(struct bt_mesh_model *model,
|
||||
static int relay_get(const struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
|
@ -624,7 +624,7 @@ static int relay_get(struct bt_mesh_model *model,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int relay_set(struct bt_mesh_model *model,
|
||||
static int relay_set(const struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
|
@ -651,10 +651,10 @@ static int relay_set(struct bt_mesh_model *model,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int send_mod_pub_status(struct bt_mesh_model *cfg_mod,
|
||||
static int send_mod_pub_status(const struct bt_mesh_model *cfg_mod,
|
||||
struct bt_mesh_msg_ctx *ctx, uint16_t elem_addr,
|
||||
uint16_t pub_addr, bool vnd,
|
||||
struct bt_mesh_model *mod, uint8_t status,
|
||||
const struct bt_mesh_model *mod, uint8_t status,
|
||||
uint8_t *mod_id)
|
||||
{
|
||||
BT_MESH_MODEL_BUF_DEFINE(msg, OP_MOD_PUB_STATUS, 14);
|
||||
|
@ -691,11 +691,11 @@ static int send_mod_pub_status(struct bt_mesh_model *cfg_mod,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int mod_pub_get(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx,
|
||||
static int mod_pub_get(const struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
uint16_t elem_addr, pub_addr = 0U;
|
||||
struct bt_mesh_model *mod;
|
||||
const struct bt_mesh_model *mod;
|
||||
struct bt_mesh_elem *elem;
|
||||
uint8_t *mod_id, status;
|
||||
bool vnd;
|
||||
|
@ -742,13 +742,13 @@ send_status:
|
|||
status, mod_id);
|
||||
}
|
||||
|
||||
static int mod_pub_set(struct bt_mesh_model *model,
|
||||
static int mod_pub_set(const struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
uint8_t retransmit, status, pub_ttl, pub_period, cred_flag;
|
||||
uint16_t elem_addr, pub_addr, pub_app_idx;
|
||||
struct bt_mesh_model *mod;
|
||||
const struct bt_mesh_model *mod;
|
||||
struct bt_mesh_elem *elem;
|
||||
uint8_t *mod_id;
|
||||
bool vnd;
|
||||
|
@ -807,7 +807,7 @@ send_status:
|
|||
status, mod_id);
|
||||
}
|
||||
|
||||
static size_t mod_sub_list_clear(struct bt_mesh_model *mod)
|
||||
static size_t mod_sub_list_clear(const struct bt_mesh_model *mod)
|
||||
{
|
||||
size_t clear_count;
|
||||
int i;
|
||||
|
@ -838,7 +838,7 @@ static size_t mod_sub_list_clear(struct bt_mesh_model *mod)
|
|||
return clear_count;
|
||||
}
|
||||
|
||||
static int mod_pub_va_set(struct bt_mesh_model *model,
|
||||
static int mod_pub_va_set(const struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
|
@ -846,7 +846,7 @@ static int mod_pub_va_set(struct bt_mesh_model *model,
|
|||
uint8_t retransmit, status, pub_ttl, pub_period, cred_flag;
|
||||
uint16_t elem_addr, pub_app_idx;
|
||||
uint16_t pub_addr = 0U;
|
||||
struct bt_mesh_model *mod;
|
||||
const struct bt_mesh_model *mod;
|
||||
struct bt_mesh_elem *elem;
|
||||
const uint8_t *uuid;
|
||||
uint8_t *mod_id;
|
||||
|
@ -915,7 +915,7 @@ send_status:
|
|||
status, mod_id);
|
||||
}
|
||||
|
||||
static int send_mod_sub_status(struct bt_mesh_model *model,
|
||||
static int send_mod_sub_status(const struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx, uint8_t status,
|
||||
uint16_t elem_addr, uint16_t sub_addr, uint8_t *mod_id,
|
||||
bool vnd)
|
||||
|
@ -943,12 +943,12 @@ static int send_mod_sub_status(struct bt_mesh_model *model,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int mod_sub_add(struct bt_mesh_model *model,
|
||||
static int mod_sub_add(const struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
uint16_t elem_addr, sub_addr;
|
||||
struct bt_mesh_model *mod;
|
||||
const struct bt_mesh_model *mod;
|
||||
struct bt_mesh_elem *elem;
|
||||
uint8_t *mod_id;
|
||||
uint8_t status;
|
||||
|
@ -1021,12 +1021,12 @@ send_status:
|
|||
mod_id, vnd);
|
||||
}
|
||||
|
||||
static int mod_sub_del(struct bt_mesh_model *model,
|
||||
static int mod_sub_del(const struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
uint16_t elem_addr, sub_addr;
|
||||
struct bt_mesh_model *mod;
|
||||
const struct bt_mesh_model *mod;
|
||||
struct bt_mesh_elem *elem;
|
||||
uint8_t *mod_id;
|
||||
uint16_t *match;
|
||||
|
@ -1092,7 +1092,7 @@ send_status:
|
|||
mod_id, vnd);
|
||||
}
|
||||
|
||||
static enum bt_mesh_walk mod_sub_clear_visitor(struct bt_mesh_model *mod, void *user_data)
|
||||
static enum bt_mesh_walk mod_sub_clear_visitor(const struct bt_mesh_model *mod, void *user_data)
|
||||
{
|
||||
if (IS_ENABLED(CONFIG_BT_MESH_LOW_POWER)) {
|
||||
bt_mesh_lpn_group_del(mod->groups, mod->groups_cnt);
|
||||
|
@ -1103,12 +1103,12 @@ static enum bt_mesh_walk mod_sub_clear_visitor(struct bt_mesh_model *mod, void *
|
|||
return BT_MESH_WALK_CONTINUE;
|
||||
}
|
||||
|
||||
static int mod_sub_overwrite(struct bt_mesh_model *model,
|
||||
static int mod_sub_overwrite(const struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
uint16_t elem_addr, sub_addr;
|
||||
struct bt_mesh_model *mod;
|
||||
const struct bt_mesh_model *mod;
|
||||
struct bt_mesh_elem *elem;
|
||||
uint8_t *mod_id;
|
||||
uint8_t status;
|
||||
|
@ -1174,11 +1174,11 @@ send_status:
|
|||
mod_id, vnd);
|
||||
}
|
||||
|
||||
static int mod_sub_del_all(struct bt_mesh_model *model,
|
||||
static int mod_sub_del_all(const struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
struct bt_mesh_model *mod;
|
||||
const struct bt_mesh_model *mod;
|
||||
struct bt_mesh_elem *elem;
|
||||
uint16_t elem_addr;
|
||||
uint8_t *mod_id;
|
||||
|
@ -1232,13 +1232,13 @@ struct mod_sub_list_ctx {
|
|||
struct net_buf_simple *msg;
|
||||
};
|
||||
|
||||
static enum bt_mesh_walk mod_sub_list_visitor(struct bt_mesh_model *mod, void *ctx)
|
||||
static enum bt_mesh_walk mod_sub_list_visitor(const struct bt_mesh_model *mod, void *ctx)
|
||||
{
|
||||
struct mod_sub_list_ctx *visit = ctx;
|
||||
int count = 0;
|
||||
int i;
|
||||
|
||||
if (mod->elem_idx != visit->elem_idx) {
|
||||
if (*(mod->elem_idx) != visit->elem_idx) {
|
||||
return BT_MESH_WALK_CONTINUE;
|
||||
}
|
||||
|
||||
|
@ -1257,18 +1257,18 @@ static enum bt_mesh_walk mod_sub_list_visitor(struct bt_mesh_model *mod, void *c
|
|||
count++;
|
||||
}
|
||||
|
||||
LOG_DBG("sublist: model %u:%x: %u groups", mod->elem_idx, mod->id, count);
|
||||
LOG_DBG("sublist: model %u:%x: %u groups", *(mod->elem_idx), mod->id, count);
|
||||
|
||||
return BT_MESH_WALK_CONTINUE;
|
||||
}
|
||||
|
||||
static int mod_sub_get(struct bt_mesh_model *model,
|
||||
static int mod_sub_get(const struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
NET_BUF_SIMPLE_DEFINE(msg, BT_MESH_TX_SDU_MAX);
|
||||
struct mod_sub_list_ctx visit_ctx;
|
||||
struct bt_mesh_model *mod;
|
||||
const struct bt_mesh_model *mod;
|
||||
struct bt_mesh_elem *elem;
|
||||
uint16_t addr, id;
|
||||
|
||||
|
@ -1306,7 +1306,7 @@ static int mod_sub_get(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->elem_idx);
|
||||
bt_mesh_model_extensions_walk(mod, mod_sub_list_visitor, &visit_ctx);
|
||||
|
||||
send_list:
|
||||
|
@ -1317,13 +1317,13 @@ send_list:
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int mod_sub_get_vnd(struct bt_mesh_model *model,
|
||||
static int mod_sub_get_vnd(const struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
NET_BUF_SIMPLE_DEFINE(msg, BT_MESH_TX_SDU_MAX);
|
||||
struct mod_sub_list_ctx visit_ctx;
|
||||
struct bt_mesh_model *mod;
|
||||
const struct bt_mesh_model *mod;
|
||||
struct bt_mesh_elem *elem;
|
||||
uint16_t company, addr, id;
|
||||
|
||||
|
@ -1365,7 +1365,7 @@ static int mod_sub_get_vnd(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->elem_idx);
|
||||
bt_mesh_model_extensions_walk(mod, mod_sub_list_visitor, &visit_ctx);
|
||||
|
||||
send_list:
|
||||
|
@ -1376,13 +1376,13 @@ send_list:
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int mod_sub_va_add(struct bt_mesh_model *model,
|
||||
static int mod_sub_va_add(const struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
const struct bt_mesh_va *va;
|
||||
uint16_t elem_addr, sub_addr = BT_MESH_ADDR_UNASSIGNED;
|
||||
struct bt_mesh_model *mod;
|
||||
const struct bt_mesh_model *mod;
|
||||
struct bt_mesh_elem *elem;
|
||||
const uint8_t *uuid;
|
||||
uint8_t *mod_id;
|
||||
|
@ -1478,13 +1478,13 @@ send_status:
|
|||
mod_id, vnd);
|
||||
}
|
||||
|
||||
static int mod_sub_va_del(struct bt_mesh_model *model,
|
||||
static int mod_sub_va_del(const struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
const struct bt_mesh_va *va;
|
||||
uint16_t elem_addr, sub_addr = BT_MESH_ADDR_UNASSIGNED;
|
||||
struct bt_mesh_model *mod;
|
||||
const struct bt_mesh_model *mod;
|
||||
struct bt_mesh_elem *elem;
|
||||
const uint8_t *uuid;
|
||||
uint8_t *mod_id;
|
||||
|
@ -1562,13 +1562,13 @@ send_status:
|
|||
mod_id, vnd);
|
||||
}
|
||||
|
||||
static int mod_sub_va_overwrite(struct bt_mesh_model *model,
|
||||
static int mod_sub_va_overwrite(const struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
const struct bt_mesh_va *va;
|
||||
uint16_t elem_addr, sub_addr = BT_MESH_ADDR_UNASSIGNED;
|
||||
struct bt_mesh_model *mod;
|
||||
const struct bt_mesh_model *mod;
|
||||
struct bt_mesh_elem *elem;
|
||||
const uint8_t *uuid;
|
||||
uint8_t *mod_id;
|
||||
|
@ -1638,7 +1638,7 @@ send_status:
|
|||
mod_id, vnd);
|
||||
}
|
||||
|
||||
static int send_net_key_status(struct bt_mesh_model *model,
|
||||
static int send_net_key_status(const struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx, uint16_t idx,
|
||||
uint8_t status)
|
||||
{
|
||||
|
@ -1656,7 +1656,7 @@ static int send_net_key_status(struct bt_mesh_model *model,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int net_key_add(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx,
|
||||
static int net_key_add(const struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
uint8_t status;
|
||||
|
@ -1675,7 +1675,7 @@ static int net_key_add(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx,
|
|||
return send_net_key_status(model, ctx, idx, status);
|
||||
}
|
||||
|
||||
static int net_key_update(struct bt_mesh_model *model,
|
||||
static int net_key_update(const struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
|
@ -1693,7 +1693,7 @@ static int net_key_update(struct bt_mesh_model *model,
|
|||
return send_net_key_status(model, ctx, idx, status);
|
||||
}
|
||||
|
||||
static int net_key_del(struct bt_mesh_model *model,
|
||||
static int net_key_del(const struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
|
@ -1720,7 +1720,7 @@ static int net_key_del(struct bt_mesh_model *model,
|
|||
return send_net_key_status(model, ctx, del_idx, STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
static int net_key_get(struct bt_mesh_model *model,
|
||||
static int net_key_get(const struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
|
@ -1745,7 +1745,7 @@ static int net_key_get(struct bt_mesh_model *model,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int send_node_id_status(struct bt_mesh_model *model,
|
||||
static int send_node_id_status(const struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
uint8_t status,
|
||||
uint16_t net_idx, uint8_t node_id)
|
||||
|
@ -1764,7 +1764,7 @@ static int send_node_id_status(struct bt_mesh_model *model,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int node_identity_get(struct bt_mesh_model *model,
|
||||
static int node_identity_get(const struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
|
@ -1786,7 +1786,7 @@ static int node_identity_get(struct bt_mesh_model *model,
|
|||
return send_node_id_status(model, ctx, status, idx, node_id);
|
||||
}
|
||||
|
||||
static int node_identity_set(struct bt_mesh_model *model,
|
||||
static int node_identity_set(const struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
|
@ -1824,7 +1824,7 @@ static int node_identity_set(struct bt_mesh_model *model,
|
|||
}
|
||||
|
||||
static void create_mod_app_status(struct net_buf_simple *msg,
|
||||
struct bt_mesh_model *mod, bool vnd,
|
||||
const struct bt_mesh_model *mod, bool vnd,
|
||||
uint16_t elem_addr, uint16_t app_idx,
|
||||
uint8_t status, uint8_t *mod_id)
|
||||
{
|
||||
|
@ -1841,13 +1841,13 @@ static void create_mod_app_status(struct net_buf_simple *msg,
|
|||
}
|
||||
}
|
||||
|
||||
static int mod_app_bind(struct bt_mesh_model *model,
|
||||
static int mod_app_bind(const struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
BT_MESH_MODEL_BUF_DEFINE(msg, OP_MOD_APP_STATUS, 9);
|
||||
uint16_t elem_addr, key_app_idx;
|
||||
struct bt_mesh_model *mod;
|
||||
const struct bt_mesh_model *mod;
|
||||
struct bt_mesh_elem *elem;
|
||||
uint8_t *mod_id, status;
|
||||
bool vnd;
|
||||
|
@ -1881,7 +1881,7 @@ static int mod_app_bind(struct bt_mesh_model *model,
|
|||
}
|
||||
|
||||
/* Some models only allow device key based access */
|
||||
if (mod->flags & BT_MESH_MOD_DEVKEY_ONLY) {
|
||||
if (*(mod->flags) & BT_MESH_MOD_DEVKEY_ONLY) {
|
||||
LOG_ERR("Client tried to bind AppKey to DevKey based model");
|
||||
status = STATUS_CANNOT_BIND;
|
||||
goto send_status;
|
||||
|
@ -1905,13 +1905,13 @@ send_status:
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int mod_app_unbind(struct bt_mesh_model *model,
|
||||
static int mod_app_unbind(const struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
BT_MESH_MODEL_BUF_DEFINE(msg, OP_MOD_APP_STATUS, 9);
|
||||
uint16_t elem_addr, key_app_idx;
|
||||
struct bt_mesh_model *mod;
|
||||
const struct bt_mesh_model *mod;
|
||||
struct bt_mesh_elem *elem;
|
||||
uint8_t *mod_id, status;
|
||||
bool vnd;
|
||||
|
@ -1964,7 +1964,7 @@ send_status:
|
|||
|
||||
#define KEY_LIST_LEN (CONFIG_BT_MESH_MODEL_KEY_COUNT * 2)
|
||||
|
||||
static int mod_app_get(struct bt_mesh_model *model,
|
||||
static int mod_app_get(const struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
|
@ -1973,7 +1973,7 @@ static int mod_app_get(struct bt_mesh_model *model,
|
|||
9 + KEY_LIST_LEN),
|
||||
BT_MESH_MODEL_BUF_LEN(OP_SIG_MOD_APP_LIST,
|
||||
9 + KEY_LIST_LEN)));
|
||||
struct bt_mesh_model *mod;
|
||||
const struct bt_mesh_model *mod;
|
||||
struct bt_mesh_elem *elem;
|
||||
uint8_t *mod_id, status;
|
||||
uint16_t elem_addr;
|
||||
|
@ -2050,7 +2050,7 @@ static void reset_send_end(int err, void *cb_data)
|
|||
k_work_submit(&node_reset_pending);
|
||||
}
|
||||
|
||||
static int node_reset(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx,
|
||||
static int node_reset(const struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
static const struct bt_mesh_send_cb reset_cb = {
|
||||
|
@ -2072,7 +2072,7 @@ static int node_reset(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int send_friend_status(struct bt_mesh_model *model,
|
||||
static int send_friend_status(const struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx)
|
||||
{
|
||||
BT_MESH_MODEL_BUF_DEFINE(msg, OP_FRIEND_STATUS, 1);
|
||||
|
@ -2087,7 +2087,7 @@ static int send_friend_status(struct bt_mesh_model *model,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int friend_get(struct bt_mesh_model *model,
|
||||
static int friend_get(const struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
|
@ -2097,7 +2097,7 @@ static int friend_get(struct bt_mesh_model *model,
|
|||
return send_friend_status(model, ctx);
|
||||
}
|
||||
|
||||
static int friend_set(struct bt_mesh_model *model,
|
||||
static int friend_set(const struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
|
@ -2114,7 +2114,7 @@ static int friend_set(struct bt_mesh_model *model,
|
|||
return send_friend_status(model, ctx);
|
||||
}
|
||||
|
||||
static int lpn_timeout_get(struct bt_mesh_model *model,
|
||||
static int lpn_timeout_get(const struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
|
@ -2160,7 +2160,7 @@ send_rsp:
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int send_krp_status(struct bt_mesh_model *model,
|
||||
static int send_krp_status(const struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx, uint16_t idx,
|
||||
uint8_t phase, uint8_t status)
|
||||
{
|
||||
|
@ -2179,7 +2179,7 @@ static int send_krp_status(struct bt_mesh_model *model,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int krp_get(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx,
|
||||
static int krp_get(const struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
uint8_t kr_phase, status;
|
||||
|
@ -2198,7 +2198,7 @@ static int krp_get(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx,
|
|||
return send_krp_status(model, ctx, idx, kr_phase, status);
|
||||
}
|
||||
|
||||
static int krp_set(struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx,
|
||||
static int krp_set(const struct bt_mesh_model *model, struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
uint8_t phase, status;
|
||||
|
@ -2254,7 +2254,7 @@ struct hb_pub_param {
|
|||
uint16_t net_idx;
|
||||
} __packed;
|
||||
|
||||
static int hb_pub_send_status(struct bt_mesh_model *model,
|
||||
static int hb_pub_send_status(const struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx, uint8_t status,
|
||||
const struct bt_mesh_hb_pub *pub)
|
||||
{
|
||||
|
@ -2284,7 +2284,7 @@ static int hb_pub_send_status(struct bt_mesh_model *model,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int heartbeat_pub_get(struct bt_mesh_model *model,
|
||||
static int heartbeat_pub_get(const struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
|
@ -2297,7 +2297,7 @@ static int heartbeat_pub_get(struct bt_mesh_model *model,
|
|||
return hb_pub_send_status(model, ctx, STATUS_SUCCESS, &pub);
|
||||
}
|
||||
|
||||
static int heartbeat_pub_set(struct bt_mesh_model *model,
|
||||
static int heartbeat_pub_set(const struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
|
@ -2357,7 +2357,7 @@ rsp:
|
|||
return hb_pub_send_status(model, ctx, status, &pub);
|
||||
}
|
||||
|
||||
static int hb_sub_send_status(struct bt_mesh_model *model,
|
||||
static int hb_sub_send_status(const struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
const struct bt_mesh_hb_sub *sub)
|
||||
{
|
||||
|
@ -2382,7 +2382,7 @@ static int hb_sub_send_status(struct bt_mesh_model *model,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int heartbeat_sub_get(struct bt_mesh_model *model,
|
||||
static int heartbeat_sub_get(const struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
|
@ -2395,7 +2395,7 @@ static int heartbeat_sub_get(struct bt_mesh_model *model,
|
|||
return hb_sub_send_status(model, ctx, &sub);
|
||||
}
|
||||
|
||||
static int heartbeat_sub_set(struct bt_mesh_model *model,
|
||||
static int heartbeat_sub_set(const struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
|
@ -2508,7 +2508,7 @@ const struct bt_mesh_model_op bt_mesh_cfg_srv_op[] = {
|
|||
BT_MESH_MODEL_OP_END,
|
||||
};
|
||||
|
||||
static int cfg_srv_init(struct bt_mesh_model *model)
|
||||
static int cfg_srv_init(const struct bt_mesh_model *model)
|
||||
{
|
||||
if (!bt_mesh_model_in_primary(model)) {
|
||||
LOG_ERR("Configuration Server only allowed in primary element");
|
||||
|
@ -2520,7 +2520,7 @@ static int cfg_srv_init(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->flags) |= BT_MESH_MOD_DEVKEY_ONLY;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -2529,7 +2529,7 @@ const struct bt_mesh_model_cb bt_mesh_cfg_srv_cb = {
|
|||
.init = cfg_srv_init,
|
||||
};
|
||||
|
||||
static void mod_reset(struct bt_mesh_model *mod, struct bt_mesh_elem *elem,
|
||||
static void mod_reset(const struct bt_mesh_model *mod, struct bt_mesh_elem *elem,
|
||||
bool vnd, bool primary, void *user_data)
|
||||
{
|
||||
size_t clear_count;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue