]> granicus.if.org Git - esp-idf/commitdiff
ble_mesh: fix RPL storage timeout handling
authorlly <lly@espressif.com>
Mon, 2 Sep 2019 06:16:33 +0000 (14:16 +0800)
committerlly <lly@espressif.com>
Mon, 9 Sep 2019 09:15:16 +0000 (17:15 +0800)
components/bt/esp_ble_mesh/mesh_core/net.h
components/bt/esp_ble_mesh/mesh_core/settings.c

index 90515fd2cabefa803f62e429edc8bbc56878bf6e..28cd91ce872bcf1934cb333deb33539529f653f9 100644 (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,
index adf63e50730afd2828958a4eb7e9047d8b82e4c4..0a6a8b9c25847f4e41f7f79cb0cf1cade544d951 100644 (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);