Add BabbleSim tests for VS write BD addr functionality#24
Conversation
|
@copilot add a new test in |
Added new tests:
The peripheral creates a public address |
The current way of setting the public address using `bt_hci_driver_api::setup` does not work well in split builds where host and controller runs on different cores/socs/boards. This approach requires each HCI driver and each `hci_<transport>` application to implement the setup and pass the information on to the next layer. Zephyr already defines a vendor-specific command that can be used to set the public address (`bt_hci_cp_vs_write_bd_addr`). Use this in `bt_enable` after opening the HCI transport and before initializing the id module. This makes the setup independent of hci transport and only depends on a controller that implements the Zephyr HCI VS commands. Signed-off-by: Herman Berget <herman.berget@nordicsemi.no>
Co-authored-by: cvinayak <6350656+cvinayak@users.noreply.github.com>
Co-authored-by: cvinayak <6350656+cvinayak@users.noreply.github.com>
Co-authored-by: cvinayak <6350656+cvinayak@users.noreply.github.com>
Added compile script, Kconfig, Kconfig.sysbuild and sysbuild.cmake for testing on nrf5340bsim/nrf5340/cpuapp.
3288bbc to
e298ddf
Compare
|
@copilot i have now updated the pull request (force pushed). I added scripts et al to be able to test on nrf5340bsim/nrf5340/cpuapp |
Acknowledged. I can see the new files added in e298ddf:
The test infrastructure I added (test functions and scripts) is still intact and will now work with nrf5340bsim/nrf5340/cpuapp builds. |
Adds test coverage for setting public address via HCI Vendor-Specific
bt_hci_cp_vs_write_bd_addrcommand duringbt_enable(), introduced in zephyrproject-rtos#103753.Changes
Test Scenario 1: Central with public address
test_central_connect_vs_set_public_addrinmain.c- Creates public identity withbt_id_create()beforebt_enable()to trigger VS write BD addr path, then connects to peripheral with random addresstests_scripts/run_central_vs_set_public_addr.sh- BabbleSim test runnerTest Scenario 2: Peripheral with public address
test_peripheral_vs_set_public_addrindummy_peripheral.c- Peripheral creates public identity withbt_id_create()beforebt_enable()to trigger VS write BD addr path, then advertisestest_central_connect_to_peripheral_public_addrinmain.c- Central connects to the peripheral with public addresstests_scripts/run_central_connect_to_peripheral_public_addr.sh- BabbleSim test runnerTest infrastructure:
CONFIG_BT_HCI_VS=yinprj.confTest flow
Scenario 1 - Central with public address:
Scenario 2 - Peripheral with public address:
Tests registered in
test_def[]arrays, following existing BabbleSim test patterns.Original prompt
Context
PR zephyrproject-rtos#103753 adds support for using the HCI Vendor-Specific command
bt_hci_cp_vs_write_bd_addrto set the public address duringbt_enable(). This replaces the previous approach of usingbt_hci_driver_api::setupwhich didn't work well in split builds.The key changes in that PR are:
BT_VS_CMD_WRITE_BD_ADDR(cmd)ininclude/zephyr/bluetooth/hci_vs.hhci_vs_write_bd_addr()insubsys/bluetooth/host/hci_core.cthat sends the VS commandhci_init(), afterhci_vs_init(), if there's a pre-configured public address and the VS write BD addr command is supported, it sends the address via the VS commandbt_id_create()insubsys/bluetooth/host/id.cnow allows public addresses whenCONFIG_BT_HCI_VSis enabled (not justCONFIG_BT_HCI_SET_PUBLIC_ADDR)Task
Add new BabbleSIM tests to
tests/bsim/bluetooth/host/central/to verify the VS write BD addr functionality. Take inspiration from the existingrun_central_connect_to_existing.shtest and the test infrastructure already in place.Existing test structure to follow
The test lives in
tests/bsim/bluetooth/host/central/with:src/main.c- Contains test functions and test installersrc/dummy_peripheral.c- Contains a simple connectable peripheraltests_scripts/run_central_connect_to_existing.sh- Shell script that runs central + peripheral + PHY simulatorprj.conf- Project configurationCMakeLists.txt- Build configurationtestcase.yaml- Test case metadataWhat to add
New test function in
tests/bsim/bluetooth/host/central/src/main.c:test_central_connect_vs_set_public_addrthat:bt_id_create()withBT_ADDR_LE_PUBLICtype BEFORE callingbt_enable(). Use an address like{.type = BT_ADDR_LE_PUBLIC, .a.val = {0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF}}bt_enable(NULL)- this should trigger the VS write BD addr path internallytest_central_connect_to_existing)test_def[]array withtest_id = "central_vs_set_public_addr"New test script
tests/bsim/bluetooth/host/central/tests_scripts/run_central_vs_set_public_addr.sh:run_central_connect_to_existing.sh:Reference: Existing
run_central_connect_to_existing.shReference: Existing
src/main.c(relevant parts)