| nRF5 SDK v12.0.0 |

Choose documentation: | nRF5 SDK | S130 SoftDevice API | S132 SoftDevice API | S212 SoftDevice API | S332 SoftDevice API

All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
Experimental: BLE Relay Example
This example requires one of the following SoftDevices: S130, S132

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 S13x 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 Master Control Panel 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

The application includes services from two profiles:

- Running Speed and Cadence Service
- Heart Rate Service

# 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:

- LED 1: Central side is scanning.
- LED 2: Central side is connected to a peripheral.
- LED 3: Peripheral side is advertising.
- LED 4: Peripheral side is connected to a central.

The application uses the following UART settings:

- Baud rate: 115.200
- 8 data bits
- 1 stop bit
- No parity
- HW flow control: RTS/CTS

# Testing

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

- 1 relay board: nRF5 Development Kit board containing the S13x SoftDevice.
- 2 sensor boards: nRF5 Development Kit board containing the S13x SoftDevice. One of the boards should be running the Running Speed and Cadence Application example. The other one should be running the Heart Rate Application example.

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 Master Control Panel. The application advertises as 'NordicRelay'.
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 Master Control Panel 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.