Error NRF_ERROR_NO_MEM ble_nus_data_send on ble_app_hrs_rscs_relay

I try to add NUS service in example ble_app_hrs_rscs_relay.

I have fail on send data from "Relay" to smart phone iOS nRF Toolbox.

1. I have modify the MTU size .
#define NRF_SDH_BLE_GATT_MAX_MTU_SIZE 247 

2. I try to echo back the data as below code.

static void nus_data_handler(ble_nus_evt_t * p_evt)
{

    if (p_evt->type == BLE_NUS_EVT_RX_DATA)
    {
        uint32_t err_code;

        NRF_LOG_DEBUG("Received data from BLE eNUS. Writing data on UART.");
        NRF_LOG_HEXDUMP_DEBUG(p_evt->params.rx_data.p_data, p_evt->params.rx_data.length);

        for (uint32_t i = 0; i < p_evt->params.rx_data.length; i++)
        {
            do
            {
                if ((err_code != NRF_SUCCESS) && (err_code != NRF_ERROR_BUSY))
                {
                    NRF_LOG_ERROR("Failed receiving NUS message. Error 0x%x. ", err_code);
                    APP_ERROR_CHECK(err_code);
                }
            } while (err_code == NRF_ERROR_BUSY);
        }
        if (p_evt->params.rx_data.p_data[p_evt->params.rx_data.length - 1] == '\r')
        {
            while (app_uart_put('\n') == NRF_ERROR_BUSY);
        }

		
		{
			uint16_t index = 0;


		
			index = p_evt->params.rx_data.length;
			
			{
				NRF_LOG_DEBUG("Ready to send data over BLE NUS");
				NRF_LOG_HEXDUMP_DEBUG(p_evt->params.rx_data.p_data, index);
			
				do
				{
					err_code = ble_nus_c_string_send(&etest_m_nus_c, (uint8_t *)p_evt->params.rx_data.p_data, index);
					if ( (err_code != NRF_ERROR_INVALID_STATE) && (err_code != NRF_ERROR_BUSY) )
					{
						APP_ERROR_CHECK(err_code);
					}
				} while (err_code == NRF_ERROR_BUSY);
			
				index = 0;
			}

		if (ECHOBACK_BLE_UART_DATA)
			{
				// Send data back to smart phone.
				do
				{
					NRF_LOG_DEBUG("send data back smart phone over BLE NUS");
					NRF_LOG_HEXDUMP_DEBUG(p_evt->params.rx_data.p_data, index);

					err_code = ble_nus_data_send(&etest_m_nus, (uint8_t *)p_evt->params.rx_data.p_data, &index, etest_m_conn_handle_nus_c);		//test echo loop back

					if ((err_code != NRF_SUCCESS) && (err_code != NRF_ERROR_BUSY))
					{
						NRF_LOG_ERROR("Failed sending NUS message to smart phone. Error 0x%x. ", err_code);
						APP_ERROR_CHECK(err_code);
					}
				} while (err_code == NRF_ERROR_BUSY);
		}

    	}
		
    }

}

3. Bellow is debug message.

<info> app: Dbg: BLE_NUS_C_EVT_NUS_TX_EVT.
<debug> app: Receiving data.
<debug> app: FF FF A1 46 00 19 |;..
<error> app: Failed sending NUS message. Error 0x4.
<error> app: ERROR 4 [NRF_ERROR_NO_MEM] at ..\..\..\main.c:496
PC at: 0x00028777
<error> app: End of error report

4. How did I enlarge the RAM size?

Thanks a lot 

Parents
  • Hi,

    I suspect the NO_MEM error is coming from link context manager and not related to the RAM base address. Can you check the return code from blcm_link_ctx_get() in ble_nus_data_send() to confirm? In that case you will have to increase the link count in your BLE_NUS_DEF() macro.

Reply Children