Bluetooth: Multiple advertising sets

The Multiple advertising sets sample demonstrates how to use the Bluetooth® advertising sets.

Requirements

The sample supports the following development kits:

Hardware platforms

PCA

Board name

Board target

nRF54LV10 DK

PCA10188

nrf54lv10dk

nrf54lv10dk/nrf54lv10a/cpuapp/ns nrf54lv10dk/nrf54lv10a/cpuapp

nRF54LM20 DK

PCA10184

nrf54lm20dk

nrf54lm20dk/nrf54lm20b/cpuapp/ns nrf54lm20dk/nrf54lm20b/cpuapp nrf54lm20dk/nrf54lm20a/cpuapp/ns nrf54lm20dk/nrf54lm20a/cpuapp

nRF54LC10 DK

PCA10226

nrf54lc10dk

nrf54lc10dk/nrf54lc10a/cpuapp/ns nrf54lc10dk/nrf54lc10a/cpuapp

nRF54L15 DK

PCA10156

nrf54l15dk

nrf54l15dk/nrf54l15/cpuapp/ns 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/ns nrf5340dk/nrf5340/cpuapp

nRF52 DK

PCA10040

nrf52dk

nrf52dk/nrf52832

nRF52840 DK

PCA10056

nrf52840dk

nrf52840dk/nrf52840

For more security, it is recommended to use the */ns variant of the board target. When built for this variant, the sample is configured to compile and run as a non-secure application using security by separation. Therefore, it automatically includes Trusted Firmware-M that prepares the required peripherals and secure services to be available for the application.

For testing this sample, you need to have the nRF Connect for Mobile app installed on your smartphone or tablet.

Overview

The sample implements two advertising sets:

  • Non-connectable advertising with the URI to the https://www.nordicsemi.com website in the advertising data. It shows the Bluetooth Broadcaster role (Beacon) functionality.

  • Connectable advertising with the 16-bit UUID of the Device Information GATT Service in the advertising data. It shows the Bluetooth Peripheral role functionality.

When you start the sample, it creates two advertising sets. Use your scanner device to observe the two advertisers:

  • Nordic Beacon that you can use to open the nRF Beacon website.

  • Nordic multi adv sets that you can use to establish a connection with the device.

Use your central device to establish the connection with this sample. When connected, the non-connectable advertiser is still shown on your scanner device. After disconnection, the connectable advertising starts again.

User interface

LED 1:

Blinks with a period of two seconds with the duty cycle set to 50% when the main loop is running and the device is advertising.

LED 2:

Lit when the development kit is connected.

Building and running

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

For more security, it is recommended to use the */ns variant of the board target (see the Requirements section above.) When built for this variant, the sample is configured to compile and run as a non-secure application using security by separation. Therefore, it automatically includes Trusted Firmware-M that prepares the required peripherals and secure services to be available for the application.

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.

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 dongle or development kit, test it by performing the following steps:

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

  2. Reset the kit.

  3. Start the nRF Connect for Mobile application on your smartphone or tablet.

    The device is advertising as Nordic multi adv sets and Nordic Beacon.

  4. Select the connectable variant and connect to the device from the application.

  5. In the SCANNER tab check if Nordic Beacon is still advertising.

    You can use it to open the Nordic website.

  6. Disconnect from the device.

  7. In the SCANNER tab, check again if there is an advertiser with the name Nordic multi adv sets.

Dependencies

This sample uses the following nRF Connect SDK libraries:

In addition, it uses the following Zephyr libraries:

  • include/kernel.h

  • API:

    • include/bluetooth/bluetooth.h

    • include/bluetooth/conn.h

    • include/bluetooth/uuid.h

    • include/bluetooth/services/dis.h

The sample also uses the following secure firmware component: