Unable to add multiple peripheral connections on my nrf52840 dongle

I think this code snippet is causing the issue, since I am able to make the device work by setting:

'NRF_SDH_BLE_PERIPHERAL_LINK_COUNT = 1' and
'NRF_SDH_BLE_TOTAL_LINK_COUNT = 1',

however it doesn't work upon setting it to more than one.

I think this code snippet is causing some issue, please help me out if anyone has resolved this!

/**@brief Function for handling the Connected event.
 *
 * @param[in] p_gap_evt GAP event received from the BLE stack.
 */
static void on_connected(const ble_gap_evt_t *const p_gap_evt) {
  ret_code_t err_code;
  uint32_t periph_link_cnt = ble_conn_state_peripheral_conn_count();    // Number of peripheral links.

  NRF_LOG_INFO("Connection with link 0x%x established.", p_gap_evt->conn_handle);

  // Assign connection handle to available instance of QWR module.
  for (uint32_t i = 0; i < NRF_SDH_BLE_PERIPHERAL_LINK_COUNT; i++) {
    if (m_qwrs[i].conn_handle == BLE_CONN_HANDLE_INVALID) {
      err_code = nrf_ble_qwr_conn_handle_assign(&m_qwrs[i], p_gap_evt->conn_handle);
      APP_ERROR_CHECK(err_code);
      break;
    }
  }

  err_code = app_button_enable();
  APP_ERROR_CHECK(err_code);

  // Update LEDs
  bsp_board_led_on(CONNECTED_LED);
  if (periph_link_cnt == NRF_SDH_BLE_PERIPHERAL_LINK_COUNT) {
    bsp_board_led_off(ADVERTISING_LED);
  } else {
    // Continue advertising. More connections can be established because the maximum link count has not been reached.
    advertising_start();
  }
}
Github

Related