tests: Bluetooth: Mesh: OD priv proxy pst test

Adds test for persistent storage in On-Demand Private Proxy
implementation.

Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
This commit is contained in:
Anders Storrø 2023-09-06 13:06:40 +02:00 committed by Carles Cufí
commit cf8301d01e
3 changed files with 39 additions and 0 deletions

View file

@ -61,6 +61,8 @@ CONFIG_BT_MESH_DFD_SRV=y
CONFIG_BT_MESH_DFU_SLOT_CNT=3 CONFIG_BT_MESH_DFU_SLOT_CNT=3
CONFIG_BT_MESH_PRIV_BEACON_SRV=y CONFIG_BT_MESH_PRIV_BEACON_SRV=y
CONFIG_BT_MESH_PRIV_BEACON_CLI=y CONFIG_BT_MESH_PRIV_BEACON_CLI=y
CONFIG_BT_MESH_OD_PRIV_PROXY_SRV=y
CONFIG_BT_MESH_OD_PRIV_PROXY_CLI=y
CONFIG_BT_MESH_COMP_PAGE_1=y CONFIG_BT_MESH_COMP_PAGE_1=y
CONFIG_BT_MESH_COMP_PAGE_2=y CONFIG_BT_MESH_COMP_PAGE_2=y

View file

@ -170,6 +170,9 @@ static struct bt_mesh_sar_cfg_cli sar_cfg_cli;
static struct bt_mesh_priv_beacon_cli priv_beacon_cli; static struct bt_mesh_priv_beacon_cli priv_beacon_cli;
#endif #endif
#if defined(CONFIG_BT_MESH_OD_PRIV_PROXY_CLI)
static struct bt_mesh_od_priv_proxy_cli priv_proxy_cli;
#endif
static struct bt_mesh_model models[] = { static struct bt_mesh_model models[] = {
BT_MESH_MODEL_CFG_SRV, BT_MESH_MODEL_CFG_SRV,
@ -184,6 +187,12 @@ static struct bt_mesh_model models[] = {
BT_MESH_MODEL_PRIV_BEACON_SRV, BT_MESH_MODEL_PRIV_BEACON_SRV,
BT_MESH_MODEL_PRIV_BEACON_CLI(&priv_beacon_cli), BT_MESH_MODEL_PRIV_BEACON_CLI(&priv_beacon_cli),
#endif #endif
#if defined(CONFIG_BT_MESH_OD_PRIV_PROXY_SRV)
BT_MESH_MODEL_OD_PRIV_PROXY_SRV,
#endif
#if defined(CONFIG_BT_MESH_OD_PRIV_PROXY_CLI)
BT_MESH_MODEL_OD_PRIV_PROXY_CLI(&priv_proxy_cli),
#endif
}; };
struct bt_mesh_model *test_model = &models[2]; struct bt_mesh_model *test_model = &models[2];

View file

@ -209,6 +209,9 @@ static const struct stack_cfg {
uint8_t priv_beacon_int; uint8_t priv_beacon_int;
uint8_t priv_beacon_gatt; uint8_t priv_beacon_gatt;
#endif #endif
#ifdef CONFIG_BT_MESH_OD_PRIV_PROXY_SRV
uint8_t priv_proxy_val;
#endif
} stack_cfgs[] = { } stack_cfgs[] = {
{ {
.beacon = 1, .beacon = 1,
@ -221,6 +224,9 @@ static const struct stack_cfg {
.priv_beacon = 1, .priv_beacon = 1,
.priv_beacon_int = 123, .priv_beacon_int = 123,
.priv_beacon_gatt = 0, .priv_beacon_gatt = 0,
#endif
#ifdef CONFIG_BT_MESH_OD_PRIV_PROXY_SRV
.priv_proxy_val = 10,
#endif #endif
}, },
{ {
@ -234,6 +240,9 @@ static const struct stack_cfg {
.priv_beacon = 1, .priv_beacon = 1,
.priv_beacon_int = 100, .priv_beacon_int = 100,
.priv_beacon_gatt = 1, .priv_beacon_gatt = 1,
#endif
#ifdef CONFIG_BT_MESH_OD_PRIV_PROXY_SRV
.priv_proxy_val = 20,
#endif #endif
}, },
}; };
@ -946,6 +955,16 @@ static void test_cfg_save(void)
} }
#endif #endif
#if defined(CONFIG_BT_MESH_OD_PRIV_PROXY_SRV) && defined(CONFIG_BT_MESH_OD_PRIV_PROXY_CLI)
uint8_t priv_proxy_val;
err = bt_mesh_od_priv_proxy_cli_set(test_netkey_idx, TEST_ADDR,
current_stack_cfg->priv_proxy_val, &priv_proxy_val);
if (err || priv_proxy_val != current_stack_cfg->priv_proxy_val) {
FAIL("Failed to set OD Private proxy (err %d, value %d)", err, priv_proxy_val);
}
#endif
k_sleep(K_SECONDS(CONFIG_BT_MESH_STORE_TIMEOUT)); k_sleep(K_SECONDS(CONFIG_BT_MESH_STORE_TIMEOUT));
PASS(); PASS();
@ -1015,6 +1034,15 @@ static void test_cfg_load(void)
} }
#endif #endif
#if defined(CONFIG_BT_MESH_OD_PRIV_PROXY_SRV) && defined(CONFIG_BT_MESH_OD_PRIV_PROXY_CLI)
uint8_t priv_proxy_val;
err = bt_mesh_od_priv_proxy_cli_get(test_netkey_idx, TEST_ADDR, &priv_proxy_val);
if (err || priv_proxy_val != current_stack_cfg->priv_proxy_val) {
FAIL("Private proxy get failed (err %d, value %u)", err, priv_proxy_val);
}
#endif
PASS(); PASS();
} }