Skip to content

Commit fd818d7

Browse files
alxelaxkartben
authored andcommitted
tests: bluetooth: mesh: test lpn communication after friendship
Commit extends the communication test between the LPN and the third mesh device by checking that LPN and the third mesh device can exchange data normally after friendship termination. Signed-off-by: Aleksandr Khromykh <aleksandr.khromykh@nordicsemi.no>
1 parent 855639a commit fd818d7

File tree

4 files changed

+52
-8
lines changed

4 files changed

+52
-8
lines changed

tests/bsim/bluetooth/mesh/compile.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ app=tests/bsim/bluetooth/mesh conf_overlay=overlay_low_lat.conf compile
1818
app=tests/bsim/bluetooth/mesh conf_overlay=overlay_psa.conf compile
1919
app=tests/bsim/bluetooth/mesh conf_overlay=overlay_workq_sys.conf compile
2020
app=tests/bsim/bluetooth/mesh conf_overlay=overlay_multi_adv_sets.conf compile
21+
app=tests/bsim/bluetooth/mesh conf_overlay=overlay_lpn_scan_on.conf compile
2122
app=tests/bsim/bluetooth/mesh \
2223
conf_overlay="overlay_pst.conf;overlay_ss.conf;overlay_psa.conf" compile
2324
app=tests/bsim/bluetooth/mesh conf_overlay="overlay_gatt.conf;overlay_psa.conf" compile
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
CONFIG_BT_MESH_LPN_ESTABLISHMENT=n

tests/bsim/bluetooth/mesh/src/test_friendship.c

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -537,23 +537,23 @@ static void test_lpn_msg_mesh(void)
537537
bt_mesh_test_friendship_init(CONFIG_BT_MESH_FRIEND_LPN_COUNT);
538538
bt_mesh_lpn_set(true);
539539

540-
ASSERT_OK_MSG(bt_mesh_test_friendship_evt_wait(BT_MESH_TEST_LPN_ESTABLISHED,
541-
K_SECONDS(2)), "LPN not established");
540+
ASSERT_OK_MSG(bt_mesh_test_friendship_evt_wait(BT_MESH_TEST_LPN_ESTABLISHED, K_SECONDS(2)),
541+
"LPN did not establish friendship");
542542
/* LPN polls on establishment. Clear the poll state */
543543
bt_mesh_test_friendship_evt_clear(BT_MESH_TEST_LPN_POLLED);
544544

545545
/* Send an unsegmented message to a third mesh node.
546546
* Should not be affected by the LPN mode at all.
547547
*/
548548
ASSERT_OK_MSG(bt_mesh_test_send(other_cfg.addr, NULL, 5, 0, K_NO_WAIT),
549-
"Send to mesh failed");
549+
"Send to the third mesh node failed");
550550

551551
/* Receive an unsegmented message back */
552552
ASSERT_OK(bt_mesh_test_recv(5, cfg->addr, NULL, K_FOREVER));
553553

554554
/* Send a segmented message to the mesh node. */
555555
ASSERT_OK_MSG(bt_mesh_test_send(other_cfg.addr, NULL, 15, 0, K_FOREVER),
556-
"Send to other failed");
556+
"Send to the third mesh node failed");
557557

558558
/* Receive a segmented message back */
559559
ASSERT_OK(bt_mesh_test_recv(15, cfg->addr, NULL, K_FOREVER));
@@ -569,6 +569,25 @@ static void test_lpn_msg_mesh(void)
569569
bt_mesh_model_msg_init(test_model->pub->msg, TEST_MSG_OP_1);
570570
ASSERT_OK(bt_mesh_model_publish(test_model));
571571

572+
/* Give time to complete publication */
573+
k_sleep(K_SECONDS(2));
574+
575+
/* Terminate friendship by disabling the LPN functionality */
576+
bt_mesh_lpn_set(false);
577+
ASSERT_OK_MSG(bt_mesh_test_friendship_evt_wait(BT_MESH_TEST_LPN_TERMINATED, K_SECONDS(5)),
578+
"LPN did not terminate friendship correctly");
579+
580+
/* With this enabled feature, LPN leaves scanner disabled after termination. */
581+
if (IS_ENABLED(CONFIG_BT_MESH_LPN_ESTABLISHMENT)) {
582+
bt_mesh_scan_enable();
583+
}
584+
585+
/* Send an unsegmented message to a third mesh node. */
586+
ASSERT_OK_MSG(bt_mesh_test_send(other_cfg.addr, NULL, 5, 0, K_NO_WAIT),
587+
"Send to the third mesh node failed");
588+
/* Receive an unsegmented message back */
589+
ASSERT_OK(bt_mesh_test_recv(5, cfg->addr, NULL, K_FOREVER));
590+
572591
PASS();
573592
}
574593

@@ -587,9 +606,9 @@ static void test_lpn_re_est(void)
587606
"LPN not established");
588607

589608
bt_mesh_lpn_set(false);
590-
ASSERT_OK_MSG(bt_mesh_test_friendship_evt_wait(BT_MESH_TEST_LPN_TERMINATED,
591-
K_SECONDS(5)),
592-
"LPN never terminated friendship");
609+
ASSERT_OK_MSG(
610+
bt_mesh_test_friendship_evt_wait(BT_MESH_TEST_LPN_TERMINATED, K_SECONDS(5)),
611+
"LPN did not terminate friendship correctly");
593612

594613
k_sleep(K_SECONDS(2));
595614
}
@@ -966,6 +985,13 @@ static void test_other_msg(void)
966985
ASSERT_OK_MSG(bt_mesh_test_recv(1, cfg->addr, NULL, K_FOREVER),
967986
"Failed to receive from LPN");
968987

988+
/* Receive an unsegmented message from the LPN outside of friendship. */
989+
ASSERT_OK_MSG(bt_mesh_test_recv(5, cfg->addr, NULL, K_FOREVER),
990+
"Failed to receive from LPN after friendship termination");
991+
/* Send an unsegmented message to the LPN */
992+
ASSERT_OK_MSG(bt_mesh_test_send(LPN_ADDR_START, NULL, 5, 0, K_NO_WAIT),
993+
"Failed to send to LPN after friendship termination");
994+
969995
PASS();
970996
}
971997

tests/bsim/bluetooth/mesh/tests_scripts/friendship/msg_mesh.sh

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,28 @@
44

55
source $(dirname "${BASH_SOURCE[0]}")/../../_mesh_test.sh
66

7-
# Test communication between the LPN and a third mesh device
7+
# Test communication between the LPN and a third mesh device.
8+
# Test scenario:
9+
# 1. LPN and Friend establish friendship.
10+
# 2. LPN sends unsegmented data to the third mesh device and receives unsegmented data back.
11+
# 3. LPN sends segmented data to the third mesh device and receives segmented data back.
12+
# 4. LPN publishes unsegmented data to the third device with friendship credentials.
13+
# Friend should relay data to the third device with network credentials.
14+
# The third mesh receives published data.
15+
# 5. LPN terminates friendship and gets an event about termination.
16+
# 6. LPN sends unsegmented data to the third device outside of friendship and
17+
# receives unsegmented data back.
818
RunTest mesh_friendship_msg_mesh \
919
friendship_lpn_msg_mesh \
1020
friendship_other_msg \
1121
friendship_friend_est
1222

23+
overlay=overlay_lpn_scan_on_conf
24+
RunTest mesh_friendship_msg_mesh_lpn_scan_on \
25+
friendship_lpn_msg_mesh \
26+
friendship_other_msg \
27+
friendship_friend_est
28+
1329
overlay=overlay_psa_conf
1430
RunTest mesh_friendship_msg_mesh_psa \
1531
friendship_lpn_msg_mesh \

0 commit comments

Comments
 (0)