Skip to content

Commit c238ffe

Browse files
rafpelcnordicjm
authored andcommitted
NCSDK-34445: Added Bluetooth LE samples testing application
Application provides central function to test basic BLE functionality. Application to be used in Bluetooth Samples tests. Sample yaml added for twister build. Signed-off-by: Rafal Pelc <[email protected]>
1 parent 1ac0323 commit c238ffe

File tree

10 files changed

+766
-0
lines changed

10 files changed

+766
-0
lines changed

CODEOWNERS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -976,6 +976,10 @@
976976
/tests/bluetooth/bsim/nrf_auraconfig/*.rst @nrfconnect/ncs-audio-doc
977977

978978
/tests/samples/bluetooth/io_adapter/ @rafpelc @jema-nordic
979+
/tests/samples/bluetooth/samples_test_app/ @rafpelc
980+
/tests/samples/bluetooth/samples_test_app/README.rst @nrfconnect/ncs-doc-leads
981+
982+
979983
# CI specific west
980984
/test-manifests/99-default-test-nrf.yml @nrfconnect/ncs-ci
981985

doc/nrf/releases_and_maturity/releases/release-notes-changelog.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,8 @@ Amazon Sidewalk samples
265265
Bluetooth samples
266266
-----------------
267267

268+
* Added the :ref:`samples_test_app` application to demonstrate how to use the Bluetooth LE Test GATT Server and test Bluetooth LE functionality in peripheral samples.
269+
268270
* Updated the network core image applications for the following samples from the :zephyr:code-sample:`bluetooth_hci_ipc` sample to the :ref:`ipc_radio` application for multicore builds:
269271

270272
* :ref:`bluetooth_conn_time_synchronization`

doc/nrf/samples/bl.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,4 @@ This section lists the available |NCS| samples for the :ref:`Bluetooth® <ug_bt>
1919
../../../samples/bluetooth/*/README
2020
../../tests/bluetooth/bsim/nrf_auraconfig/README
2121
../../tests/bluetooth/bsim/nrf_auraconfig/tester/README
22+
../../tests/samples/bluetooth/*/README
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
cmake_minimum_required(VERSION 3.8.2)
2+
3+
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
4+
5+
target_sources(app PRIVATE src/main.c)
6+
zephyr_library_include_directories(${CMAKE_CURRENT_SOURCE_DIR})
7+
8+
project(bluetooth_sample_test_app)
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#
2+
# Copyright (c) 2023 Nordic Semiconductor
3+
#
4+
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
#
6+
7+
source "${ZEPHYR_BASE}/share/sysbuild/Kconfig"
8+
9+
config NRF_DEFAULT_IPC_RADIO
10+
default y
Lines changed: 231 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,231 @@
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>`
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Enable the UART driver
2+
CONFIG_UART_INTERRUPT_DRIVEN=y
3+
CONFIG_SERIAL=y
4+
CONFIG_CONSOLE=y
5+
CONFIG_UART_CONSOLE=y
6+
7+
# Enable the BLE stack with GATT Client configuration
8+
CONFIG_BT=y
9+
CONFIG_BT_CENTRAL=y
10+
CONFIG_BT_SMP=y
11+
CONFIG_BT_GATT_CLIENT=y
12+
13+
# Enable the BLE modules from NCS
14+
CONFIG_BT_SCAN=y
15+
CONFIG_BT_SCAN_FILTER_ENABLE=y
16+
CONFIG_BT_SCAN_UUID_CNT=1
17+
CONFIG_BT_GATT_DM=y
18+
CONFIG_HEAP_MEM_POOL_SIZE=2048
19+
CONFIG_BT_SCAN_NAME_CNT=6
20+
CONFIG_BT_GATT_DM_DATA_PRINT=y
21+
22+
CONFIG_BT_SETTINGS=y
23+
CONFIG_FLASH=y
24+
CONFIG_FLASH_PAGE_LAYOUT=y
25+
CONFIG_FLASH_MAP=y
26+
CONFIG_FCB=y
27+
CONFIG_SETTINGS=y
28+
CONFIG_SETTINGS_FCB=y
29+
30+
CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
sample:
2+
description: Appl with central role for testing basic Bluetooth functionality in BLE samples
3+
name: BLE Samples Test App
4+
tests:
5+
sample.bluetooth.ble_samples_test_app:
6+
sysbuild: true
7+
harness: bluetooth
8+
integration_platforms:
9+
- nrf52dk/nrf52832
10+
- nrf52833dk/nrf52833
11+
- nrf52840dk/nrf52840
12+
- nrf5340dk/nrf5340/cpuapp
13+
- nrf54h20dk/nrf54h20/cpuapp
14+
- nrf54l15dk/nrf54l15/cpuapp
15+
platform_allow:
16+
- nrf52dk/nrf52832
17+
- nrf52833dk/nrf52833
18+
- nrf52840dk/nrf52840
19+
- nrf5340dk/nrf5340/cpuapp
20+
- nrf54h20dk/nrf54h20/cpuapp
21+
- nrf54l15dk/nrf54l15/cpuapp
22+
tags:
23+
- bluetooth
24+
- ci_build
25+
- sysbuild

0 commit comments

Comments
 (0)