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

Cannot get AT Command 'NCELLMEAS' into a buffer.

Hey Guys :)  have a MQTT code that publishes certain AT commands, It works for all cases except Mutlicell 'NCELLMEAS' command. Any help would be appreciated.

[This Works]

const char at_cgsn_cmd[] = "AT+CGSN=1";
	char cmd_rcv_buf_cgsn[50];
	int ret_cgsn = at_cmd_write(at_cgsn_cmd, cmd_rcv_buf_cgsn, sizeof(cmd_rcv_buf_cgsn), &state);
	printk("CGSN_ANS: %s", cmd_rcv_buf_cgsn);

Result

CGSN_ANS: +CGSN: "352656106109179"

[This Doesn't]

const char at_ncell_cmd[] = "AT%NCELLMEAS";
	char cmd_rcv_buf_ncell[500];
	int ret_ncell = at_cmd_write(at_ncell_cmd, cmd_rcv_buf_ncell, sizeof(cmd_rcv_buf_ncell), &state);
	printk("MULTICELL_ANS: %s", cmd_rcv_buf_ncell);

Result : 

MULTICELL_ANS:

%NCELLMEAS: 0,"0A3FED10","310410","8D0C",336,5110,242,37,17,3373

Although the AT Command works and outputs a result.The Result wouldn't go inside the buffer (It should look something like this 'MULTICELL_ANS: %NCELLMEAS: 0,"0A3FED10","310410","8D0C",336,5110,242,37,17,3373) in 1 single line .  We are not getting any output on the MQTT server for NCELLMEAS

1. We have tried playing around with the buffer size

2. We have tried the start_cell_measurements(); and print_cell_data(); without any results.

Parents Reply Children
  • Hi Didrik,

    - We are using ncs v1.6.1 (MFW 1.3.0)

    - We tested the %NCELLMEAS command using a At_Client example, and it worked as expected.

    - Return value is 0 for at_cmd_write.

    - Added 'CONFIG_LOG=y' and 'CONFIG_AT_CMD_LOG_LEVEL_DBG=y'. We are still getting the Result of the NCELLMEAS but it doesn't go into the buffer or get printed.

    - We have played with some Delay values, increased MQTT Buffer size, Disabled unsolicited messages without any results.

    Here is a Simple Function with just Command to Publish - We haven't changed anything else in the MQTT code

    void get_loc_data(void)
    {
    	
    	//Common_Declaration
    	enum at_cmd_state state;
    	
    	/* Disable Unsolicted Code*/
    	const char at_cscon_cmd[] = "AT+CSCON=0";
    	char cmd_rcv_buf_cscon[50];
    	int ret_cscon = at_cmd_write(at_cscon_cmd, cmd_rcv_buf_cscon, sizeof(cmd_rcv_buf_cscon), &state);
    	printk("CSCON_ANS: %s\n", cmd_rcv_buf_cscon);
    	
    	
    	/* Wait till the buffer is full*/
    	const char at_ncell_cmd[] = "AT%NCELLMEAS";
    	char cmd_rcv_buf_ncell[500];
    	int ret_ncell = at_cmd_write(at_ncell_cmd, cmd_rcv_buf_ncell, sizeof(cmd_rcv_buf_ncell), &state);
    	k_sleep(K_MSEC(2000));                                 
    	printk("state: %d, ret %d\n", state, ret_ncell);
    	printk("MULTICELL_ANS: %s\n", cmd_rcv_buf_ncell);
    	
    	strcpy(Loc_Result, cmd_rcv_buf_ncell);                         
        printk("CONCAT_ANS_1: %s",Loc_Result);            // We publish 'Loc_Result' with the data_publish func
    	
    }

    Here is the Result :

    *** Booting Zephyr OS build v2.6.0-rc1-ncs1  ***
    
    [00:00:00.205,902] <dbg> at_cmd.at_cmd_driver_init: Common AT socket created
    
    [00:00:00.205,932] <dbg> at_cmd.at_cmd_driver_init: Common AT socket processing thread created
    
    --- 12 messages dropped ---
    
    [00:00:00.206,909] <dbg> at_cmd.at_write: Sending command AT+CEREG=5
    
    [00:00:00.213,287] <dbg> at_cmd.socket_thread_fn: Listening on socket
    
    [00:00:00.213,439] <dbg> at_cmd.socket_thread_fn: at_cmd_rx 5 bytes, OK
    
    
    
    [00:00:00.213,470] <dbg> at_cmd.socket_thread_fn: Enqueueing response for sync call
    
    --- 1 messages dropped ---
    
    [00:00:00.213,531] <dbg> at_cmd.socket_thread_fn: Writing any pending command
    
    [00:00:00.213,531] <dbg> at_cmd.at_write: Sending command AT+CSCON=1
    
    [00:00:00.213,836] <dbg> at_cmd.socket_thread_fn: Listening on socket
    
    [00:00:00.214,019] <dbg> at_cmd.socket_thread_fn: at_cmd_rx 5 bytes, OK
    
    
    
    [00:00:00.214,019] <dbg> at_cmd.socket_thread_fn: Enqueueing response for sync call
    
    [00:00:00.214,141] <dbg> at_cmd.at_cmd_write: Awaiting response for AT%XSYSTEMMODE=1,0,0,0
    
    [00:00:00.214,141] <dbg> at_cmd.socket_thread_fn: Writing any pending command
    
    [00:00:00.214,172] <dbg> at_cmd.at_write: Sending command <log_strdup alloc failed>
    
    [00:00:00.220,428] <dbg> at_cmd.socket_thread_fn: Listening on socket
    
    [00:00:00.221,893] <dbg> at_cmd.socket_thread_fn: at_cmd_rx 5 bytes, <log_strdup alloc failed>
    
    [00:00:00.221,893] <dbg> at_cmd.socket_thread_fn: Enqueueing response for sync call
    
    [00:00:00.221,923] <dbg> at_cmd.at_cmd_write: Awaiting response for AT+CEREG=5
    
    [00:00:00.221,954] <dbg> at_cmd.socket_thread_fn: Writing any pending command
    
    [00:00:00.221,984] <dbg> at_cmd.at_write: Sending command AT+CEREG=5
    
    [00:00:00.222,320] <dbg> at_cmd.socket_thread_fn: Listening on socket
    
    [00:00:00.222,473] <dbg> at_cmd.socket_thread_fn: at_cmd_rx 5 bytes, <log_strdup alloc failed>
    
    [00:00:00.222,473] <dbg> at_cmd.socket_thread_fn: Enqueueing response for sync call
    
    [00:00:00.222,534] <dbg> at_cmd.at_cmd_write: Awaiting response for AT+CSCON=1
    
    [00:00:00.222,564] <dbg> at_cmd.socket_thread_fn: Writing any pending command
    
    [00:00:00.222,595] <dbg> at_cmd.at_write: Sending command AT+CSCON=1
    
    [00:00:00.222,869] <dbg> at_cmd.socket_thread_fn: Listening on socket
    
    [00:00:00.223,022] <dbg> at_cmd.socket_thread_fn: at_cmd_rx 5 bytes, <log_strdup alloc failed>
    
    [00:00:00.223,052] <dbg> at_cmd.socket_thread_fn: Enqueueing response for sync call
    
    [00:00:00.223,144] <dbg> at_cmd.at_cmd_write: Awaiting response for AT+CFUN=1
    
    [00:00:00.223,175] <dbg> at_cmd.socket_thread_fn: Writing any pending command
    
    [00:00:00.223,205] <dbg> at_cmd.at_write: Sending command <log_strdup alloc failed>
    
    [00:00:00.229,583] <dbg> at_cmd.socket_thread_fn: Listening on socket
    
    [00:00:00.258,178] <dbg> at_cmd.socket_thread_fn: at_cmd_rx 5 bytes, OK
    
    
    
    [00:00:00.258,178] <dbg> at_cmd.socket_thread_fn: Enqueueing response for sync call
    
    [00:00:00.258,239] <dbg> at_cmd.socket_thread_fn: Writing any pending command
    
    [00:00:00.258,270] <dbg> at_cmd.socket_thread_fn: Listening on socket
    
    +CEREG: 2,"8D0C","0A3FED10",7
    
    +CSCON: 1
    
    [00:00:01.891,632] <dbg> at_cmd.socket_thread_fn: at_cmd_rx 32 bytes, +CEREG: 2,"8D0C","0A3FED10",7
    
    
    
    [00:00:01.894,744] <dbg> at_cmd.socket_thread_fn: Writing any pending command
    
    [00:00:01.894,744] <dbg> at_cmd.socket_thread_fn: Listening on socket
    
    [00:00:02.045,410] <dbg> at_cmd.socket_thread_fn: at_cmd_rx 12 bytes, +CSCON: 1
    
    
    
    [00:00:02.046,508] <dbg> at_cmd.socket_thread_fn: Writing any pending command
    
    [00:00:02.046,508] <dbg> at_cmd.socket_thread_fn: Listening on socket
    
    +CEREG: 5,"8D0C","0A3FED10",7,,,"11100000","11100000"
    
    CSCON_ANS:
    
    [00:00:%NCELLMEAS: 0,"0A3FED10","310410","8D0C",352,5110,242,27,8,3470
    
    03.647,003] <dbg> at_cmd.socket_thread_fn: at_cmd_rx 56 bytes, +CEREG: 5,"8D0C","0A3FED10",7,,,"11100000","1~
    
    [00:00:03.652,465] <inf> mqtt_simple: LTE Link Connected!
    
    [00:00:03.652,496] <dbg> at_cmd.at_write: Sending command AT+CSCON=0
    
    [00:00:03.652,557] <dbg> at_cmd.socket_thread_fn: Writing any pending command
    
    [00:00:03.652,679] <dbg> at_cmd.at_cmd_write: Awaiting response for AT+CSCON=0
    
    [00:00:03.652,709] <dbg> at_cmd.socket_thread_fn: Listening on socket
    
    [00:00:03.652,862] <dbg> at_cmd.socket_thread_fn: at_cmd_rx 5 bytes, OK
    
    
    
    [00:00:03.652,862] <dbg> at_cmd.socket_thread_fn: Enqueueing response for sync call
    
    [00:00:03.654,022] <dbg> at_cmd.at_cmd_write: Awaiting response for <log_strdup alloc failed>
    
    [00:00:03.654,052] <dbg> at_cmd.socket_thread_fn: Writing any pending command
    
    [00:00:03.654,083] <dbg> at_cmd.at_write: Sending command <log_strdup alloc failed>
    
    [00:00:03.654,266] <dbg> at_cmd.socket_thread_fn: Listening on socket
    
    [00:00:03.654,815] <dbg> at_cmd.socket_thread_fn: at_cmd_rx 5 bytes, <log_strdup alloc failed>
    
    [00:00:03.654,815] <dbg> at_cmd.socket_thread_fn: Enqueueing response for sync call
    
    [00:00:03.654,876] <dbg> at_cmd.socket_thread_fn: Writing any pending command
    
    [00:00:03.654,876] <dbg> at_cmd.socket_thread_fn: Listening on socket
    
    [00:00:03.655,212] <dbg> at_cmd.socket_thread_fn: at_cmd_rx 66 bytes, <log_strdup alloc failed>
    
    [00:00:03.661,132] <dbg> at_cmd.socket_thread_fn: Writing any pending command
    
    [00:00:03.661,163] <dbg> at_cmd.socket_thread_fn: Listening on socket
    
    state: 0, ret 0
    
    MULTICELL_ANS:
    
    CONCAT_ANS_1: [00:00:07.253,906] <inf> mqtt_simple: IPv4 Address found +REMOVED+
    
    [00:00:07.253,967] <dbg> mqtt_simple.client_id_get: client_id = gurbir
    
    [00:00:07.804,168] <inf> mqtt_simple: Publishing:
    
    [00:00:07.804,168] <inf> mqtt_simple: to topic: +REMOVED+ len: 11
    
    [00:00:07.804,656] <inf> mqtt_simple: MQTT client connected
    
    [00:00:07.804,656] <inf> mqtt_simple: Subscribing to: # len 1
    
    +CEREG: 5,"8D0C","0A3E8B11",7,,,"11100000","11100000"
    
    [00:00:09.574,218] <dbg> at_cmd.socket_thread_fn: at_cmd_rx 56 bytes, +CEREG: 5,"8D0C","0A3E8B11",7,,,"11100000","1~
    
    [00:00:09.579,650] <dbg> at_cmd.socket_thread_fn: Writing any pending command
    
    [00:00:09.579,681] <dbg> at_cmd.socket_thread_fn: Listening on socket
    
    [00:00:12.519,805] <inf> mqtt_simple: PUBACK packet id: 36932
    
    [00:00:12.676,574] <inf> mqtt_simple: SUBACK packet id: 1234
    
    +CEREG: 5,"8D0C","0A3FED10",7,,,"11100000","11100000"
    
    [00:00:14.698,150] <dbg> at_cmd.socket_thread_fn: at_cmd_rx 56 bytes, +CEREG: 5,"8D0C","0A3FED10",7,,,"11100000","1~
    
    [00:00:14.703,582] <dbg> at_cmd.socket_thread_fn: Writing any pending command
    
    [00:00:14.703,613] <dbg> at_cmd.socket_thread_fn: Listening on socket
    
    +CEREG: 5,"8D0C","0A3E8B11",7,,,"11100000","11100000"
    
    [00:02:13.953,125] <dbg> at_cmd.socket_thread_fn: at_cmd_rx 56 bytes, +CEREG: 5,"8D0C","0A3E8B11",7,,,"11100000","1~
    
    [00:02:13.958,557] <dbg> at_cmd.socket_thread_fn: Writing any pending command
    
    [00:02:13.958,557] <dbg> at_cmd.socket_thread_fn: Listening on socket

    As you can see the Result of %NCELLMEAS is received, but it doesn't seem to show up when printed in "MULTICELL_ANS:" . Can I send you the code to recreate this issue on your side ?

    Thanks and Regards,

    Gurbir

  • Hi, and sorry for the late reply.

    I've tested this myself, and when running similar code to yours, I get the same behavior.

    The reason for this is that %NCELLMEAS does not return a response, but a notification.

    This means that you don't get the answer when you send %NCELLMEAS, but later.

    You can use the at_notif library to subscribe to AT notifications, or you can use the lte_lc library (again, you'll need an event handler).

    Best regards,

    Didrik

Related