|
| 1 | +.. _samples_test_app: |
| 2 | + |
| 3 | +Bluetooth: Bluetooth LE master test app |
| 4 | +####################################### |
| 5 | + |
| 6 | +.. contents:: |
| 7 | + :local: |
| 8 | + :depth: 2 |
| 9 | + |
| 10 | +The Bluetooth LE master test app is a Bluetooth® Low Energy (LE) central application designed to test basic Bluetooth functionality in peripheral samples. |
| 11 | +This application acts as a tester in the central role to validate Bluetooth LE peripheral applications in the |NCS|. |
| 12 | + |
| 13 | +Requirements |
| 14 | +************ |
| 15 | + |
| 16 | +The sample supports the following development kits: |
| 17 | + |
| 18 | +.. table-from-sample-yaml:: |
| 19 | + |
| 20 | +.. include:: /includes/tfm.txt |
| 21 | + |
| 22 | +The sample requires a Bluetooth LE peripheral device for testing. |
| 23 | +You can use any of the following peripheral samples: |
| 24 | + |
| 25 | +* :ref:`peripheral_uart` |
| 26 | +* :ref:`peripheral_hids_keyboard` |
| 27 | +* :ref:`peripheral_hids_mouse` |
| 28 | +* :ref:`peripheral_lbs` |
| 29 | + |
| 30 | +Overview |
| 31 | +******** |
| 32 | + |
| 33 | +The Bluetooth LE master test app implements a Bluetooth LE central device that can discover and connect to peripheral devices. |
| 34 | +It performs automatic device discovery, service discovery, connection management, and supports security features. |
| 35 | + |
| 36 | +The application follows a specific test sequence: |
| 37 | + |
| 38 | +1. Initialization - Initializes the Bluetooth stack and sets up required modules. |
| 39 | +#. Scanning - Actively scans for supported peripheral devices. |
| 40 | +#. Connection - Automatically connects to discovered devices. |
| 41 | +#. Service discovery - Discovers and logs GATT services. |
| 42 | +#. Connection maintenance - Maintains the connection for five seconds. |
| 43 | +#. Disconnection - Disconnects gracefully. |
| 44 | +#. Reconnection - Waits three seconds, then reconnects. |
| 45 | +#. Extended test - Maintains the connection for 10 seconds. |
| 46 | +#. Final disconnection - Completes the test cycle. |
| 47 | +#. Success indication - Prints ``SUCCESS`` when all steps are completed. |
| 48 | + |
| 49 | +Supported device types |
| 50 | +====================== |
| 51 | + |
| 52 | +The application is configured to discover and test the following Bluetooth LE peripheral devices: |
| 53 | + |
| 54 | +* Nordic UART Service |
| 55 | +* Nordic Throughput |
| 56 | +* NCS HIDS Keyboard |
| 57 | +* NCS HIDS Mouse |
| 58 | +* Nordic Lightweight Battery Service (LBS) |
| 59 | +* Test Beacon |
| 60 | +* HID devices (through UUID filtering) |
| 61 | + |
| 62 | +Debugging |
| 63 | +********* |
| 64 | + |
| 65 | +In this sample, the UART console is used to display test progress and results. |
| 66 | +Debug messages are not displayed in the UART console, instead, they are printed by the RTT logger. |
| 67 | + |
| 68 | +To view debug messages, follow the procedure described in :ref:`testing_rtt_connect`. |
| 69 | + |
| 70 | +FEM support |
| 71 | +*********** |
| 72 | + |
| 73 | +.. include:: /includes/sample_fem_support.txt |
| 74 | + |
| 75 | +Configuration |
| 76 | +************* |
| 77 | + |
| 78 | +|config| |
| 79 | + |
| 80 | +Configuration options |
| 81 | +===================== |
| 82 | + |
| 83 | +Check and configure the following configuration options for the sample: |
| 84 | + |
| 85 | +* :kconfig:option:`CONFIG_BT_CENTRAL` |
| 86 | +* :kconfig:option:`CONFIG_BT_SCAN` |
| 87 | +* :kconfig:option:`CONFIG_BT_GATT_DM` |
| 88 | +* :kconfig:option:`CONFIG_BT_SMP` |
| 89 | + |
| 90 | +Building and running |
| 91 | +******************** |
| 92 | + |
| 93 | +.. |sample path| replace:: :file:`tests/samples/bluetooth/samples_test_app` |
| 94 | + |
| 95 | +.. include:: /includes/build_and_run_ns.txt |
| 96 | + |
| 97 | +.. |sample_or_app| replace:: sample |
| 98 | +.. |ipc_radio_dir| replace:: :file:`sysbuild/ipc_radio` |
| 99 | + |
| 100 | +.. include:: /includes/ipc_radio_conf.txt |
| 101 | + |
| 102 | +.. include:: /includes/nRF54H20_erase_UICR.txt |
| 103 | + |
| 104 | +Testing |
| 105 | +======= |
| 106 | + |
| 107 | +After programming the sample to your development kit, complete the following steps to test the basic functionality: |
| 108 | + |
| 109 | +.. tabs:: |
| 110 | + |
| 111 | + .. group-tab:: nRF21, nRF52 and nRF53 DKs |
| 112 | + |
| 113 | + 1. Connect the device to the computer to access UART 0. |
| 114 | + If you use a development kit, UART 0 is forwarded as a serial port. |
| 115 | + |serial_port_number_list| |
| 116 | + #. |connect_terminal| |
| 117 | + #. Reset the kit. |
| 118 | + #. Observe that the text ``Starting Bluetooth LE test application`` is printed on the COM listener. |
| 119 | + #. Power on a Bluetooth LE peripheral device that matches one of the supported device types. |
| 120 | + #. Observe that the application discovers and connects to the peripheral device. |
| 121 | + #. Monitor the console output for successful connection and service discovery. |
| 122 | + #. Verify that the application completes the full test cycle and prints ``SUCCESS``. |
| 123 | + |
| 124 | + .. group-tab:: nRF54 DKs |
| 125 | + |
| 126 | + .. note:: |
| 127 | + |nrf54_buttons_leds_numbering| |
| 128 | + |
| 129 | + 1. Connect the device to the computer to access UART 0. |
| 130 | + If you use a development kit, UART 0 is forwarded as a serial port. |
| 131 | + |serial_port_number_list| |
| 132 | + #. |connect_terminal| |
| 133 | + #. Reset the kit. |
| 134 | + #. Observe that the text ``Starting Bluetooth LE test application`` is printed on the COM listener. |
| 135 | + #. Power on a Bluetooth LE peripheral device that matches one of the supported device types. |
| 136 | + #. Observe that the application discovers and connects to the peripheral device. |
| 137 | + #. Monitor the console output for successful connection and service discovery. |
| 138 | + #. Verify that the application completes the full test cycle and prints ``SUCCESS``. |
| 139 | + |
| 140 | +Sample output |
| 141 | +============= |
| 142 | + |
| 143 | +The application provides detailed console output, including: |
| 144 | + |
| 145 | +* Bluetooth initialization status |
| 146 | +* Device discovery information |
| 147 | +* Connection establishment details |
| 148 | +* Service discovery results |
| 149 | +* Security pairing information |
| 150 | +* Test progress and results |
| 151 | + |
| 152 | +The following is an example of the output: |
| 153 | + |
| 154 | +.. code-block:: console |
| 155 | +
|
| 156 | + Starting BLE test application |
| 157 | + Bluetooth initialized |
| 158 | + UART initialized |
| 159 | + Scan module initialized |
| 160 | + Scanning successfully started |
| 161 | + Filters matched. Address: AA:BB:CC:DD:EE:FF connectable: 1 |
| 162 | + Connected |
| 163 | + Service discovery completed |
| 164 | + Disconnect successful |
| 165 | + SUCCESS |
| 166 | +
|
| 167 | +Testing workflow |
| 168 | +================ |
| 169 | + |
| 170 | +The application supports both manual and automated testing. |
| 171 | + |
| 172 | +Manual testing |
| 173 | +-------------- |
| 174 | + |
| 175 | +To test the sample manually, complete the following steps: |
| 176 | + |
| 177 | +1. Build and flash the application to a development kit. |
| 178 | +#. Power on a Bluetooth LE peripheral device (for example, Nordic UART Service sample). |
| 179 | +#. Monitor the console output for successful connection and service discovery. |
| 180 | +#. Verify that the application completes the full test cycle. |
| 181 | + |
| 182 | +Automated testing |
| 183 | +----------------- |
| 184 | + |
| 185 | +The application is designed for integration with automated test frameworks, providing: |
| 186 | + |
| 187 | +* Seamless CI/CD pipeline support. |
| 188 | +* Structured test results. |
| 189 | +* Comprehensive documentation of test procedures. |
| 190 | +* Full compatibility with Nordic Semiconductor's test infrastructure. |
| 191 | + |
| 192 | +Troubleshooting |
| 193 | +=============== |
| 194 | + |
| 195 | +If you have issues while using the sample, consider the following potential causes and recommended checks: |
| 196 | + |
| 197 | +1. No devices discovered - Ensure the peripheral device is advertising with the correct name. |
| 198 | +#. Connection failures - Check device compatibility and verify the Bluetooth stack configuration. |
| 199 | +#. Service discovery errors - Verify that the peripheral device implements the expected services. |
| 200 | +#. Build errors - Ensure all required dependencies are properly installed. |
| 201 | + |
| 202 | +Dependencies |
| 203 | +************ |
| 204 | + |
| 205 | +This sample uses the following |NCS| libraries: |
| 206 | + |
| 207 | +* :ref:`gatt_dm_readme` |
| 208 | +* :ref:`nrf_bt_scan_readme` |
| 209 | + |
| 210 | +In addition, it uses the following Zephyr libraries: |
| 211 | + |
| 212 | +* :file:`include/zephyr/types.h` |
| 213 | +* :file:`boards/arm/nrf*/board.h` |
| 214 | +* :ref:`zephyr:kernel_api`: |
| 215 | + |
| 216 | + * :file:`include/kernel.h` |
| 217 | + |
| 218 | +* :ref:`zephyr:api_peripherals`: |
| 219 | + |
| 220 | + * :file:`include/uart.h` |
| 221 | + |
| 222 | +* :ref:`zephyr:bluetooth_api`: |
| 223 | + |
| 224 | + * :file:`include/bluetooth/bluetooth.h` |
| 225 | + * :file:`include/bluetooth/gatt.h` |
| 226 | + * :file:`include/bluetooth/hci.h` |
| 227 | + * :file:`include/bluetooth/uuid.h` |
| 228 | + |
| 229 | +The sample also uses the following secure firmware component: |
| 230 | + |
| 231 | +* :ref:`Trusted Firmware-M <ug_tfm>` |
0 commit comments