Skip to content

Commit 06078ee

Browse files
erbr-otcarlescufi
authored andcommitted
Bluetooth: controller: DO TODO, compile out members of struct re. CPR
Compile out misc. members not used when Connection Parameter Request is not supported. Implement missing tests re. unsupported features in CU/CPR procedure Signed-off-by: Erik Brockhoff <[email protected]>
1 parent 0d015fd commit 06078ee

File tree

3 files changed

+107
-55
lines changed

3 files changed

+107
-55
lines changed

subsys/bluetooth/controller/ll_sw/ull_llcp_internal.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,6 @@ struct proc_ctx {
190190
} pu;
191191
#endif /* CONFIG_BT_CTLR_PHY */
192192

193-
/* TODO(tosk): leave out some params below if !CONFIG_BT_CTLR_CONN_PARAM_REQ */
194193
/* Connection Update & Connection Parameter Request */
195194
struct {
196195
uint8_t error;
@@ -202,6 +201,7 @@ struct proc_ctx {
202201
uint16_t interval_max;
203202
uint16_t latency;
204203
uint16_t timeout;
204+
#if defined(CONFIG_BT_CTLR_CONN_PARAM_REQ)
205205
uint8_t preferred_periodicity;
206206
uint16_t reference_conn_event_count;
207207
uint16_t offset0;
@@ -210,6 +210,7 @@ struct proc_ctx {
210210
uint16_t offset3;
211211
uint16_t offset4;
212212
uint16_t offset5;
213+
#endif /* defined(CONFIG_BT_CTLR_CONN_PARAM_REQ) */
213214
} cu;
214215

215216
/* Use by ACL Termination Procedure */

subsys/bluetooth/controller/ll_sw/ull_llcp_pdu.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,7 @@ void llcp_pdu_decode_phy_rsp(struct proc_ctx *ctx, struct pdu_data *pdu)
504504
#endif /* CONFIG_BT_CENTRAL */
505505
#endif /* CONFIG_BT_CTLR_PHY */
506506

507+
#if defined(CONFIG_BT_CTLR_CONN_PARAM_REQ)
507508
/*
508509
* Connection Update Procedure Helper
509510
*/
@@ -592,6 +593,7 @@ void llcp_pdu_decode_conn_param_rsp(struct proc_ctx *ctx, struct pdu_data *pdu)
592593
ctx->data.cu.offset4 = sys_le16_to_cpu(p->offset4);
593594
ctx->data.cu.offset5 = sys_le16_to_cpu(p->offset5);
594595
}
596+
#endif /* defined(CONFIG_BT_CTLR_CONN_PARAM_REQ) */
595597

596598
void llcp_pdu_encode_conn_update_ind(struct proc_ctx *ctx, struct pdu_data *pdu)
597599
{

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

Lines changed: 103 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ struct pdu_data_llctrl_conn_update_ind conn_update_ind = { .win_size = 1U,
5151
.timeout = TIMEOUT,
5252
.instant = 6U };
5353

54-
#if defined(CONFIG_BT_CTLR_CONN_PARAM_REQ)
5554
/* Default conn_param_req PDU */
5655
struct pdu_data_llctrl_conn_param_req conn_param_req = { .interval_min = INTVL_MIN,
5756
.interval_max = INTVL_MAX,
@@ -66,6 +65,7 @@ struct pdu_data_llctrl_conn_param_req conn_param_req = { .interval_min = INTVL_M
6665
.offset4 = 0xffffU,
6766
.offset5 = 0xffffU };
6867

68+
#if defined(CONFIG_BT_CTLR_CONN_PARAM_REQ)
6969
/* Default conn_param_rsp PDU */
7070
struct pdu_data_llctrl_conn_param_rsp conn_param_rsp = { .interval_min = INTVL_MIN,
7171
.interval_max = INTVL_MAX,
@@ -1276,28 +1276,6 @@ void test_conn_update_central_rem_reject(void)
12761276
"Free CTX buffers %d", ctx_buffers_free());
12771277
}
12781278

1279-
/* Peripheral-initiated Connection Parameters Request procedure.
1280-
* Peripheral requests change in LE connection parameters, central’s Controller do not
1281-
* support Connection Parameters Request procedure.
1282-
*
1283-
* +-----+ +-------+ +-----+
1284-
* | UT | | LL_C | | LT |
1285-
* +-----+ +-------+ +-----+
1286-
* | | |
1287-
* | | LL_CONNECTION_PARAM_REQ |
1288-
* | |<--------------------------|
1289-
* | | |
1290-
* | | LL_UNKNOWN_RSP |
1291-
* | |-------------------------->|
1292-
* | | |
1293-
*/
1294-
void test_conn_update_central_rem_unsupp_feat(void)
1295-
{
1296-
/* TODO(thoh): Implement when Remote Request machine has feature
1297-
* checking
1298-
*/
1299-
}
1300-
13011279
/*
13021280
* (A)
13031281
* Peripheral-initiated Connection Parameters Request procedure.
@@ -2525,29 +2503,6 @@ void test_conn_update_periph_rem_reject(void)
25252503
"Free CTX buffers %d", ctx_buffers_free());
25262504
}
25272505

2528-
/*
2529-
* Central-initiated Connection Parameters Request procedure.
2530-
* Central requests change in LE connection parameters, peripheral’s Controller do not
2531-
* support Connection Parameters Request procedure.
2532-
*
2533-
* +-----+ +-------+ +-----+
2534-
* | UT | | LL_P | | LT |
2535-
* +-----+ +-------+ +-----+
2536-
* | | |
2537-
* | | LL_CONNECTION_PARAM_REQ |
2538-
* | |<--------------------------|
2539-
* | | |
2540-
* | | LL_UNKNOWN_RSP |
2541-
* | |-------------------------->|
2542-
* | | |
2543-
*/
2544-
void test_conn_update_periph_rem_unsupp_feat(void)
2545-
{
2546-
/* TODO(thoh): Implement when Remote Request machine has feature
2547-
* checking
2548-
*/
2549-
}
2550-
25512506
/*
25522507
* (A)
25532508
* Central-initiated Connection Parameters Request procedure.
@@ -2890,7 +2845,7 @@ void test_conn_update_central_loc_accept_no_param_req(void)
28902845

28912846
/*
28922847
* Parameter Request Procedure not supported.
2893-
* Peripheral-initiated Connection Update procedure.
2848+
* Peripheral-initiated Connection Update/Connection Parameter Request procedure
28942849
* Central receives Connection Update parameters.
28952850
*
28962851
* +-----+ +-------+ +-----+
@@ -2904,8 +2859,15 @@ void test_conn_update_central_loc_accept_no_param_req(void)
29042859
* | |-------------------------->|
29052860
* | | |
29062861
* | | |
2862+
* | | LL_CONNECTION_PARAM_REQ |
2863+
* | |<--------------------------|
2864+
* | | |
2865+
* | | LL_UNKNOWN_RSP |
2866+
* | |-------------------------->|
2867+
* | | |
2868+
* | | |
29072869
*/
2908-
void test_conn_update_central_rem_accept_no_param_req(void)
2870+
void test_conn_update_central_rem_unknown_no_param_req(void)
29092871
{
29102872
struct node_tx *tx;
29112873

@@ -2943,6 +2905,93 @@ void test_conn_update_central_rem_accept_no_param_req(void)
29432905

29442906
zassert_equal(ctx_buffers_free(), test_ctx_buffers_cnt(),
29452907
"Free CTX buffers %d", ctx_buffers_free());
2908+
2909+
/* Check UNKNOWN_RSP on Connection Parameter Request */
2910+
unknown_rsp.type = PDU_DATA_LLCTRL_TYPE_CONN_PARAM_REQ;
2911+
/* Prepare */
2912+
event_prepare(&conn);
2913+
2914+
/* Rx */
2915+
lt_tx(LL_CONNECTION_PARAM_REQ, &conn, &conn_param_req);
2916+
2917+
/* Done */
2918+
event_done(&conn);
2919+
2920+
/* Prepare */
2921+
event_prepare(&conn);
2922+
2923+
/* Tx Queue should have one LL Control PDU */
2924+
lt_rx(LL_UNKNOWN_RSP, &conn, &tx, &unknown_rsp);
2925+
lt_rx_q_is_empty(&conn);
2926+
2927+
/* Done */
2928+
event_done(&conn);
2929+
2930+
/* There should NOT be a host notification */
2931+
ut_rx_q_is_empty();
2932+
2933+
zassert_equal(ctx_buffers_free(), test_ctx_buffers_cnt(),
2934+
"Free CTX buffers %d", ctx_buffers_free());
2935+
2936+
}
2937+
2938+
/*
2939+
* Parameter Request Procedure not supported.
2940+
* Peripheral-initiated Connection Update/Connection Parameter Request procedure
2941+
* Central receives Connection Update parameters.
2942+
*
2943+
* +-----+ +-------+ +-----+
2944+
* | UT | | LL_M | | LT |
2945+
* +-----+ +-------+ +-----+
2946+
* | | |
2947+
* | | |
2948+
* | | LL_CONNECTION_PARAM_REQ |
2949+
* | |<--------------------------|
2950+
* | | |
2951+
* | | LL_UNKNOWN_RSP |
2952+
* | |-------------------------->|
2953+
* | | |
2954+
* | | |
2955+
*/
2956+
void test_conn_update_periph_rem_unknown_no_param_req(void)
2957+
{
2958+
struct node_tx *tx;
2959+
2960+
struct pdu_data_llctrl_unknown_rsp unknown_rsp = {
2961+
.type = PDU_DATA_LLCTRL_TYPE_CONN_PARAM_REQ
2962+
};
2963+
2964+
/* Role */
2965+
test_set_role(&conn, BT_HCI_ROLE_PERIPHERAL);
2966+
2967+
/* Connect */
2968+
ull_cp_state_set(&conn, ULL_CP_CONNECTED);
2969+
2970+
/* Prepare */
2971+
event_prepare(&conn);
2972+
2973+
/* Rx */
2974+
lt_tx(LL_CONNECTION_PARAM_REQ, &conn, &conn_param_req);
2975+
2976+
/* Done */
2977+
event_done(&conn);
2978+
2979+
/* Prepare */
2980+
event_prepare(&conn);
2981+
2982+
/* Tx Queue should have one LL Control PDU */
2983+
lt_rx(LL_UNKNOWN_RSP, &conn, &tx, &unknown_rsp);
2984+
lt_rx_q_is_empty(&conn);
2985+
2986+
/* Done */
2987+
event_done(&conn);
2988+
2989+
/* There should NOT be a host notification */
2990+
ut_rx_q_is_empty();
2991+
2992+
zassert_equal(ctx_buffers_free(), test_ctx_buffers_cnt(),
2993+
"Free CTX buffers %d", ctx_buffers_free());
2994+
29462995
}
29472996

29482997
/*
@@ -3110,8 +3159,6 @@ void test_main(void)
31103159
setup, unit_test_noop),
31113160
ztest_unit_test_setup_teardown(test_conn_update_central_rem_reject,
31123161
setup, unit_test_noop),
3113-
ztest_unit_test_setup_teardown(test_conn_update_central_rem_unsupp_feat,
3114-
setup, unit_test_noop),
31153162
ztest_unit_test_setup_teardown(test_conn_update_central_rem_collision,
31163163
setup, unit_test_noop));
31173164

@@ -3137,8 +3184,6 @@ void test_main(void)
31373184
setup, unit_test_noop),
31383185
ztest_unit_test_setup_teardown(test_conn_update_periph_rem_reject,
31393186
setup, unit_test_noop),
3140-
ztest_unit_test_setup_teardown(test_conn_update_periph_rem_unsupp_feat,
3141-
setup, unit_test_noop),
31423187
ztest_unit_test_setup_teardown(test_conn_update_periph_rem_collision,
31433188
setup, unit_test_noop));
31443189

@@ -3154,16 +3199,20 @@ void test_main(void)
31543199
setup, unit_test_noop));
31553200

31563201
ztest_test_suite(central_rem_no_param_req, ztest_unit_test_setup_teardown(
3157-
test_conn_update_central_rem_accept_no_param_req,
3202+
test_conn_update_central_rem_unknown_no_param_req,
31583203
setup, unit_test_noop));
31593204

31603205
ztest_test_suite(
31613206
periph_loc_no_param_req,
31623207
ztest_unit_test_setup_teardown(test_conn_update_periph_loc_disallowed_no_param_req,
31633208
setup, unit_test_noop));
31643209

3165-
ztest_test_suite(periph_rem_no_param_req, ztest_unit_test_setup_teardown(
3210+
ztest_test_suite(periph_rem_no_param_req,
3211+
ztest_unit_test_setup_teardown(
31663212
test_conn_update_periph_rem_accept_no_param_req,
3213+
setup, unit_test_noop),
3214+
ztest_unit_test_setup_teardown(
3215+
test_conn_update_periph_rem_unknown_no_param_req,
31673216
setup, unit_test_noop));
31683217

31693218
ztest_run_test_suite(central_loc_no_param_req);

0 commit comments

Comments
 (0)