This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

BLE peripheral that supports 2 simultaneous connections with nRF Connect SDK 1.8

When using nRF Connect SDK v1.6.1, a BLE peripheral that supports 2 simultaneous connections could be created by including these lines in prj.conf. These lines set the Link Layer choice to be the Nordic Semiconductor Softdevice that supports multiple simultaneous connections, and configure it to support 2 connections. 

# Support connection of 2 central devices to the BLE peripheral
CONFIG_BT_LL_SOFTDEVICE_DEFAULT=y
CONFIG_BT_MAX_CONN=2
CONFIG_BT_MAX_PAIRED=2

Then, after the first BLE central device had connected, connectable advertising was re-enabled by including this code snippet in the connected callback:

// enable CONNECTABLE advertising when first connection has been established
int adv_err = bt_le_adv_start(BT_LE_ADV_CONN, ad, ARRAY_SIZE(ad), sd, ARRAY_SIZE(sd));
printk("Start advertising while connected (adv_err %d)\n", adv_err);

When I build my application using nRF Connect SDK v1.8, this process no longer works. The line CONFIG_BT_LL_SOFTDEVICE_DEFAULT=y results in a build error. I consulted the documentation for SDK v1.8, which states that BT_LL_SOFTDEVICE is now the default Link Layer option, so I figured I could just delete this line and everything would work as before.

However, that is not the case. After removing the line CONFIG_BT_LL_SOFTDEVICE_DEFAULT=y from prj.conf, the call to bt_le_adv_start() when one central device is already connected returns error code -111, which is this definition:

#define ECONNREFUSED 111 /**< Connection refused */

When I step into the SDK code with a debugger, I find that the root cause is failure of the call to bt_hci_cmd_send_sync(BT_HCI_OP_LE_SET_ADV_ENABLE, buf, NULL). This HCI command fails and returns status code BT_HCI_ERR_CONN_LIMIT_EXCEEDED. In other words, the Link Layer only supports a single BLE connection.

What is the correct way to configure support for 2 simultaneous BLE connections to a Peripheral, using SDK 1.8?  I do not want to switch to using the Zephyr software BLE Link Layer ULL LLL split implementation (BT_LL_SW_SPLIT) because that choice is marked as "EXPERIMENTAL" - which makes it unsuitable for production use.

Related