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

issue about Ram setting and NRF_ERROR_RESOURCES:

Hi:

  I'm developing a project with  nRF 58232 in ble_app_hrs_rscs_relay example ( s132  sdk:nRF5SDK160098a08e2 ). The device need to be central and peripheral,My device worked fine as peripheral with smart phone. After that I tried to make the device  connect to the smart phone first, and then connect to other device as central. My device worked fine as  central and peripheral at first. But I got [NRF_ERROR_RESOURCES]  error after a while.

<info> app: Peer Temp.

<debug> ble_private_c: send data to peripheral

<debug> nrf_ble_gq: Adding item to the request queue

<debug> nrf_ble_gq: GATTC Write Request

<debug> nrf_ble_gq: SD GATT procedure (1) succeeded on connection handle: 0.

<debug> nrf_ble_gq: Processing the request queue...

<debug> nrf_ble_gq: Processing the request queue...

<debug> ble_private_c: Received HVX on link 0x16, hrm_handle 0x16

<debug> ble_private_c: Received HVX on link 0x16, hrm_handle 0x16

<info> app: Temp Respond.

<info> app: Peer Temp.

<debug> ble_private_c: send data to peripheral

<debug> nrf_ble_gq: Adding item to the request queue

<debug> nrf_ble_gq: GATTC Write Request

<debug> nrf_ble_gq: SD GATT procedure (1) succeeded on connection handle: 0.

<debug> nrf_ble_gq: Processing the request queue...

<debug> nrf_ble_gq: Processing the request queue...

<debug> ble_private_c: Received HVX on link 0x16, hrm_handle 0x16

<debug> ble_private_c: Received HVX on link 0x16, hrm_handle 0x16

<info> app: Temp Respond.

<error> app: ERROR 19 [NRF_ERROR_RESOURCES] at :0PC at: 0x00000000
<error> app: End of error report
 

I seeked the answer for NRF_ERROR_RESOURCES in DevZone.I found it might be caused by size of BLE_GATTS_HVN_TX_QUEUE_SIZE_DEFAULT or BLE_GATTC_WRITE_CMD_TX_QUEUE_SIZE_DEFAULT. So I changed the size of both BLE_GATTS_HVN_TX_QUEUE_SIZE_DEFAULT  and BLE_GATTC_WRITE_CMD_TX_QUEUE_SIZE_DEFAULT to 3. Unfortunately I got an unknown error after my device conneted to peripheral.

<info> app: Peripheral connected

<info> app: Central connected<info> app: Attempt to find Peripheral on conn_handle 0x0

<debug> nrf_ble_gq: Registering connection handle: 0x0000

<debug> ble_db_disc: Starting discovery of service with UUID 0xFF00 on connection handle 0x0.

<debug> nrf_ble_gq: Adding item to the request queue

<debug> nrf_ble_gq: GATTC Primary Services Discovery Request

<debug> nrf_ble_gq: SD GATT procedure (2) succeeded on connection handle: 0.

<info> app: Peer Connect.

<debug> nrf_ble_gq: Processing the request queue...
<debug> ble_db_disc: Found service UUID 0xFF00.<debug> nrf_ble_gq: Adding item to the request queue
<debug> nrf_ble_gq: GATTC Characteristic Discovery Request
<debug> nrf_ble_gq: SD GATT procedure (3) succeeded on connection handle: 0.

<error> app: ERROR 13313 [Unknown error code] at :0PC at: 0x00000000
<error> app: End of error report

And I haven't changed the ram setting after BLE_GATTS_HVN_TX_QUEUE_SIZE_DEFAULT  and  BLE_GATTC_WRITE_CMD_TX_QUEUE_SIZE_DEFAULT were modified.If it needed to modify the ram,how much ram I need to increase in MDK setting If  I increase 1 in BLE_GATTC_WRITE_CMD_TX_QUEUE_SIZE_DEFAULT or

 BLE_GATTS_HVN_TX_QUEUE_SIZE_DEFAULT  . 

Maybe I get a wrong way to fix NRF_ERROR_RESOURCES. Please tell me what do I miss.

My second problem is about the Ram setting for  __HEAP_SIZE. I had changed NRF_BLE_GQ_GATTS_HVX_MAX_DATA_LEN and NRF_BLE_GQ_GATTC_WRITE_MAX_DATA_LEN to 20.And I found gattc_write_alloc and gatts_hvx_alloc had called nrf_balloc_alloc.But __HEAP_SIZE is zero in ble_app_hrs_rscs_relay example. Did I need to change __HEAP_SIZE. If __HEAP_SIZE need to be changed, I need to change ram setting, right?My ram setting is default in ble_app_hrs_rscs_relay example.

