This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Multiperipheral UART Example

I am using 3 nrf52 DKs with S132 and SDK14 / and SDK15 to try and implement a combination of the multilink and UART examples. I started with the ble_app_uart_c example and added the relevant code from the ble_app_multilink_central example to connect to multiple (in my case 2) peripherals.

If I call in the ble_evt_handler() in case BLE_GAP_EVT_CONNECTED the function scan_start(); then the ble_nus_c_evt_handler() with the case BLE_NUS_C_EVT_DISCOVERY_COMPLETE is called three times. If I don't call the scan_start() function in the BLE_GAP_EVT_CONNECTED case the BLE_NUS_C_EVT_DISCOVERY_COMPLETE  is called only ones.

But in both cases the central is not connecting to the second peripheral. As soon as I switch of the connected peripheral, the other peripheral is connecting and exchanging datas.

What do I miss that I can connect to the two peripherals at the same time?

Thanks

Parents
  • Hi, I guess there may be several things here, but a few for a starter:


    1. How many central links have you configured the stack to support?

    This is typically configured in nrf_sdh_ble_default_cfg_set():
    ble_cfg.gap_cfg.role_count_cfg.central_role_count = ?;
    sd_ble_cfg_set(BLE_GAP_CFG_ROLE_COUNT, &ble_cfg, *p_ram_start);


    2. After calling scan_start() the softdevice will be scanning for devices, and thereby the softdevice will typically generate BLE_GAP_EVT_ADV_REPORT events. Depending on the advertisement data, the application may then decide to connect to the peripheral by calling sd_ble_gap_connect(). What are the parameters used to connect?

    It is for instance a good idea to have a reasonable timeout for SCAN_TIMEOUT (instead of 0 infinite timeout), such that if no peripheral connects within a few seconds (for instance 2 seconds), then the application will receive a BLE_GAP_EVT_TIMEOUT, and then the application can call scan_start() waiting for next advertisment report.

  • Hi, thanks for the information:

    in the sdk_config.h file I changed only the NRF_SDH_BLE_TOTAL_LINK_COUNT,  but the NRF_SDH_BLE_CENTRAL_LINK_COUNT remaind on the default value. After changing this definition I can connect the several peripherals.

    But the "problem" that connection 0 is calling the le_nus_c_evt_handler() with event BLE_NUS_C_EVT_DISCOVERY_COMPLETE remains. see the screenshot from the NRF_LOG INFOS.

Reply
  • Hi, thanks for the information:

    in the sdk_config.h file I changed only the NRF_SDH_BLE_TOTAL_LINK_COUNT,  but the NRF_SDH_BLE_CENTRAL_LINK_COUNT remaind on the default value. After changing this definition I can connect the several peripherals.

    But the "problem" that connection 0 is calling the le_nus_c_evt_handler() with event BLE_NUS_C_EVT_DISCOVERY_COMPLETE remains. see the screenshot from the NRF_LOG INFOS.

Children
Related