tests: Bluetooth: Mesh: Priv beacon pst test
Adds test for persistent storage in private beacon implementation. Signed-off-by: Anders Storrø <anders.storro@nordicsemi.no>
This commit is contained in:
parent
5b0a08d876
commit
893a239f85
2 changed files with 61 additions and 0 deletions
|
@ -166,6 +166,11 @@ static struct bt_mesh_model_pub health_pub = {
|
|||
static struct bt_mesh_sar_cfg_cli sar_cfg_cli;
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_BT_MESH_PRIV_BEACONS)
|
||||
static struct bt_mesh_priv_beacon_cli priv_beacon_cli;
|
||||
#endif
|
||||
|
||||
|
||||
static struct bt_mesh_model models[] = {
|
||||
BT_MESH_MODEL_CFG_SRV,
|
||||
BT_MESH_MODEL_CFG_CLI(&cfg_cli),
|
||||
|
@ -175,6 +180,10 @@ static struct bt_mesh_model models[] = {
|
|||
BT_MESH_MODEL_SAR_CFG_SRV,
|
||||
BT_MESH_MODEL_SAR_CFG_CLI(&sar_cfg_cli),
|
||||
#endif
|
||||
#if defined(CONFIG_BT_MESH_PRIV_BEACONS)
|
||||
BT_MESH_MODEL_PRIV_BEACON_SRV,
|
||||
BT_MESH_MODEL_PRIV_BEACON_CLI(&priv_beacon_cli),
|
||||
#endif
|
||||
};
|
||||
|
||||
struct bt_mesh_model *test_model = &models[2];
|
||||
|
|
|
@ -204,6 +204,11 @@ static const struct stack_cfg {
|
|||
enum bt_mesh_feat_state state;
|
||||
uint8_t transmit;
|
||||
} relay;
|
||||
#ifdef CONFIG_BT_MESH_PRIV_BEACONS
|
||||
uint8_t priv_beacon;
|
||||
uint8_t priv_beacon_int;
|
||||
uint8_t priv_beacon_gatt;
|
||||
#endif
|
||||
} stack_cfgs[] = {
|
||||
{
|
||||
.beacon = 1,
|
||||
|
@ -212,6 +217,11 @@ static const struct stack_cfg {
|
|||
.friend = 1,
|
||||
.net_transmit = BT_MESH_TRANSMIT(3, 20),
|
||||
.relay = { .state = BT_MESH_FEATURE_ENABLED, .transmit = BT_MESH_TRANSMIT(2, 20) },
|
||||
#ifdef CONFIG_BT_MESH_PRIV_BEACONS
|
||||
.priv_beacon = 1,
|
||||
.priv_beacon_int = 123,
|
||||
.priv_beacon_gatt = 0,
|
||||
#endif
|
||||
},
|
||||
{
|
||||
.beacon = 0,
|
||||
|
@ -220,6 +230,11 @@ static const struct stack_cfg {
|
|||
.friend = 0,
|
||||
.net_transmit = BT_MESH_TRANSMIT(1, 30),
|
||||
.relay = { .state = BT_MESH_FEATURE_ENABLED, .transmit = BT_MESH_TRANSMIT(1, 10) },
|
||||
#ifdef CONFIG_BT_MESH_PRIV_BEACONS
|
||||
.priv_beacon = 1,
|
||||
.priv_beacon_int = 100,
|
||||
.priv_beacon_gatt = 1,
|
||||
#endif
|
||||
},
|
||||
};
|
||||
static const struct stack_cfg *current_stack_cfg;
|
||||
|
@ -912,6 +927,25 @@ static void test_cfg_save(void)
|
|||
current_stack_cfg->relay.transmit);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_BT_MESH_PRIV_BEACONS
|
||||
struct bt_mesh_priv_beacon priv_beacon_state = {
|
||||
.enabled = current_stack_cfg->priv_beacon,
|
||||
.rand_interval = current_stack_cfg->priv_beacon_int,
|
||||
};
|
||||
|
||||
err = bt_mesh_priv_beacon_cli_set(test_netkey_idx, TEST_ADDR, &priv_beacon_state);
|
||||
if (err) {
|
||||
FAIL("Failed to enable Private Beacon (err %d)", err);
|
||||
}
|
||||
|
||||
uint8_t priv_beacon_gatt = current_stack_cfg->priv_beacon_gatt;
|
||||
|
||||
err = bt_mesh_priv_beacon_cli_gatt_proxy_set(test_netkey_idx, TEST_ADDR, &priv_beacon_gatt);
|
||||
if (err) {
|
||||
FAIL("Failed to enable Private Beacon GATT proxy (err %d)", err);
|
||||
}
|
||||
#endif
|
||||
|
||||
k_sleep(K_SECONDS(CONFIG_BT_MESH_STORE_TIMEOUT));
|
||||
|
||||
PASS();
|
||||
|
@ -963,6 +997,24 @@ static void test_cfg_load(void)
|
|||
FAIL("Relay get failed (err %d, state %u, transmit %x)", err, status, transmit);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_BT_MESH_PRIV_BEACONS
|
||||
struct bt_mesh_priv_beacon priv_beacon_state;
|
||||
uint8_t priv_beacon_gatt;
|
||||
|
||||
err = bt_mesh_priv_beacon_cli_get(test_netkey_idx, TEST_ADDR, &priv_beacon_state);
|
||||
if (err || priv_beacon_state.enabled != current_stack_cfg->priv_beacon ||
|
||||
priv_beacon_state.rand_interval != current_stack_cfg->priv_beacon_int) {
|
||||
FAIL("Private beacon get failed (err %d, enabled %u, interval %x)", err,
|
||||
priv_beacon_state.enabled, priv_beacon_state.rand_interval);
|
||||
}
|
||||
|
||||
err = bt_mesh_priv_beacon_cli_gatt_proxy_get(test_netkey_idx, TEST_ADDR, &priv_beacon_gatt);
|
||||
if (err || priv_beacon_gatt != current_stack_cfg->priv_beacon_gatt) {
|
||||
FAIL("Private beacon GATT proxy get failed (err %d, enabled %u)", err,
|
||||
priv_beacon_gatt);
|
||||
}
|
||||
#endif
|
||||
|
||||
PASS();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue