nRF5 SDK v17.0.2
Experimental: BLE Relay Example
This example requires one of the following SoftDevices: S132, S140

Important: Before you run this example, make sure to program the SoftDevice.

This example application demonstrates a simple relay that receives values and passes them on. The application combines a collector part on one end and a sensor part on the other to show how the SoftDevice can be used to make a device simultaneously function as central and peripheral device. The application uses the Peer Manager module, which allows for encryption of both central and peripheral connections simultaneously.

The following figure shows how a heart rate sensor and a running speed sensor connect and interact with the relay in the same manner they would connect to a collector. In this case, the relay application acts as a central.

On the other side, a collector (such as nRF Connect or ble_app_hrs_c) connects and interacts with the relay in the same manner it would connect to a sensor. In this case, the relay application acts as a peripheral.

relay_example.svg
Relay example

The application includes services from two profiles:

Setup

You can find the source code and the project file of the example in the following folder: <InstallFolder>\examples\ble_central_and_peripheral\experimental\ble_app_hrs_rscs_relay

LED assignments:

The application uses the following UART settings:

Testing

Testing the application requires at least two boards (one relay and one sensor board). Preferably, you should use three boards:

The applications that are running on the sensor boards serve as a peer for the relay board that acts as a central.

Note
When testing, make sure that the peripheral sensor and the central collector actually connect to the relay and not directly to each other!

Test the BLE Relay Example application by performing the following steps:

  1. Compile the Relay Example application and program both the SoftDevice and the application on the relay board.
  2. On the Relay board, observe that LEDs 1 and 3 are on. This indicates that both the central and the peripheral side of the relay are looking for peers.
  3. Compile the Running Speed and Cadence Application and program both the SoftDevice and the application on a sensor board.
  4. Observe that the Running Speed and Cadence sensor is advertising.
  5. Observe that the Running Speed and Cadence sensor connects to the relay board. On the sensor board, the BSP_INDICATE_CONNECTED state is indicated. On the relay board, LED 2 will turn on.
  6. If you are testing with two sensor boards:
    1. Compile the Heart Rate Application and program both the SoftDevice and the application on the second sensor board.
    2. Observe that the Heart Rate sensor is advertising.
    3. Observe that the Heart Rate sensor connects to the relay board. On the sensor board, the BSP_INDICATE_CONNECTED state is indicated. On the relay board, LED 2 is on and LED 1 will turn off (because the application is now connected to both HRS and RSCS and therefore no longer scanning).
  7. Connect to the relay board using nRF Connect. The application advertises as 'nRF Relay'.
  8. Observe that LED 3 is turned off and LED 4 is turned on, which indicates that the relay board has stopped advertising and is in a connection.
  9. Use nRF Connect to discover services and enable notifications.
  10. Observe that both RSC Measurement (0x2A53) and HRS Measurement (0x2A37) are received, depending on which of the sensor boards are connected.

Documentation feedback | Developer Zone | Subscribe | Updated