Skip to content

Commit 9e3943d

Browse files
olivier-le-sagefabiobaltieri
authored andcommitted
bluetooth: host: Add CONFIG_BT_CHANNEL_SOUNDING_TEST
Makes it easier to make sure the CS test code is removed if desired. It should hopefully allow for a clean split in general. Signed-off-by: Olivier Lesage <[email protected]>
1 parent a12b869 commit 9e3943d

File tree

5 files changed

+28
-4
lines changed

5 files changed

+28
-4
lines changed

include/zephyr/bluetooth/cs.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -595,6 +595,8 @@ int bt_le_cs_read_remote_fae_table(struct bt_conn *conn);
595595
* Existing callbacks can be unregistered by providing NULL function
596596
* pointers.
597597
*
598+
* @note To use this API @kconfig{CONFIG_BT_CHANNEL_SOUNDING_TEST} must be set.
599+
*
598600
* @param cs_test_cb Set of callbacks to be used with CS Test
599601
*
600602
* @return Zero on success or (negative) error code on failure.
@@ -615,7 +617,7 @@ int bt_le_cs_test_cb_register(struct bt_le_cs_test_cb cs_test_cb);
615617
* parameters of this command describe the required transmit and receive behavior
616618
* for the CS test.
617619
*
618-
* @note To use this API @kconfig{CONFIG_BT_CHANNEL_SOUNDING} must be set.
620+
* @note To use this API @kconfig{CONFIG_BT_CHANNEL_SOUNDING_TEST} must be set.
619621
*
620622
* @param params CS Test parameters
621623
*
@@ -661,7 +663,7 @@ int bt_le_cs_remove_config(struct bt_conn *conn, uint8_t config_id);
661663
* The controller is expected to finish reporting any subevent results
662664
* before completing this termination.
663665
*
664-
* @note To use this API @kconfig{CONFIG_BT_CHANNEL_SOUNDING} must be set.
666+
* @note To use this API @kconfig{CONFIG_BT_CHANNEL_SOUNDING_TEST} must be set.
665667
*
666668
* @return Zero on success or (negative) error code on failure.
667669
*/

subsys/bluetooth/Kconfig

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,13 @@ config BT_CHANNEL_SOUNDING
196196
help
197197
Enable support for Bluetooth 6.0 Channel Sounding feature.
198198

199+
config BT_CHANNEL_SOUNDING_TEST
200+
bool "Channel Sounding Test [EXPERIMENTAL]"
201+
select EXPERIMENTAL
202+
depends on BT_CHANNEL_SOUNDING
203+
help
204+
Enable support for Channel Sounding test mode.
205+
199206
endif # BT_CONN
200207

201208
rsource "Kconfig.iso"

subsys/bluetooth/host/cs.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@
1818
LOG_MODULE_REGISTER(bt_cs);
1919

2020
#if defined(CONFIG_BT_CHANNEL_SOUNDING)
21+
#if defined(CONFIG_BT_CHANNEL_SOUNDING_TEST)
2122
static struct bt_le_cs_test_cb cs_test_callbacks;
23+
#endif
2224

2325
void bt_le_cs_set_valid_chmap_bits(uint8_t channel_map[10])
2426
{
@@ -242,6 +244,7 @@ void bt_hci_le_cs_read_remote_fae_table_complete(struct net_buf *buf)
242244
bt_conn_unref(conn);
243245
}
244246

247+
#if defined(CONFIG_BT_CHANNEL_SOUNDING_TEST)
245248
int bt_le_cs_test_cb_register(struct bt_le_cs_test_cb cb)
246249
{
247250
cs_test_callbacks = cb;
@@ -350,6 +353,7 @@ int bt_le_cs_start_test(const struct bt_le_cs_test_param *params)
350353

351354
return bt_hci_cmd_send_sync(BT_HCI_OP_LE_CS_TEST, buf, NULL);
352355
}
356+
#endif /* CONFIG_BT_CHANNEL_SOUNDING_TEST */
353357

354358
void bt_hci_le_cs_subevent_result(struct net_buf *buf)
355359
{
@@ -370,12 +374,15 @@ void bt_hci_le_cs_subevent_result(struct net_buf *buf)
370374
return;
371375
}
372376

377+
#if defined(CONFIG_BT_CHANNEL_SOUNDING_TEST)
373378
if (sys_le16_to_cpu(evt->conn_handle) == BT_HCI_LE_CS_TEST_CONN_HANDLE) {
374379
if (!cs_test_callbacks.le_cs_test_subevent_data_available) {
375380
LOG_WRN("No callback registered. Discarded subevent results from CS Test.");
376381
return;
377382
}
378-
} else {
383+
} else
384+
#endif /* CONFIG_BT_CHANNEL_SOUNDING_TEST */
385+
{
379386
conn = bt_conn_lookup_handle(sys_le16_to_cpu(evt->conn_handle), BT_CONN_TYPE_LE);
380387
if (!conn) {
381388
LOG_ERR("Unknown connection handle when processing subevent results");
@@ -402,13 +409,16 @@ void bt_hci_le_cs_subevent_result(struct net_buf *buf)
402409
result.step_data_buf = NULL;
403410
}
404411

412+
#if defined(CONFIG_BT_CHANNEL_SOUNDING_TEST)
405413
if (sys_le16_to_cpu(evt->conn_handle) == BT_HCI_LE_CS_TEST_CONN_HANDLE) {
406414
result.header.config_id = 0;
407415
result.header.start_acl_conn_event = 0;
408416

409417
cs_test_callbacks.le_cs_test_subevent_data_available(&result);
410418

411-
} else {
419+
} else
420+
#endif /* CONFIG_BT_CHANNEL_SOUNDING_TEST */
421+
{
412422
result.header.config_id = evt->config_id;
413423
result.header.start_acl_conn_event =
414424
sys_le16_to_cpu(evt->start_acl_conn_event_counter);
@@ -523,6 +533,7 @@ int bt_le_cs_remove_config(struct bt_conn *conn, uint8_t config_id)
523533
return bt_hci_cmd_send_sync(BT_HCI_OP_LE_CS_REMOVE_CONFIG, buf, NULL);
524534
}
525535

536+
#if defined(CONFIG_BT_CHANNEL_SOUNDING_TEST)
526537
int bt_le_cs_stop_test(void)
527538
{
528539
struct net_buf *buf;
@@ -554,6 +565,7 @@ void bt_hci_le_cs_test_end_complete(struct net_buf *buf)
554565
cs_test_callbacks.le_cs_test_end_complete();
555566
}
556567
}
568+
#endif /* CONFIG_BT_CHANNEL_SOUNDING_TEST */
557569

558570
void bt_le_cs_step_data_parse(struct net_buf_simple *step_data_buf,
559571
bool (*func)(struct bt_le_cs_subevent_step *step, void *user_data),

subsys/bluetooth/host/hci_core.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2833,9 +2833,11 @@ static const struct event_handler meta_events[] = {
28332833
EVENT_HANDLER(BT_HCI_EVT_LE_CS_SUBEVENT_RESULT,
28342834
bt_hci_le_cs_subevent_result,
28352835
sizeof(struct bt_hci_evt_le_cs_subevent_result)),
2836+
#if defined(CONFIG_BT_CHANNEL_SOUNDING_TEST)
28362837
EVENT_HANDLER(BT_HCI_EVT_LE_CS_TEST_END_COMPLETE,
28372838
bt_hci_le_cs_test_end_complete,
28382839
sizeof(struct bt_hci_evt_le_cs_test_end_complete)),
2840+
#endif /* CONFIG_BT_CHANNEL_SOUNDING_TEST */
28392841
#endif /* CONFIG_BT_CHANNEL_SOUNDING */
28402842

28412843
};

tests/bluetooth/shell/testcase.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ tests:
3737
bluetooth.shell.channel_sounding:
3838
extra_configs:
3939
- CONFIG_BT_CHANNEL_SOUNDING=y
40+
- CONFIG_BT_CHANNEL_SOUNDING_TEST=y
4041
- CONFIG_BT_CTLR=n
4142
build_only: true
4243
bluetooth.shell.cdc_acm:

0 commit comments

Comments
 (0)