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
|
@ -21,7 +21,7 @@ LOG_MODULE_REGISTER(bt_mesh_sar_cfg_cli);
|
|||
|
||||
static struct bt_mesh_sar_cfg_cli *cli;
|
||||
|
||||
static int transmitter_status(struct bt_mesh_model *model,
|
||||
static int transmitter_status(const struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
|
@ -45,7 +45,7 @@ static int transmitter_status(struct bt_mesh_model *model,
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int receiver_status(struct bt_mesh_model *model,
|
||||
static int receiver_status(const struct bt_mesh_model *model,
|
||||
struct bt_mesh_msg_ctx *ctx,
|
||||
struct net_buf_simple *buf)
|
||||
{
|
||||
|
@ -87,35 +87,35 @@ void bt_mesh_sar_cfg_cli_timeout_set(int32_t timeout)
|
|||
cli->timeout = timeout;
|
||||
}
|
||||
|
||||
static int bt_mesh_sar_cfg_cli_init(struct bt_mesh_model *model)
|
||||
static int bt_mesh_sar_cfg_cli_init(const struct bt_mesh_model *model)
|
||||
{
|
||||
if (!bt_mesh_model_in_primary(model)) {
|
||||
LOG_ERR("SAR Configuration Client only allowed in primary element");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (!model->user_data) {
|
||||
if (!*(model->user_data)) {
|
||||
LOG_ERR("No SAR Configuration Client context provided");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
cli = model->user_data;
|
||||
cli = *(model->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->flags) |= BT_MESH_MOD_DEVKEY_ONLY;
|
||||
|
||||
bt_mesh_msg_ack_ctx_init(&cli->ack_ctx);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void bt_mesh_sar_cfg_cli_reset(struct bt_mesh_model *model)
|
||||
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->user_data);
|
||||
|
||||
bt_mesh_msg_ack_ctx_clear(&model_cli->ack_ctx);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue