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

Central connects, buts reads give NRF_ERROR_BUSY?

Hello,

I am building a Central app based on the UART example central to replace an existing BLE soc that is no longer available.

The Sensors are custom with fixed characteristics and handles.  The Discovery mode is not run during connecting to save

power.  After the BLE_GAP_EVT_CONNECTED event is received, we are trying to read characteristics from the sensor, but no luck so far.

Within the connect event, I try to read the connected sensor's characteristic, see the test code below.  There does not appear that any

request went out over the air when viewing a BLE sniffer, and there is no READ RESPONSE event?

Thanks,

Dan  

static void ble_evt_handler(ble_evt_t const * p_ble_evt, void * p_context)
{
    ret_code_t            err_code;
    ble_gap_evt_t const * p_gap_evt = &p_ble_evt->evt.gap_evt;

    switch (p_ble_evt->header.evt_id)
    {
        case BLE_GAP_EVT_CONNECTED:
            // set the connection and characteristic handles.
            NRF_LOG_INFO("CONNECT HANDLE = %d", p_ble_evt->evt.gap_evt.conn_handle);
            //err_code = cble_nus_c_handles_assign(&m_ble_nus_c, p_ble_evt->evt.gap_evt.conn_handle);
            err_code = cble_nus_c_handles_assign(&m_ble_nus_c, p_ble_evt->evt.gap_evt.conn_handle);
            APP_ERROR_CHECK(err_code);
        
            err_code = bsp_indication_set(BSP_INDICATE_CONNECTED);
            APP_ERROR_CHECK(err_code);

            // start discovery of services. The NUS Client waits for a discovery result
           //err_code = ble_db_discovery_start(&m_db_disc, p_ble_evt->evt.gap_evt.conn_handle);
           //APP_ERROR_CHECK(err_code);
           //cble_nus_c_read_sensor(&m_ble_nus_c);
            //cble_nus_c_StartPwAuthenticate(&m_ble_nus_c);sd_ble_gattc_read
            NRF_LOG_DEBUG("SEND READ TO HANDLE, CHAR HANDLE %d, %d", p_ble_evt->evt.gap_evt.conn_handle,(uint16_t)BLE_HANDLE_MSENSE_SENSOR_CHARACTERISTIC);
            do{ 
             NRF_LOG_DEBUG("RETRY % %d", err_code);  
             err_code = sd_ble_gattc_read(p_ble_evt->evt.gap_evt.conn_handle,
                                           (uint16_t)BLE_HANDLE_MSENSE_SENSOR_CHARACTERISTIC,
                                            0);
           }while(err_code == NRF_ERROR_BUSY);
            // 

Parents
  • Hi Jared,

    Thank you for the suggestion, it helped me find the problem.  As you suggested, I re-started the discovery process when the CONNECTED event was received and waited for that to complete.   The Discovery was also delay due to the SD being busy, NRF_ERROR_BUSY.  There was something else holding up the SD.  We found that the App was requesting a larger MTU packet size which our peripheral sensors will not accept.  The MTU negotiation timed out the connection.  That was the root cuase.

    I changed the gatt_init() function as shown below, and was able to read sensor values after the connection was made with no trouble.

    Thanks a lot.  Now we can continue on.

    Dan

  • Dan,

    Good job finding the root cause, and returning with a description of the solution. Hopefully this will help others that are stuck with the same issue later.

    best regards

    Jared 

Reply Children
No Data
Related