Bluetooth: Mesh: Store device key candidate asynchronously
This allows to move flash operations from the context that triggered storing device key candidate 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
f3085ab95d
commit
1113c2efd4
4 changed files with 19 additions and 3 deletions
|
@ -1066,9 +1066,11 @@ static int dev_key_cand_set(const char *name, size_t len_rd, settings_read_cb re
|
|||
}
|
||||
|
||||
BT_MESH_SETTINGS_DEFINE(dev_key, "DevKeyC", dev_key_cand_set);
|
||||
#endif
|
||||
|
||||
void bt_mesh_net_dev_key_cand_store(void)
|
||||
void bt_mesh_net_pending_dev_key_cand_store(void)
|
||||
{
|
||||
#if defined(CONFIG_BT_MESH_RPR_SRV)
|
||||
int err;
|
||||
|
||||
if (atomic_test_bit(bt_mesh.flags, BT_MESH_DEVKEY_CAND)) {
|
||||
|
@ -1082,8 +1084,13 @@ void bt_mesh_net_dev_key_cand_store(void)
|
|||
} else {
|
||||
LOG_DBG("Stored DevKey candidate value");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void bt_mesh_net_dev_key_cand_store(void)
|
||||
{
|
||||
bt_mesh_settings_store_schedule(BT_MESH_SETTINGS_DEV_KEY_CAND_PENDING);
|
||||
}
|
||||
|
||||
static void clear_iv(void)
|
||||
{
|
||||
|
|
|
@ -311,6 +311,8 @@ void bt_mesh_net_header_parse(struct net_buf_simple *buf,
|
|||
void bt_mesh_net_pending_net_store(void);
|
||||
void bt_mesh_net_pending_iv_store(void);
|
||||
void bt_mesh_net_pending_seq_store(void);
|
||||
|
||||
void bt_mesh_net_pending_dev_key_cand_store(void);
|
||||
void bt_mesh_net_dev_key_cand_store(void);
|
||||
|
||||
void bt_mesh_net_store(void);
|
||||
|
|
|
@ -116,7 +116,8 @@ SETTINGS_STATIC_HANDLER_DEFINE(bt_mesh, "bt/mesh", NULL, NULL, mesh_commit,
|
|||
BIT(BT_MESH_SETTINGS_MOD_PENDING) | \
|
||||
BIT(BT_MESH_SETTINGS_VA_PENDING) | \
|
||||
BIT(BT_MESH_SETTINGS_SSEQ_PENDING) | \
|
||||
BIT(BT_MESH_SETTINGS_COMP_PENDING))
|
||||
BIT(BT_MESH_SETTINGS_COMP_PENDING) | \
|
||||
BIT(BT_MESH_SETTINGS_DEV_KEY_CAND_PENDING))
|
||||
|
||||
void bt_mesh_settings_store_schedule(enum bt_mesh_settings_flag flag)
|
||||
{
|
||||
|
@ -188,6 +189,11 @@ static void store_pending(struct k_work *work)
|
|||
bt_mesh_net_pending_seq_store();
|
||||
}
|
||||
|
||||
if (atomic_test_and_clear_bit(pending_flags,
|
||||
BT_MESH_SETTINGS_DEV_KEY_CAND_PENDING)) {
|
||||
bt_mesh_net_pending_dev_key_cand_store();
|
||||
}
|
||||
|
||||
if (atomic_test_and_clear_bit(pending_flags,
|
||||
BT_MESH_SETTINGS_HB_PUB_PENDING)) {
|
||||
bt_mesh_hb_pub_pending_store();
|
||||
|
|
|
@ -20,6 +20,7 @@ enum bt_mesh_settings_flag {
|
|||
BT_MESH_SETTINGS_SRPL_PENDING,
|
||||
BT_MESH_SETTINGS_SSEQ_PENDING,
|
||||
BT_MESH_SETTINGS_COMP_PENDING,
|
||||
BT_MESH_SETTINGS_DEV_KEY_CAND_PENDING,
|
||||
|
||||
BT_MESH_SETTINGS_FLAG_COUNT,
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue