Bluetooth: Bluetooth LE Advertising Report with channel index

The Bluetooth LE Advertising Report with channel index sample demonstrates the use of channel index appended to HCI advertising reports for legacy advertising PDUs using the SoftDevice Controller proprietary extension.

The sample prints each advertising report twice. First, the scan callback passed to the bt_le_scan_start() function prints the report. Then, the scan receive callback registered with the bt_le_scan_cb_register() function prints it again.

Requirements

The sample supports the following development kits:

Hardware platforms

PCA

Board name

Board target

nRF54LV10 DK

PCA10188

nrf54lv10dk

nrf54lv10dk/nrf54lv10a/cpuapp

nRF54LM20 DK

PCA10184

nrf54lm20dk

nrf54lm20dk/nrf54lm20b/cpuapp nrf54lm20dk/nrf54lm20a/cpuapp

nRF54LC10 DK

PCA10226

nrf54lc10dk

nrf54lc10dk/nrf54lc10a/cpuapp

nRF54L15 DK

PCA10156

nrf54l15dk

nrf54l15dk/nrf54l15/cpuapp

nRF54L15 DK (emulating nRF54L10)

PCA10156

nrf54l15dk

nrf54l15dk/nrf54l10/cpuapp

nRF54L15 DK (emulating nRF54L05)

PCA10156

nrf54l15dk

nrf54l15dk/nrf54l05/cpuapp

nRF54H20 DK

PCA10175

nrf54h20dk

nrf54h20dk/nrf54h20/cpuapp

nRF5340 DK

PCA10095

nrf5340dk

nrf5340dk/nrf5340/cpuapp

You need one development kit that runs this scanner sample and a nearby device that sends legacy advertising PDUs. Any standard advertiser sample from Zephyr or the nRF Connect SDK works as the advertiser.

Overview

The sample enables the feature at build time using the CONFIG_BT_HCI_ADV_REPORT_CHAN_IDX and CONFIG_BT_CTLR_SDC_CHAN_IDX_IN_ADV_REPORT Kconfig options. The controller links the feature through the sdc_support_chan_idx_in_adv_report() function and appends a chan_idx octet to advertising reports for legacy advertising PDUs. The scan receive callback exposes this value in the bt_le_scan_recv_info.chan_idx field.

The channel index is available for legacy advertising PDUs with both scanning interfaces:

  • When the CONFIG_BT_EXT_ADV Kconfig option is disabled, the host uses legacy scanning HCI commands. The controller appends the chan_idx octet after the rssi field in LE Advertising Report events.

  • When the CONFIG_BT_EXT_ADV Kconfig option is enabled, the host uses extended scanning HCI commands. The controller appends the chan_idx octet after the advertising data in LE Extended Advertising Report events for legacy advertising PDUs.

The channel index is not available for extended advertising PDUs. For these PDUs, the bt_le_scan_recv_info.chan_idx field is set to UINT8_MAX.

Building and running

This sample can be found under samples/bluetooth/le_adv_report_chan_idx in the nRF Connect SDK folder structure.

To build the sample, follow the instructions in Building an application for your preferred building environment. See also Programming an application for programming steps and Testing and optimization for general information about testing and debugging in the nRF Connect SDK.

Note

When building repository applications in the SDK repositories, building with sysbuild is enabled by default. If you work with out-of-tree freestanding applications, you need to manually pass the --sysbuild parameter to every build command or configure west to always use it.

To use the extended scanning HCI commands, enable the CONFIG_BT_EXT_ADV Kconfig option for both the application and the ipc_radio image. For example, add the -DCONFIG_BT_EXT_ADV=y -Dipc_radio_CONFIG_BT_EXT_ADV=y CMake arguments to the build command.

When building this sample with Sysbuild for an SoC that has a network core, the IPC radio firmware is automatically applied to the build. The IPC radio is one of the companion components in the nRF Connect SDK and allows to use the radio peripheral from another core in a multicore device. If needed, you can modify the IPC radio configuration in the prj.conf source file in the sample’s sysbuild/ipc_radio directory.

Testing

After programming the sample to your development kit, complete the following steps to test it:

  1. Connect the kit to the computer using a USB cable. The kit is assigned a serial port. Serial ports are referred to as COM ports on Windows, /dev/ttyACM devices on Linux, and /dev/tty devices on macOS. To list Nordic Semiconductor devices connected to your computer together with their serial ports, open a terminal and run the nrfutil device list command. Alternatively, check your operating system’s device manager or its equivalent.

  2. Connect to the kit with a terminal emulator (for example, the Serial Terminal app). See Testing and optimization for the required settings and steps.

  3. Start an advertiser on a nearby device.

  4. Observe that the terminal shows advertising reports with channel index values.

Sample output

The output should look similar to the following:

LE Advertising Report with Channel Index sample
Starting scan
scan_cb: Device found: D4:3B:2A:5C:11:07 (random) (RSSI -45), type 0, AD data len 31
scan_recv: Device found: D4:3B:2A:5C:11:07 (random) (chan_idx 37 RSSI -45), type 0, AD data len 31
scan_cb: Device found: D4:3B:2A:5C:11:07 (random) (RSSI -47), type 0, AD data len 31
scan_recv: Device found: D4:3B:2A:5C:11:07 (random) (chan_idx 38 RSSI -47), type 0, AD data len 31

When you build the sample with the CONFIG_BT_EXT_ADV Kconfig option enabled, it sets the channel index to 255 (UINT8_MAX) for reports of extended advertising PDUs:

scan_cb: Device found: E1:62:9F:03:4A:B2 (random) (RSSI -52), type 5, AD data len 50
scan_recv: Device found: E1:62:9F:03:4A:B2 (random) (chan_idx 255 RSSI -52), type 5, AD data len 50