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

Ble central : dont get BLE_DB_DISCOVERY_COMPLETE sometimes?

Hi, I am having 1 central and 2 peripherals. I use ble_app_hrs as the base for both. Sometimes, I dont get the BLE_DB_DISCOVERY_COMPLETE even after I get the BLE_GAP_EVT_CONNECTED. This happens more frequently when the connection is disconnected and reconnected again. Why is this happening? How do you recommend to handle this situation? Also, the program does not fire a breakpoint at gatt_evt_handler(). Hence, I manually check if the BLE_DB_DISCOVERY_COMPLETE and if it is then I scan_start again. Is this the right approach, or, should that be done inside gatt_evt_handler()?

  • Hi,

    What SDK version is this?

    In the unmodified examples(ble_app_hrs(_c)) you should get the BLE_DB_DISCOVERY_COMPLETE after each connection.

    Try to modify the db_disc_handler(), so it looks like this:

    static void db_disc_handler(ble_db_discovery_evt_t *p_evt)
    {
        if (p_evt->evt_type == BLE_DB_DISCOVERY_COMPLETE)
        {
            NRF_LOG_INFO("BLE_DB_DISCOVERY_COMPLETE");
        }
    
        ble_hrs_on_db_disc_evt(&m_hrs_c, p_evt);
        ble_bas_on_db_disc_evt(&m_bas_c, p_evt);
    }
    

    and see if you get the BLE_DB_DISCOVERY_COMPLETE printed in the log.

Related