Commit cd294c12 authored by Pavel Vasilyev's avatar Pavel Vasilyev Committed by Christopher Friedt
Browse files

tests: Bluetooth: Mesh: Verify that all stored mesh entries removed



This ensures that all mesh settings were removed from persistent storage
after node reset.

Signed-off-by: default avatarPavel Vasilyev <pavel.vasilyev@nordicsemi.no>
parent f82086ff
Loading
Loading
Loading
Loading
+15 −5
Original line number Diff line number Diff line
@@ -1066,6 +1066,7 @@ void bt_mesh_net_pending_seq_store(void)
	struct seq_val seq;
	int err;

	if (atomic_test_bit(bt_mesh.flags, BT_MESH_VALID)) {
		sys_put_le24(bt_mesh.seq, seq.val);

		err = settings_save_one("bt/mesh/Seq", &seq, sizeof(seq));
@@ -1074,6 +1075,14 @@ void bt_mesh_net_pending_seq_store(void)
		} else {
			BT_DBG("Stored Seq value");
		}
	} else {
		err = settings_delete("bt/mesh/Seq");
		if (err) {
			BT_ERR("Failed to clear Seq value");
		} else {
			BT_DBG("Cleared Seq value");
		}
	}
}

void bt_mesh_net_clear(void)
@@ -1081,6 +1090,7 @@ void bt_mesh_net_clear(void)
	bt_mesh_settings_store_schedule(BT_MESH_SETTINGS_NET_PENDING);
	bt_mesh_settings_store_schedule(BT_MESH_SETTINGS_IV_PENDING);
	bt_mesh_settings_store_schedule(BT_MESH_SETTINGS_CFG_PENDING);
	bt_mesh_settings_store_schedule(BT_MESH_SETTINGS_SEQ_PENDING);
}

void bt_mesh_net_settings_commit(void)
+5 −0
Original line number Diff line number Diff line
@@ -47,7 +47,12 @@ CONFIG_BT_MESH_PROVISIONER=y
CONFIG_BT_MESH_PROV_DEVICE=y
CONFIG_BT_MESH_CDB=y
CONFIG_BT_MESH_CDB_NODE_COUNT=3
CONFIG_BT_MESH_CDB_SUBNET_COUNT=2
CONFIG_BT_MESH_SUBNET_COUNT=2
CONFIG_BT_MESH_GATT_PROXY=y
CONFIG_BT_MESH_TX_SEG_RETRANS_COUNT=1
CONFIG_BT_MESH_SEQ_STORE_RATE=1
CONFIG_BT_MESH_RPL_STORE_TIMEOUT=1
CONFIG_BT_MESH_STORE_TIMEOUT=1

CONFIG_BT_MESH_DEBUG=y
+18 −16
Original line number Diff line number Diff line
@@ -155,6 +155,7 @@ static int settings_custom_save(struct settings_store *cs, const char *name,
		}
	}

	if (val_len) {
		char bufvname[ENTRY_NAME_MAX_LEN + ENTRY_LEN_SIZE + 3];

		snprintk(bufvname, sizeof(bufvname), "%s=", name);
@@ -177,6 +178,7 @@ static int settings_custom_save(struct settings_store *cs, const char *name,
		if (fputs(bufval, fnew != NULL ? fnew : fcur) < 0) {
			return -1;
		}
	}

	if (fnew != NULL) {
		entry_check_and_copy(fcur, fnew, name);
+14 −0
Original line number Diff line number Diff line
@@ -900,6 +900,14 @@ static void test_cfg_load(void)
	PASS();
}

static int mesh_settings_load_cb(const char *key, size_t len, settings_read_cb read_cb,
				 void *cb_arg, void *param)
{
	ASSERT_TRUE(len == 0);

	return 0;
}

/** @brief Test reprovisioning with persistent storage, device side.
 *
 * Wait for being provisioned and configured, then wait for the node reset and store settings.
@@ -926,6 +934,9 @@ static void test_reprovisioning_device(void)

	k_sleep(K_SECONDS(CONFIG_BT_MESH_STORE_TIMEOUT));

	/* Check that all mesh settings were removed. */
	settings_load_subtree_direct("bt/mesh", mesh_settings_load_cb, NULL);

	PASS();
}

@@ -960,6 +971,9 @@ static void test_reprovisioning_provisioner(void)
		FAIL("Reset failed (err %d, status: %d)", err, status);
	}

	/* Let the remote device store configuration. */
	k_sleep(K_SECONDS(CONFIG_BT_MESH_STORE_TIMEOUT * 2));

	PASS();
}