I am using the UART central, integrated with peer manager and UART peripheral application from the SDK 15.3 on our custom hardware.
I have 2 centrals running exactly same firmware and one peripheral device that sends periodic data. In our system, both centrals are powered on together. We want only one (any one) central to get paired with the peripheral so that the other central is available for other devices.
In my application, on the central, in the event BLE_GAP_EVT_ADV_REPORT, when I get a expected device name match in ble_advdata_search(), I stop scanning and on peripheral, when I get BLE_GAP_EVT_CONNECTED, I stop advertising. This is what we want according to the design. This works well most of the times.
However, sometimes, when the 2 centrals are powered on together, I get a device name match on both centrals. One of them gets paired and starts receiving the periodic data from peripheral through event BLE_NUS_C_EVT_NUS_TX_EVT. But the other central gets 'stuck'. Through debugging, I found that on this other central device, it gets a match on device name but after that, no BLE events are triggered (no calls to ble_nus_c_evt_handler or ble_evt_handler). This is probably because the peripheral has already established connection with the other central device and stopped advertising. I can bring this stuck central out of this condition only by either rebooting the peripheral device or by rebooting the central.
Please suggest on the best way to get the central out of this condition.