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

  • Hi, thanks for the hint. I made the proposed changes but it does not help. The ble_nus_c_on_db_disc_evt() is called in the db_disc_handler. I see the db_disc_handler seems for me to have a problem.

    After the 4 Line: Connected to target: handle 0 I call the ble_db_discovery_start(). This calls several time the db_disc_handler() with event 1 (= BLE_DB_DISCOVERY_ERROR). After I while the db_disc_handler() with event 0 (= BLE_DB_DISCOVERY_COMPLETE) is called 7 times. Each time in the db_disc_handler() the ble_nus_c_on_db_disc_evt() is called.

  • Until this is fixed I don't see much workaround other than ignore the additional duplicate events that occur for the same channel. Maybe it's possible to somehow uninit() and init() the module again after service discovery, but not sure if that is a better idea either.

Related