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

at_cmd_write return ENOMEM (not enough space) after a few times activate and deactivate lte ?

Hi!

I'm using  nrf sdk v1.3.0, for power saving, i'm have to activate and deactivate lte, after a few time activate, send http request, get data and deactivate lte, the modem return ENOMEM.

This is my activate_lte function

int activate_lte(bool activate)
{
    int tmp;
    LOG_DBG("Start /stop LTE");
    if (activate) 
    {
        tmp = at_cmd_write(AT_ACTIVATE_LTE, NULL, 0, NULL);
        if (tmp != 0) 
        {
            LOG_DBG("ERROR: can not activate LTE %d", tmp);
            return -1;
        }

        at_notif_register_handler(NULL, wait_for_lte);
        tmp = at_cmd_write("AT+CEREG=5", NULL, 0, NULL);
        if (tmp != 0)
        {
            LOG_DBG("ERROR: LTE CREG 5 %d", tmp);
            return -1;
        }

        k_sem_take(&lte_ready, K_MSEC(45000));
        // k_sem_take(&lte_ready, K_FOREVER);
                

        at_notif_deregister_handler(NULL, wait_for_lte);
        tmp = at_cmd_write("AT+CEREG=0", NULL, 0, NULL);
        if (tmp != 0) 
        {
            LOG_DBG("ERROR: LTE CREG 0 %d", tmp);
            return -1;
        }

        if (!lte_connected)
        {
            tmp = at_cmd_write(AT_DEACTIVATE_LTE, NULL, 0, NULL);
            if (tmp != 0)
            {
                LOG_DBG("ERROR: can not deactivate LTE %d", tmp);
                return -1;
            }
            LOG_DBG("ERROR: can not connect LTE");
            return -1;
        }
    }
    else
    {
        tmp = at_cmd_write(AT_DEACTIVATE_LTE, NULL, 0, NULL);
        if (tmp != 0)
        {
            LOG_DBG("ERROR: can not deactivate LTE %d", tmp);
            return -1;
        }
    }

    return 0;
}

And this is my log

2020-07-07T08:08:44.014Z DEBUG modem << [00:32:15.159,149] \x1B[0m<inf> net_http_client_sample: Partial data received (1024 bytes)\x1B[0m\x0D\x0A
2020-07-07T08:08:44.021Z DEBUG modem << [00:32:15.167,175] \x1B[0m<inf> net_http_client_sample: Response to IPv4 GET\x1B[0m\x0D\x0A
2020-07-07T08:08:44.027Z DEBUG modem << [00:32:15.173,980] \x1B[0m<inf> net_http_client_sample: Response status OK\x1B[0m\x0D\x0A
2020-07-07T08:08:44.034Z DEBUG modem << [00:32:15.180,633] \x1B[0m<inf> net_http_client_sample: All the data received (0 bytes)\x1B[0m\x0D\x0A
2020-07-07T08:08:44.041Z DEBUG modem << [00:32:15.188,415] \x1B[0m<inf> net_http_client_sample: Response to IPv4 GET\x1B[0m\x0D\x0A
2020-07-07T08:08:44.046Z DEBUG modem << [00:32:15.195,251] \x1B[0m<inf> net_http_client_sample: Response status OK\x1B[0m\x0D\x0A
2020-07-07T08:08:44.058Z DEBUG modem << [00:32:15.205,932] \x1B[0m<dbg> vtracker.cloud_connection_handler: Current send period 80 seconds\x1B[0m\x0D\x0A
2020-07-07T08:08:44.456Z DEBUG modem << [00:32:15.605,346] \x1B[0m<dbg> v_cloud_transport.vct_connect: Finish vct_connect\x1B[0m\x0D
2020-07-07T08:08:48.554Z DEBUG modem << [00:32:19.701,354] \x1B[0m<dbg> v_cloud_transport.vct_mqtt_evt_handler: MQTT_EVT_CONNACK\x1B[0m\x0D\x0A
2020-07-07T08:08:48.561Z DEBUG modem << [00:32:19.709,197] \x1B[0m<dbg> v_cloud_transport.vct_mqtt_evt_handler: CONNACK result 0\x1B[0m\x0D\x0A
2020-07-07T08:08:48.568Z DEBUG modem << [00:32:19.717,041] \x1B[0m<inf> vtracker: VCT_EVT_CONNECTED\x1B[0m\x0D\x0A
2020-07-07T08:08:48.574Z DEBUG modem << [00:32:19.722,412] \x1B[0m<dbg> vtracker.cloud_event_handler: Next packet count: 22\x1B[0m\x0D\x0A
2020-07-07T08:08:48.589Z DEBUG modem << [00:32:19.735,382] \x1B[0m<dbg> vtracker.send_modem_data_work_fn: Sending modem info message !!!\x1B[0m\x0D\x0A
2020-07-07T08:08:49.175Z DEBUG modem << [00:32:20.322,357] \x1B[0m<dbg> v_cloud_transport.vct_mqtt_evt_handler: MQTT_EVT_PUBACK: id = 22 result = 0\x1B[0m\x0D\x0A
2020-07-07T08:08:49.184Z DEBUG modem << [00:32:20.331,817] \x1B[0m<inf> vtracker: VCT_EVT_DC_TX_DATA_ACK\x1B[0m\x0D\x0A
2020-07-07T08:08:49.191Z DEBUG modem << [00:32:20.337,615] \x1B[0m<inf> vtracker: Done sending packet !!!\x1B[0m\x0D\x0A
2020-07-07T08:08:49.197Z DEBUG modem << [00:32:20.343,475] \x1B[0m<dbg> v_cloud_transport.vct_disconnect: vct_disconnect\x1B[0m\x0D\x0A
2020-07-07T08:08:49.206Z DEBUG modem << [00:32:20.351,562] \x1B[0m<dbg> v_cloud_transport.vct_mqtt_evt_handler: MQTT_EVT_DISCONNECT: result = 0\x1B[0m\x0D\x0A
2020-07-07T08:08:49.212Z DEBUG modem << [00:32:20.360,687] \x1B[0m<inf> vtracker: VCT_EVT_DISCONNECTED\x1B[0m\x0D\x0A
2020-07-07T08:08:49.218Z DEBUG modem << [00:32:20.366,333] \x1B[0m<dbg> modem_control.activate_lte: Start /stop LTE\x1B[0m\x0D\x0A
2020-07-07T08:08:49.224Z DEBUG modem << [00:32:20.373,077] \x1B[1;31m<err> at_cmd: Failed to send AT command (err:12)\x1B[0m\x0D\x0A
2020-07-07T08:08:49.233Z DEBUG modem << [00:32:20.380,004] \x1B[0m<dbg> modem_control.activate_lte: ERROR: can not deactivate LTE -12\x1B[0m\x0D\x0A
2020-07-07T08:08:49.239Z DEBUG modem << [00:32:20.388,275] \x1B[0m<dbg> vtracker.cloud_connection_handler: end cloud handler\x0A
2020-07-07T08:08:49.241Z DEBUG modem << \x1B[0m\x0D\x0A
2020-07-07T08:09:44.512Z DEBUG modem << %CESQ: 37,1,11,1\x0D\x0A
2020-07-07T08:09:46.514Z DEBUG modem << %CESQ: 37,1,19,2\x0D\x0A
2020-07-07T08:09:51.016Z DEBUG modem << %CESQ: 37,1,13,1\x0D\x0A
2020-07-07T08:10:04.066Z DEBUG modem << [00:33:35.214,569] \x1B[0m<dbg> vtracker.data_send_handler: Start sending data to server \x1B[0m\x0D\x0A
2020-07-07T08:10:04.072Z DEBUG modem << [00:33:35.222,534] \x1B[0m<dbg> modem_control.activate_lte: Start /stop LTE\x1B[0m\x0D\x0A
2020-07-07T08:10:04.088Z DEBUG modem << [00:33:35.238,067] \x1B[0m<dbg> modem_control.activate_lte: ERROR: can not activate LTE -8\x1B[0m\x0D\x0A
2020-07-07T08:10:04.098Z DEBUG modem << [00:33:35.246,093] \x1B[0m<dbg> vtracker.cloud_connection_handler: Can not activate LTE network !!!\x1B[0m\x0D\x0A
2020-07-07T08:10:12.020Z DEBUG modem << %CESQ: 37,1,19,2\x0D\x0A
2020-07-07T08:10:14.022Z DEBUG modem << %CESQ: 37,1,13,1\x0D\x0A
2020-07-07T08:10:58.031Z DEBUG modem << %CESQ: 37,1,18,2\x0D\x0A
2020-07-07T08:11:18.036Z DEBUG modem << %CESQ: 37,1,10,1\x0D\x0A

Can you show me how to fix it ?

Thanks

Related