In this blog, I would share how to create the multiple role concurrently example on nRF5 SDK. It would cover how to do the multiple peripheral role, single central role to connect multiple peripherals, combo example (2 x peripheral role + 2 x central role) concurrently. This example is based on the Nordic NRF5 SDK 15.3 and can run on the nRF52832 and nRF52840 chipset.
I also plan to do the multiple role such as 2 x central + 2 x peripheral on the limited resource nRF52810. But it needs to optimize the flash size and memory usage such as MTU / DLE. I will post on such example later after I finish.
Regarding to the classic (BR/EDR) bluetooth, each node can connect up to maximum 7 devices [Link]. It calls the connection in a piconet network. The devices can switch roles, by agreement, and the slave can become the master.
Regarding to the Bluetooth Low Energy, after the bluetooth 4.1 specification, device has started to support the device to run multiple role (central/peripheral) concurrently.
On the Nordic Softdevice (Bluetooth Stack), S130 / S132 / S140 have started to support the multiple role. For example, S132v4.x or later has support up to 20 concurrent links in all roles. For example, if the device acts as central role, it can connect up to 20 peripherals. Also, if the device can connect multiple mobile at the same time by using peripheral role.
For example, this demo shows the multilink capabilities of the nRF52 Series SoCs and their associated stacks. Both the nRF52840 and the nRF52832 together with the S140 and S132 SoftDevices respectively can support 20 concurrent Bluetooth Low Energy connections.
At the Nordic Playground Github [Link], it shows the demo code how to implement an aggregator node, running on an nRF52DK or an nRF52840 DK. This aggregator can connect with an Android Host and 19 x peripheral devices (either DK or Thingy) at the same time.
Inside Nordic nRF5 SDK, it has the BLE mult-link central example which uses to connect more BLE Blinky Application as peripherals.
In this example, there are three difference roles.
- Peripheral role
- Central role
- 2 x Peripheral Role + 2 x Central Role
All of them contains the GATT Server / Client.
- NUS (Nordic UART Service)
- Image Transfer Service (ITS)
- BLE Blinky service (LBS)
/* Combo Role */ #define DEVICE_NAME "Multi_Role" /**< Name of device. Will be included in the advertising data. */ static char const m_target_periph_name = "LBS_NUS_Node"; /**< Name of the device we try to connect to. This name is searched in the scan report data*/
//Inside sdk_config.h, // <o> NRF_SDH_BLE_PERIPHERAL_LINK_COUNT - Maximum number of peripheral links. #ifndef NRF_SDH_BLE_PERIPHERAL_LINK_COUNT #define NRF_SDH_BLE_PERIPHERAL_LINK_COUNT 2 #endif // <o> NRF_SDH_BLE_CENTRAL_LINK_COUNT - Maximum number of central links. #ifndef NRF_SDH_BLE_CENTRAL_LINK_COUNT #define NRF_SDH_BLE_CENTRAL_LINK_COUNT 2 #endif // <o> NRF_SDH_BLE_TOTAL_LINK_COUNT - Total link count. // <i> Maximum number of total concurrent connections using the default configuration. #ifndef NRF_SDH_BLE_TOTAL_LINK_COUNT #define NRF_SDH_BLE_TOTAL_LINK_COUNT 4 #endif
- Peripheral Role — NRF52840 DK / NRF52832 DK
- Central Role — NRF52840 DK
- Combo Role — NRF52832 DK
- IDE Segger Embedded Studio