Skip to content

Commit d6dc5bd

Browse files
ppryga-nordiccarlescufi
authored andcommitted
tests: Bluetooth: cte_req: Add tests for handling LL_UNKNOWN_RSP
Add test that verify correct behavior of the CTE request procedure in case of reception of LL_UNKNOWN_RSP PDU from peer device. Signed-off-by: Piotr Pryga <[email protected]>
1 parent 2890f42 commit d6dc5bd

File tree

1 file changed

+94
-0
lines changed
  • tests/bluetooth/controller/ctrl_cte_req/src

1 file changed

+94
-0
lines changed

tests/bluetooth/controller/ctrl_cte_req/src/main.c

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -734,6 +734,96 @@ void test_cte_req_reject_inv_ll_param_peripheral_remote(void)
734734
"Free CTX buffers %d", ctx_buffers_free());
735735
}
736736

737+
/* +-----+ +-------+ +-----+
738+
* | UT | | LL_A | | LT |
739+
* +-----+ +-------+ +-----+
740+
* | | |
741+
* | Start initiation | |
742+
* | CTE Request Proc. | |
743+
* |--------------------------->| |
744+
* | | |
745+
* | | LL_LE_CTE_REQ |
746+
* | |------------------------------->|
747+
* | | |
748+
* | | LL_UNKNOWN_RSP |
749+
* | |<-------------------------------|
750+
* | | |
751+
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
752+
* | | |
753+
* | LE CTE Request Failed | |
754+
* |<---------------------------| |
755+
* | | |
756+
* | | |
757+
*/
758+
void test_cte_req_ll_unknown_rsp_local(uint8_t role)
759+
{
760+
uint8_t err;
761+
struct node_tx *tx;
762+
763+
struct pdu_data_llctrl_cte_req local_cte_req = {
764+
.cte_type_req = BT_HCI_LE_AOD_CTE_1US,
765+
.min_cte_len_req = BT_HCI_LE_CTE_LEN_MIN,
766+
};
767+
768+
struct pdu_data_llctrl_unknown_rsp unknown_rsp = { .type = PDU_DATA_LLCTRL_TYPE_CTE_REQ };
769+
struct node_rx_pdu *ntf;
770+
771+
/* Role */
772+
test_set_role(&conn, role);
773+
774+
/* Connect */
775+
ull_cp_state_set(&conn, ULL_CP_CONNECTED);
776+
777+
/* Initiate an CTE Request Procedure */
778+
err = ull_cp_cte_req(&conn, local_cte_req.min_cte_len_req, local_cte_req.cte_type_req);
779+
zassert_equal(err, BT_HCI_ERR_SUCCESS, NULL);
780+
781+
/* Prepare */
782+
event_prepare(&conn);
783+
784+
/* Tx Queue should have one LL Control PDU */
785+
lt_rx(LL_CTE_REQ, &conn, &tx, &local_cte_req);
786+
lt_rx_q_is_empty(&conn);
787+
788+
/* Rx */
789+
lt_tx(LL_UNKNOWN_RSP, &conn, &unknown_rsp);
790+
791+
/* Done */
792+
event_done(&conn);
793+
794+
/* Receive notification of reception of unknown response. The notification is changed to
795+
* HCI_LE_CTE_Request_Failed before send to host by HCI. This is why it is verified if CTE
796+
* request state machine sends LL_UNKNOWN_RSP towards host.
797+
*/
798+
ut_rx_pdu(LL_UNKNOWN_RSP, &ntf, &unknown_rsp);
799+
800+
/* The RX queue should be empty now */
801+
ut_rx_q_is_empty();
802+
803+
/* Release Ntf */
804+
ull_cp_release_ntf(ntf);
805+
806+
/* Release tx node */
807+
ull_cp_release_tx(&conn, tx);
808+
809+
zassert_equal(ctx_buffers_free(), test_ctx_buffers_cnt(), "Free CTX buffers %d",
810+
ctx_buffers_free());
811+
812+
/* Verify that CTE response feature is marked as not supported by peer device */
813+
err = ull_cp_cte_req(&conn, local_cte_req.min_cte_len_req, local_cte_req.cte_type_req);
814+
zassert_equal(err, BT_HCI_ERR_UNSUPP_REMOTE_FEATURE, NULL);
815+
}
816+
817+
void test_cte_req_ll_unknown_rsp_central_local(void)
818+
{
819+
test_cte_req_ll_unknown_rsp_local(BT_HCI_ROLE_CENTRAL);
820+
}
821+
822+
void test_cte_req_ll_unknown_rsp_peripheral_local(void)
823+
{
824+
test_cte_req_ll_unknown_rsp_local(BT_HCI_ROLE_PERIPHERAL);
825+
}
826+
737827
/* Tests related with PHY update procedure and CTE request procedure "collision" */
738828

739829
#define PREFER_S2_CODING 0U
@@ -1509,6 +1599,10 @@ void test_main(void)
15091599
setup, unit_test_noop),
15101600
ztest_unit_test_setup_teardown(test_cte_req_reject_inv_ll_param_peripheral_remote,
15111601
setup, unit_test_noop),
1602+
ztest_unit_test_setup_teardown(test_cte_req_ll_unknown_rsp_central_local, setup,
1603+
unit_test_noop),
1604+
ztest_unit_test_setup_teardown(test_cte_req_ll_unknown_rsp_peripheral_local, setup,
1605+
unit_test_noop),
15121606
ztest_unit_test_setup_teardown(
15131607
test_central_local_cte_req_wait_for_phy_update_complete_and_disable, setup,
15141608
unit_test_noop),

0 commit comments

Comments
 (0)