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,

    You're doing a lot in the CONNECTED event. You need to wait for the discovery to complete before you start reading characteristics. See our central examples, for example ble_app_uart_c or ble_app_gatts.

    regards

    Jared 

Reply
  • Hi,

    You're doing a lot in the CONNECTED event. You need to wait for the discovery to complete before you start reading characteristics. See our central examples, for example ble_app_uart_c or ble_app_gatts.

    regards

    Jared 

Children
No Data
Related