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

NRF_ERROR_RESOURCES occurred when the connection is disconnected

Dear

First of all, I am so sorry because of my english skill.

I got NRF_ERROR_RESOURCES when the connection between NRF Module and mobile device is disconnected  due to the reduced signal strength because of long distance.

However, if I disconnect the connection by sending the disconnection command from mobile device, it works well without any errors.

I used app_timer_start api to send data for notification every 1s as following,

err_code = app_timer_start(m_bms_measurement1_timer_id, BMS_MEASUREMENT1_TIMER_INTERVAL, NULL);
APP_ERROR_CHECK(err_code);

I already set NRF_SDH_BLE_GAP_EVENT_LENGTH as 100 and used BLE_GATTS_EVT_HVN_TX_COMPLETE.

But I had same result as before.

Thanks in advance.

  • Hello,

    ble_cus_bms_measurement1_update function works every 1s.

    I also have ble_cus_bms_measurement2_update which works every 3 s.

    Thanks.

  • That sounds strange - this should mean that there would be no resource issues at all, since the connection events happens way more often than the queueing of new notifications.

    What is the value of the HVN_COMPLETE event's count when you receive it?

    Are you familiar with the nRF Sniffer tool? It is a powerful tool to wield when developing BLE applications as it lets you see all the on-air traffic. It would be very helpful if you could capture a sniffer trace of your communication with the device, so we may see what is actually being transmitted, and how often it is transmitted.

    EarlBread said:
    ble_cus_bms_measurement2_update

    Could you show me the contents of this function as well?

    Best regards,
    Karl

  • Hello,

    I have no any error message during connection and notification and disconnect command from mobile. I just had NRF_ERROR_RESOURCES due to disconnection with weak signal because of long distance.

    I set the break point at BLE_GAP_EVT_DISCONNECTED on ble_evt_handler. but NRF_ERROR_RESOURCES occurred more faster than BLE_GAP_EVT_DISCONNECTED. Therefore, I counldn't to reach at BLE_GAP_EVT_DISCONNECTED.

    How can I get the value of the HVN_COMPLETE event's count? 

    I am not  familiar with the nRF Sniffer tool

    Thanks.

  • EarlBread said:
    I have no any error message during connection and notification and disconnect command from mobile. I just had NRF_ERROR_RESOURCES due to disconnection with weak signal because of long distance.

    Aha, I understand.
    How often does the device go out of range, and how important is it that no data is lost?
    You could for example implement error handling that buffers the data that was not queued with the sd_ble_gatts_hvx call, and instead retries to queue it once a _HVN_TX_COMPLETE event is received, or similar. How would this fit with your applications requirements and constraints?

    EarlBread said:
    How can I get the value of the HVN_COMPLETE event's count? 

    The count can be read from the HVN_TX_COMPLETE event received after a successful notification transmission.

    EarlBread said:
    I am not  familiar with the nRF Sniffer tool

    I highly recommend familiarizing with this tool. It might not be necessary for the exact issue we are working with right now - since the conditions for it seems so clear at the moment - but it will definitively be useful for future debugging.

    Best regards,
    Karl

  • Hello,

    Out of range will be happen randomly depend on customer.

    I found little bit difference result without extend buffer and any action.

    I didn't have NRF_ERROR_RESOURCES any more. What can I do?

    If I use internal pullup resistor for GPIO pin,  I don't need to use the external pull up resistor?

    I just delete checking function as followings

    ble_measurement_timeout_handler runs every 1sec. this is original code

    static void ble_measurement1_timeout_handler(void * p_context)
    {
      ret_code_t err_code;
    
    
      UNUSED_PARAMETER(p_context);
    
      
      err_code = ble_cus_bms_measurement1_update(&m_cus, m_bms_measurement1, m_conn_handle);
      if (err_code != NRF_SUCCESS &&
          err_code != BLE_ERROR_INVALID_CONN_HANDLE &&
          err_code != NRF_ERROR_INVALID_STATE &&
          err_code != BLE_ERROR_GATTS_SYS_ATTR_MISSING)
      {
          APP_ERROR_CHECK(err_code);
      }
    
    }

    I modified as following,

     

    static void ble_measurement1_timeout_handler(void * p_context)
    {
      ret_code_t err_code;
    
    
      UNUSED_PARAMETER(p_context);
    
      ble_cus_bms_measurement1_update(&m_cus, m_bms_measurement1, m_conn_handle);
    }

    Here is ble_cus_bms_measurement_update

    uint32_t ble_cus_bms_measurement1_update(ble_cus_t * p_cus, struct bms_measurement1_s *m_bms_measurement, uint16_t conn_handle)
    {
        ble_gatts_hvx_params_t params;
        uint16_t len = sizeof(struct bms_measurement1_s);
    
        memset(&params, 0, sizeof(params));
        params.type   = BLE_GATT_HVX_NOTIFICATION;
        params.handle = p_cus->bms_measurement1_char_handles.value_handle;
        params.p_data = (uint8_t*)m_bms_measurement;
        params.p_len  = &len;
    
        return sd_ble_gatts_hvx(conn_handle, &params);
    }

    #define NRF_SDH_BLE_GAP_DATA_LENGTH 27

Related