ble_mesh: fix postponing storage deadline indefinitely
@@ -846,7 +846,7 @@ int settings_core_commit(void)
static void schedule_store(int flag)
{
- s32_t timeout;
+ s32_t timeout, remaining;
bt_mesh_atomic_set_bit(bt_mesh.flags, flag);
@@ -861,6 +861,12 @@ static void schedule_store(int flag)
timeout = K_SECONDS(CONFIG_BLE_MESH_STORE_TIMEOUT);
}
+ remaining = k_delayed_work_remaining_get(&pending_store);
+ if (remaining && remaining < timeout) {
+ BT_DBG("Not rescheduling due to existing earlier deadline");
+ return;
+ }
+
BT_DBG("Waiting %d seconds", timeout / MSEC_PER_SEC);
if (timeout) {