Parents
  • I found I got "private gatts hvx" before I got " ERROR 13313 [Unknown error code]" every time.

    uint32_t ble_private_notify(ble_private_t * p_private, uint8_t * sendData)
    {
        uint32_t err_code;
    
        // Send value if connected and notifying
        if( ( p_private->conn_handle != BLE_CONN_HANDLE_INVALID )&&
    				( p_private->notify_status == BLE_PRIVATE_EVT_NOTIFICATION_ENABLED ) )
        {
            uint16_t               hvx_len;
            ble_gatts_hvx_params_t hvx_params;
    
            hvx_len = 20;
    
            memset(&hvx_params, 0, sizeof(hvx_params));
    
            hvx_params.handle = p_private->notify_handles.value_handle;
            hvx_params.type   = BLE_GATT_HVX_NOTIFICATION;
            hvx_params.offset = 0;
            hvx_params.p_len  = &hvx_len;
            hvx_params.p_data = sendData;
    			
    			 NRF_LOG_DEBUG("private gatts hvx");
    
            err_code = sd_ble_gatts_hvx(p_private->conn_handle, &hvx_params);
            if ((err_code == NRF_SUCCESS) && (hvx_len != 20))
            {
                err_code = NRF_ERROR_DATA_SIZE;
            }
        }
        else
        {
            err_code = NRF_ERROR_INVALID_STATE;
        }
    
        return err_code;
    }

    <debug> ble_private: private gatts hvx
    
    <error> app: ERROR 13313 [Unknown error code] at :0
    
    PC at: 0x00000000
    
    <error> app: End of error report

    So I tried to fix it by placing "sd_ble_gatts_sys_attr_set(pre_conn_handle_peripheral_c, NULL, 0, 0)" there.

    /**@brief   Function for handling BLE events from the central application.
     *
     * @details This function parses scanning reports and initiates a connection to peripherals when a
     *          target UUID is found. It updates the status of LEDs used to report the central application
     *          activity.
     *
     * @param[in]   p_ble_evt   Bluetooth stack event.
     */
    static void on_ble_central_evt(ble_evt_t const * p_ble_evt)
    {
        ret_code_t            err_code = 0;
        ble_gap_evt_t const * p_gap_evt = &p_ble_evt->evt.gap_evt;
    
        switch (p_ble_evt->header.evt_id)
        {
            // Upon connection, check which peripheral is connected (HR or RSC), initiate DB
            // discovery, and stop scanning.
            case BLE_GAP_EVT_CONNECTED:
            {
                NRF_LOG_INFO("Central connected");
                // If no Heart Rate sensor or RSC sensor is currently connected, try to find them on this peripheral.
                if ( m_conn_handle_peripheral_c == BLE_CONN_HANDLE_INVALID )
                {
                    NRF_LOG_INFO("Attempt to find Peripheral on conn_handle 0x%x", p_gap_evt->conn_handle);
    
                    err_code = ble_db_discovery_start(&m_db_discovery[0], p_gap_evt->conn_handle);
    								APP_ERROR_CHECK(err_code);
                }
    						pre_conn_handle_peripheral_c = p_gap_evt->conn_handle;
    						
                // Assign connection handle to the QWR module.
                multi_qwr_conn_handle_assign(p_gap_evt->conn_handle);
    						
    						//BLE_GATTS_EVT_SYS_ATTR_MISSING			//JAM 2020-4-21
    						err_code = sd_ble_gatts_sys_attr_set(pre_conn_handle_peripheral_c, NULL, 0, 0);
    						APP_ERROR_CHECK(err_code);
    						
    						// Stop scanning.
    						//nrf_ble_scan_stop( );
    						
    				#ifdef PA_ENABLE 
    						if ( m_conn_handle_peripheral_c != BLE_CONN_HANDLE_INVALID )
    						 {
    								err_code = sd_ble_gap_tx_power_set( BLE_GAP_TX_POWER_ROLE_CONN, pre_conn_handle_peripheral_c, SCAN_TX_POWER );
    								APP_ERROR_CHECK(err_code);
    						 }
    				#endif
    						
            } break; // BLE_GAP_EVT_CONNECTED
     ..............................................................
     }

    But I got "app: ERROR 8 [NRF_ERROR_INVALID_STATE]".

    [2020-04-21 19:01:04.288]# RECV ASCII>
    info> app: Peer Verify Success.
    
    <info> app: wait for bond.
    
    <info> app: Pair Peer.
    
    <debug> ble_private_c: send data to peripheral
    
    <debug> nrf_ble_gq: Adding item to the request queue
    
    <debug> nrf_ble_gq: GATTC Write Request
    
    <debug> nrf_ble_gq: SD GATT procedure (1) succeeded on connection handle: 0.
    
    <debug> nrf_ble_gq: Processing the request queue...
    
    
    
    [2020-04-21 19:01:04.638]# RECV ASCII>
    <info> app: Verify time out.
    
    <debug> app: Queue time. 2
    
    
    
    [2020-04-21 19:01:05.087]# RECV ASCII>
    <debug> ble_private: private gatts hvx
    
    <error> app: ERROR 8 [NRF_ERROR_INVALID_STATE] at :0
    
    PC at: 0x00000000
    
    <error> app: End of error report

Reply
  • I found I got "private gatts hvx" before I got " ERROR 13313 [Unknown error code]" every time.

    uint32_t ble_private_notify(ble_private_t * p_private, uint8_t * sendData)
    {
        uint32_t err_code;
    
        // Send value if connected and notifying
        if( ( p_private->conn_handle != BLE_CONN_HANDLE_INVALID )&&
    				( p_private->notify_status == BLE_PRIVATE_EVT_NOTIFICATION_ENABLED ) )
        {
            uint16_t               hvx_len;
            ble_gatts_hvx_params_t hvx_params;
    
            hvx_len = 20;
    
            memset(&hvx_params, 0, sizeof(hvx_params));
    
            hvx_params.handle = p_private->notify_handles.value_handle;
            hvx_params.type   = BLE_GATT_HVX_NOTIFICATION;
            hvx_params.offset = 0;
            hvx_params.p_len  = &hvx_len;
            hvx_params.p_data = sendData;
    			
    			 NRF_LOG_DEBUG("private gatts hvx");
    
            err_code = sd_ble_gatts_hvx(p_private->conn_handle, &hvx_params);
            if ((err_code == NRF_SUCCESS) && (hvx_len != 20))
            {
                err_code = NRF_ERROR_DATA_SIZE;
            }
        }
        else
        {
            err_code = NRF_ERROR_INVALID_STATE;
        }
    
        return err_code;
    }

    <debug> ble_private: private gatts hvx
    
    <error> app: ERROR 13313 [Unknown error code] at :0
    
    PC at: 0x00000000
    
    <error> app: End of error report

    So I tried to fix it by placing "sd_ble_gatts_sys_attr_set(pre_conn_handle_peripheral_c, NULL, 0, 0)" there.

    /**@brief   Function for handling BLE events from the central application.
     *
     * @details This function parses scanning reports and initiates a connection to peripherals when a
     *          target UUID is found. It updates the status of LEDs used to report the central application
     *          activity.
     *
     * @param[in]   p_ble_evt   Bluetooth stack event.
     */
    static void on_ble_central_evt(ble_evt_t const * p_ble_evt)
    {
        ret_code_t            err_code = 0;
        ble_gap_evt_t const * p_gap_evt = &p_ble_evt->evt.gap_evt;
    
        switch (p_ble_evt->header.evt_id)
        {
            // Upon connection, check which peripheral is connected (HR or RSC), initiate DB
            // discovery, and stop scanning.
            case BLE_GAP_EVT_CONNECTED:
            {
                NRF_LOG_INFO("Central connected");
                // If no Heart Rate sensor or RSC sensor is currently connected, try to find them on this peripheral.
                if ( m_conn_handle_peripheral_c == BLE_CONN_HANDLE_INVALID )
                {
                    NRF_LOG_INFO("Attempt to find Peripheral on conn_handle 0x%x", p_gap_evt->conn_handle);
    
                    err_code = ble_db_discovery_start(&m_db_discovery[0], p_gap_evt->conn_handle);
    								APP_ERROR_CHECK(err_code);
                }
    						pre_conn_handle_peripheral_c = p_gap_evt->conn_handle;
    						
                // Assign connection handle to the QWR module.
                multi_qwr_conn_handle_assign(p_gap_evt->conn_handle);
    						
    						//BLE_GATTS_EVT_SYS_ATTR_MISSING			//JAM 2020-4-21
    						err_code = sd_ble_gatts_sys_attr_set(pre_conn_handle_peripheral_c, NULL, 0, 0);
    						APP_ERROR_CHECK(err_code);
    						
    						// Stop scanning.
    						//nrf_ble_scan_stop( );
    						
    				#ifdef PA_ENABLE 
    						if ( m_conn_handle_peripheral_c != BLE_CONN_HANDLE_INVALID )
    						 {
    								err_code = sd_ble_gap_tx_power_set( BLE_GAP_TX_POWER_ROLE_CONN, pre_conn_handle_peripheral_c, SCAN_TX_POWER );
    								APP_ERROR_CHECK(err_code);
    						 }
    				#endif
    						
            } break; // BLE_GAP_EVT_CONNECTED
     ..............................................................
     }

    But I got "app: ERROR 8 [NRF_ERROR_INVALID_STATE]".

    [2020-04-21 19:01:04.288]# RECV ASCII>
    info> app: Peer Verify Success.
    
    <info> app: wait for bond.
    
    <info> app: Pair Peer.
    
    <debug> ble_private_c: send data to peripheral
    
    <debug> nrf_ble_gq: Adding item to the request queue
    
    <debug> nrf_ble_gq: GATTC Write Request
    
    <debug> nrf_ble_gq: SD GATT procedure (1) succeeded on connection handle: 0.
    
    <debug> nrf_ble_gq: Processing the request queue...
    
    
    
    [2020-04-21 19:01:04.638]# RECV ASCII>
    <info> app: Verify time out.
    
    <debug> app: Queue time. 2
    
    
    
    [2020-04-21 19:01:05.087]# RECV ASCII>
    <debug> ble_private: private gatts hvx
    
    <error> app: ERROR 8 [NRF_ERROR_INVALID_STATE] at :0
    
    PC at: 0x00000000
    
    <error> app: End of error report

Children
No Data
Related