Bluetooth: Mesh: Move storing of new prov data to settings work item
This allows to move flash operations from the context that triggered bt_mesh_provision or bt_mesh_reprovision to the mesh settings work item that runs on the system workqueue. This is required to for a case where the mesh settings work item is running on a separate thread instead of the system workqueue to unblock the system workqueue eventually. Signed-off-by: Pavel Vasilyev <pavel.vasilyev@nordicsemi.no>
This commit is contained in:
parent
e1d7b0a0ca
commit
f3085ab95d
7 changed files with 39 additions and 13 deletions
|
@ -1905,7 +1905,7 @@ int bt_mesh_comp_change_prepare(void)
|
||||||
return bt_mesh_comp_store();
|
return bt_mesh_comp_store();
|
||||||
}
|
}
|
||||||
|
|
||||||
void bt_mesh_comp_clear(void)
|
static void comp_data_clear(void)
|
||||||
{
|
{
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
|
@ -2073,7 +2073,7 @@ int bt_mesh_models_metadata_read(struct net_buf_simple *buf, size_t offset)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void bt_mesh_models_metadata_clear(void)
|
static void models_metadata_clear(void)
|
||||||
{
|
{
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
|
@ -2087,6 +2087,17 @@ void bt_mesh_models_metadata_clear(void)
|
||||||
atomic_clear_bit(bt_mesh.flags, BT_MESH_METADATA_DIRTY);
|
atomic_clear_bit(bt_mesh.flags, BT_MESH_METADATA_DIRTY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void bt_mesh_comp_data_pending_clear(void)
|
||||||
|
{
|
||||||
|
comp_data_clear();
|
||||||
|
models_metadata_clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void bt_mesh_comp_data_clear(void)
|
||||||
|
{
|
||||||
|
bt_mesh_settings_store_schedule(BT_MESH_SETTINGS_COMP_PENDING);
|
||||||
|
}
|
||||||
|
|
||||||
int bt_mesh_models_metadata_change_prepare(void)
|
int bt_mesh_models_metadata_change_prepare(void)
|
||||||
{
|
{
|
||||||
#if !IS_ENABLED(CONFIG_BT_MESH_LARGE_COMP_DATA_SRV)
|
#if !IS_ENABLED(CONFIG_BT_MESH_LARGE_COMP_DATA_SRV)
|
||||||
|
|
|
@ -62,13 +62,14 @@ int bt_mesh_model_recv(struct bt_mesh_msg_ctx *ctx, struct net_buf_simple *buf);
|
||||||
|
|
||||||
int bt_mesh_comp_register(const struct bt_mesh_comp *comp);
|
int bt_mesh_comp_register(const struct bt_mesh_comp *comp);
|
||||||
int bt_mesh_comp_store(void);
|
int bt_mesh_comp_store(void);
|
||||||
void bt_mesh_comp_clear(void);
|
|
||||||
int bt_mesh_comp_read(struct net_buf_simple *buf);
|
int bt_mesh_comp_read(struct net_buf_simple *buf);
|
||||||
|
|
||||||
int bt_mesh_models_metadata_store(void);
|
int bt_mesh_models_metadata_store(void);
|
||||||
void bt_mesh_models_metadata_clear(void);
|
|
||||||
int bt_mesh_models_metadata_read(struct net_buf_simple *buf, size_t offset);
|
int bt_mesh_models_metadata_read(struct net_buf_simple *buf, size_t offset);
|
||||||
|
|
||||||
|
void bt_mesh_comp_data_pending_clear(void);
|
||||||
|
void bt_mesh_comp_data_clear(void);
|
||||||
|
|
||||||
void bt_mesh_model_pending_store(void);
|
void bt_mesh_model_pending_store(void);
|
||||||
void bt_mesh_model_bind_store(struct bt_mesh_model *mod);
|
void bt_mesh_model_bind_store(struct bt_mesh_model *mod);
|
||||||
void bt_mesh_model_sub_store(struct bt_mesh_model *mod);
|
void bt_mesh_model_sub_store(struct bt_mesh_model *mod);
|
||||||
|
|
|
@ -130,7 +130,7 @@ int bt_mesh_provision(const uint8_t net_key[16], uint16_t net_idx,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IS_ENABLED(CONFIG_BT_SETTINGS)) {
|
if (IS_ENABLED(CONFIG_BT_SETTINGS)) {
|
||||||
bt_mesh_net_pending_net_store();
|
bt_mesh_net_store();
|
||||||
}
|
}
|
||||||
|
|
||||||
bt_mesh_start();
|
bt_mesh_start();
|
||||||
|
@ -159,10 +159,9 @@ void bt_mesh_reprovision(uint16_t addr)
|
||||||
|
|
||||||
if (IS_ENABLED(CONFIG_BT_SETTINGS)) {
|
if (IS_ENABLED(CONFIG_BT_SETTINGS)) {
|
||||||
LOG_DBG("Storing network information persistently");
|
LOG_DBG("Storing network information persistently");
|
||||||
bt_mesh_net_pending_net_store();
|
bt_mesh_net_store();
|
||||||
bt_mesh_net_pending_seq_store();
|
bt_mesh_net_seq_store(true);
|
||||||
bt_mesh_comp_clear();
|
bt_mesh_comp_data_clear();
|
||||||
bt_mesh_models_metadata_clear();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -189,9 +189,10 @@ static void store_iv(bool only_duration)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void store_seq(void)
|
void bt_mesh_net_seq_store(bool force)
|
||||||
{
|
{
|
||||||
if (CONFIG_BT_MESH_SEQ_STORE_RATE > 1 &&
|
if (!force &&
|
||||||
|
CONFIG_BT_MESH_SEQ_STORE_RATE > 1 &&
|
||||||
(bt_mesh.seq % CONFIG_BT_MESH_SEQ_STORE_RATE)) {
|
(bt_mesh.seq % CONFIG_BT_MESH_SEQ_STORE_RATE)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -379,7 +380,7 @@ uint32_t bt_mesh_next_seq(void)
|
||||||
uint32_t seq = bt_mesh.seq++;
|
uint32_t seq = bt_mesh.seq++;
|
||||||
|
|
||||||
if (IS_ENABLED(CONFIG_BT_SETTINGS)) {
|
if (IS_ENABLED(CONFIG_BT_SETTINGS)) {
|
||||||
store_seq();
|
bt_mesh_net_seq_store(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!atomic_test_bit(bt_mesh.flags, BT_MESH_IVU_IN_PROGRESS) &&
|
if (!atomic_test_bit(bt_mesh.flags, BT_MESH_IVU_IN_PROGRESS) &&
|
||||||
|
@ -1185,6 +1186,11 @@ void bt_mesh_net_pending_seq_store(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void bt_mesh_net_store(void)
|
||||||
|
{
|
||||||
|
bt_mesh_settings_store_schedule(BT_MESH_SETTINGS_NET_PENDING);
|
||||||
|
}
|
||||||
|
|
||||||
void bt_mesh_net_clear(void)
|
void bt_mesh_net_clear(void)
|
||||||
{
|
{
|
||||||
bt_mesh_settings_store_schedule(BT_MESH_SETTINGS_NET_PENDING);
|
bt_mesh_settings_store_schedule(BT_MESH_SETTINGS_NET_PENDING);
|
||||||
|
|
|
@ -303,6 +303,7 @@ void bt_mesh_net_recv(struct net_buf_simple *data, int8_t rssi,
|
||||||
void bt_mesh_net_loopback_clear(uint16_t net_idx);
|
void bt_mesh_net_loopback_clear(uint16_t net_idx);
|
||||||
|
|
||||||
uint32_t bt_mesh_next_seq(void);
|
uint32_t bt_mesh_next_seq(void);
|
||||||
|
void bt_mesh_net_seq_store(bool force);
|
||||||
|
|
||||||
void bt_mesh_net_init(void);
|
void bt_mesh_net_init(void);
|
||||||
void bt_mesh_net_header_parse(struct net_buf_simple *buf,
|
void bt_mesh_net_header_parse(struct net_buf_simple *buf,
|
||||||
|
@ -312,6 +313,7 @@ void bt_mesh_net_pending_iv_store(void);
|
||||||
void bt_mesh_net_pending_seq_store(void);
|
void bt_mesh_net_pending_seq_store(void);
|
||||||
void bt_mesh_net_dev_key_cand_store(void);
|
void bt_mesh_net_dev_key_cand_store(void);
|
||||||
|
|
||||||
|
void bt_mesh_net_store(void);
|
||||||
void bt_mesh_net_clear(void);
|
void bt_mesh_net_clear(void);
|
||||||
void bt_mesh_net_settings_commit(void);
|
void bt_mesh_net_settings_commit(void);
|
||||||
|
|
||||||
|
|
|
@ -115,7 +115,8 @@ SETTINGS_STATIC_HANDLER_DEFINE(bt_mesh, "bt/mesh", NULL, NULL, mesh_commit,
|
||||||
BIT(BT_MESH_SETTINGS_CFG_PENDING) | \
|
BIT(BT_MESH_SETTINGS_CFG_PENDING) | \
|
||||||
BIT(BT_MESH_SETTINGS_MOD_PENDING) | \
|
BIT(BT_MESH_SETTINGS_MOD_PENDING) | \
|
||||||
BIT(BT_MESH_SETTINGS_VA_PENDING) | \
|
BIT(BT_MESH_SETTINGS_VA_PENDING) | \
|
||||||
BIT(BT_MESH_SETTINGS_SSEQ_PENDING))
|
BIT(BT_MESH_SETTINGS_SSEQ_PENDING) | \
|
||||||
|
BIT(BT_MESH_SETTINGS_COMP_PENDING))
|
||||||
|
|
||||||
void bt_mesh_settings_store_schedule(enum bt_mesh_settings_flag flag)
|
void bt_mesh_settings_store_schedule(enum bt_mesh_settings_flag flag)
|
||||||
{
|
{
|
||||||
|
@ -197,6 +198,11 @@ static void store_pending(struct k_work *work)
|
||||||
bt_mesh_cfg_pending_store();
|
bt_mesh_cfg_pending_store();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (atomic_test_and_clear_bit(pending_flags,
|
||||||
|
BT_MESH_SETTINGS_COMP_PENDING)) {
|
||||||
|
bt_mesh_comp_data_pending_clear();
|
||||||
|
}
|
||||||
|
|
||||||
if (atomic_test_and_clear_bit(pending_flags,
|
if (atomic_test_and_clear_bit(pending_flags,
|
||||||
BT_MESH_SETTINGS_MOD_PENDING)) {
|
BT_MESH_SETTINGS_MOD_PENDING)) {
|
||||||
bt_mesh_model_pending_store();
|
bt_mesh_model_pending_store();
|
||||||
|
|
|
@ -19,6 +19,7 @@ enum bt_mesh_settings_flag {
|
||||||
BT_MESH_SETTINGS_CDB_PENDING,
|
BT_MESH_SETTINGS_CDB_PENDING,
|
||||||
BT_MESH_SETTINGS_SRPL_PENDING,
|
BT_MESH_SETTINGS_SRPL_PENDING,
|
||||||
BT_MESH_SETTINGS_SSEQ_PENDING,
|
BT_MESH_SETTINGS_SSEQ_PENDING,
|
||||||
|
BT_MESH_SETTINGS_COMP_PENDING,
|
||||||
|
|
||||||
BT_MESH_SETTINGS_FLAG_COUNT,
|
BT_MESH_SETTINGS_FLAG_COUNT,
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue