Hi,
I am working with nrf52-ble-app-uart-relay example from Nordic Playground github. I use SES IDE & nRF5_SDK_16.0.0. There is BLE event forwarding in ble_evt_handler() in main.c, so both server and client part of the example receive BLE GAP events. In app_nus_client_ble_evt_handler() and app_nus_server_ble_evt_handler(), I am trying to detect whether BLE_GAP_EVT_DISCONNECTED event is meant for central/client or peripheral/server part of the Relay example. I see that for Connect event, p_gap_evt->params.connected.role is read to determine whether the Connect event is meant for peripheral or central part of the relay example. This works fine. But when I tried to read same variable for Disconnect event, p_gap_evt->params.connected.role is 0 (invalid role) or sometimes a garbage number like 67,177, etc. (I know because I printed out that 'role' variable on Uart.) So I am unable to determine in firmware whether peripheral or central side received Disconnect event. How to determine in this example whether BLE_GAP_EVT_DISCONNECTED is meant for peripheral or central part of the Relay?
I want to use that event to turn off few GPIOs and timers.