ble_mesh: fix RPL storage timeout handling

This commit is contained in:
lly 2019-09-02 14:16:33 +08:00
parent 9a7efd30ef
commit c44a3f1209
2 changed files with 16 additions and 6 deletions

View File

@ -209,7 +209,7 @@ enum {
BLE_MESH_IVU_TEST, /* IV Update test mode */
BLE_MESH_IVU_PENDING, /* Update blocked by SDU in progress */
/* pending storage actions */
/* pending storage actions, must reside within first 32 flags */
BLE_MESH_RPL_PENDING,
BLE_MESH_KEYS_PENDING,
BLE_MESH_NET_PENDING,

View File

@ -833,19 +833,29 @@ int settings_core_commit(void)
return 0;
}
/* Pending flags that use K_NO_WAIT as the storage timeout */
#define NO_WAIT_PENDING_BITS (BIT(BLE_MESH_NET_PENDING) | \
BIT(BLE_MESH_IV_PENDING) | \
BIT(BLE_MESH_SEQ_PENDING))
/* Pending flags that use CONFIG_BLE_MESH_STORE_TIMEOUT */
#define GENERIC_PENDING_BITS (BIT(BLE_MESH_KEYS_PENDING) | \
BIT(BLE_MESH_HB_PUB_PENDING) | \
BIT(BLE_MESH_CFG_PENDING) | \
BIT(BLE_MESH_MOD_PENDING))
static void schedule_store(int flag)
{
s32_t timeout;
bt_mesh_atomic_set_bit(bt_mesh.flags, flag);
if (bt_mesh_atomic_test_bit(bt_mesh.flags, BLE_MESH_NET_PENDING) ||
bt_mesh_atomic_test_bit(bt_mesh.flags, BLE_MESH_IV_PENDING) ||
bt_mesh_atomic_test_bit(bt_mesh.flags, BLE_MESH_SEQ_PENDING)) {
if (bt_mesh_atomic_get(bt_mesh.flags) & NO_WAIT_PENDING_BITS) {
timeout = K_NO_WAIT;
} else if (bt_mesh_atomic_test_bit(bt_mesh.flags, BLE_MESH_RPL_PENDING) &&
(CONFIG_BLE_MESH_RPL_STORE_TIMEOUT <
CONFIG_BLE_MESH_STORE_TIMEOUT)) {
(!(bt_mesh_atomic_get(bt_mesh.flags) & GENERIC_PENDING_BITS) ||
(CONFIG_BLE_MESH_RPL_STORE_TIMEOUT <
CONFIG_BLE_MESH_STORE_TIMEOUT))) {
timeout = K_SECONDS(CONFIG_BLE_MESH_RPL_STORE_TIMEOUT);
} else {
timeout = K_SECONDS(CONFIG_BLE_MESH_STORE_TIMEOUT);