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

How to properly monitor for BLE GAP disconnect event?

I'm working on a proximity beacon application using the nRF51 DK and a Nordic Beacon. The application basically has the nRF51 DK connect to the Beacon and monitor the RSSI. If the RSSI changes dramatically, execute a series of actions. I am using S130 and SDK 12.1.

After connecting a multimeter to the Beacon to monitor current in uA's, I noticed that the multimeter was occasionally limiting the current and causing the Beacon to disconnect from the DK. It is specifically disconnecting in the ble_db_discovery_on_ble_evt() function in ble_db_discovery.c with event "BLE_GAP_EVT_DISCONNECTED". When this happens, my application just hangs. I suspect that this scenario could also occur with a weak or dying battery.

In this scenario, I would like to properly disconnect and re-start scanning. Is there a function that I can use within my main loop to poll whether or not GAP is not disconnected without using a global flag?

Related