##Introducing concurrent MultiLinks
I’d like to inform that it is possible to configure concurrent-multiple connections with several Centrals and Peripherals.
This behavior can be possible to use examples in the nRF5 SDK v13.
In the nRF5 SDK v13, “multiperipheral” example has been come newly.
So, “multilink_central” and “multiperipheral” can be used together.
##MultiLink examples in the nRF5 SDK v13
There are two multilink examples for Central and Peripheral which are located in the nRF5 SDK v13.
These solutions allow multi-connections from Peripherals as the Central Role and from Centrals as the Peripheral Role.
These examples are based on Blinky behavior and are using LED_BUTTON Service.
It doesn’t matter which example is used as the background.
In this blog, the “multilink_central” example has been the background and the “multiperipheral” example has been merged.
To verify easy, the connected Peripherals and Centrals are restricted only two each.
Add Peripheral Role to Multilink Central example code.
. Modify count value for PERIPHERAL_LINK_COUNT
In Main.c, link count value for Peripheral is 0.
So, change this value to some value user want.
#define PERIPHERAL_LINK_COUNT 0
#define PERIPHERAL_LINK_COUNT 2
. Copy and add defined values from code of multiperipheral example for the Peripheral Role.
#define DEVICE_NAME "Nordic_Blinky_Peripheral"
#define APP_ADV_INTERVAL 64
#define APP_ADV_TIMEOUT_IN_SECONDS BLE_GAP_ADV_TIMEOUT_GENERAL_UNLIMITED
#define MIN_CONN_INTERVAL MSEC_TO_UNITS(100, UNIT_1_25_MS)
#define MAX_CONN_INTERVAL MSEC_TO_UNITS(200, UNIT_1_25_MS)
#define CONN_SUP_TIMEOUT MSEC_TO_UNITS(4000, UNIT_10_MS)
#define FIRST_CONN_PARAMS_UPDATE_DELAY APP_TIMER_TICKS(20000)
#define NEXT_CONN_PARAMS_UPDATE_DELAY APP_TIMER_TICKS(5000)
#define MAX_CONN_PARAMS_UPDATE_COUNT 3
. Copy these functions from multiperipheral example and add to main.c
. Add ble_lbs.c to nRF_BLE_Sevice of Project.
And, declare a golbal variable for LED Button Service Instance.
static ble_lbs_t m_lbs;
Then, define BLE_LBS_ENABLED in sdk_config.h.
#define BLE_LBS_ENABLED 1
Last, include head file in main.c.
. Add initializing functions related with Peripheral Role to Main Function.
gap_params_init(); //Add for Peripheral Role
services_init(); //Add for Peripheral Role
advertising_init(); //Add for Peripheral Role
conn_params_init(); //Add for Peripheral Role
NRF_LOG_INFO("Multilink example started.\r\n");
advertising_start(); //Add for Peripheral Role
. In advertising_start(), one value should be changed.
static void advertising_start(void)
err_code = sd_ble_gap_adv_start(&adv_params, CONN_CFG_TAG BLE_CONN_CFG_TAG_DEFAULT);
If you use original value, you will get the Fatal situation.
. To allow second Central connection, should advertise again after connection with first Central.
static void on_ble_evt(ble_evt_t const * p_ble_evt)
if((ble_conn_state_n_peripherals() evt.gap_evt.conn_handle) == BLE_GAP_ROLE_PERIPH))
. Adjust RAM parameters.
After Flash, start address and size of RMA should be adjusted.
SDH:WARNING:RAM start should be adjusted to 0x20004e78.
SDH:WARNING:RAM size should be adjusted to 0xb188.
Start address and size of RAM can be changed due to amount of your modified codes.
For demonstration, more modified codes are needed.
To exchange data between a board with the Peripheral role and Central devices with Blinky behavior, LED Button Service has been added.
And, not used codes and functions have been deleted to avoid any confusion.
New behaviors have been assigned to LEDs and Buttons.
. Behaviors for LEDs and Buttons
As you know, there are 4 LEDs and Buttons in a nRF52 DK.
With MultiLink Demo, behaviors for LEDs and Buttons on the MultiLink Board are like below.
You can refer sample code here.
Multilink_Peripheral_Central : ble_app_multiConnection-Central_Peripheral.7z
In sample code, only allow the connection with two Peripherals and Centrals.
You can expand more Peripherals and Centrals if you want.