This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

[NRF51822] Function to check if BLE is connected or not

Is there a function within the nRF51822 SDK to check if BLE is connected or not (or to check general BLE connection state)?

Thanks.

Parents
  • I think you are supposed to handle the BLE events and remember the state your self. You can register to receive these events using softdevice_ble_evt_handler_set(ble_evt_dispatch) where your ble_evt_dispatch function looks like this :

    static void ble_evt_dispatch(ble_evt_t * p_ble_evt) { switch (p_ble_evt->header.evt_id) { case BLE_GAP_EVT_CONNECTED: connected = true; break;

        case BLE_GAP_EVT_DISCONNECTED:
            connected = false;
            break;
            
        default:
            break;
    }
    

    }

Reply
  • I think you are supposed to handle the BLE events and remember the state your self. You can register to receive these events using softdevice_ble_evt_handler_set(ble_evt_dispatch) where your ble_evt_dispatch function looks like this :

    static void ble_evt_dispatch(ble_evt_t * p_ble_evt) { switch (p_ble_evt->header.evt_id) { case BLE_GAP_EVT_CONNECTED: connected = true; break;

        case BLE_GAP_EVT_DISCONNECTED:
            connected = false;
            break;
            
        default:
            break;
    }
    

    }

Children
Related