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

How to check connection is being established?

Hi,

We want to have same key for handling accept for LESC pairing  and sleep mode if BLE is in advertising.

The implementation is based on ble_app_hrs_pca10040_s132. 

SDK: nRF5_SDK_16.0.0

How do I check the connection is being established?

=>To ignore the keypress in case BSP_EVENT_SLEEP.

void bsp_event_handler(bsp_event_t event)
{
    switch (event)
    {
        case BSP_EVENT_SLEEP:
            if (connection is being established or connected )
            {
                //do nothing       
            }
            else
            {
                sleep_mode_enter();
            }
            break;
        case BSP_EVENT_KEY_0:
            NRF_LOG_INFO("BSP_EVENT_KEY_0 m_conn_handle %d", m_conn_handle);
            if ((m_conn_handle != BLE_CONN_HANDLE_INVALID)
                  && (fg_accept == false)
                 ){
                  NRF_LOG_INFO("press BSP_EVENT_KEY_0 accept");
  
                  on_num_comp_button_press(true);
                  fg_accept = true;
              
            }
            break;
            ...
        }
    }
}

Thanks. Vick

Related