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

nrf9160 (NRF9160-SICA-R) as modem for sending/receiving data by AT Commands

Hi DevZone! 

I would like to use nrf9160 for sending/receiving data by interfacing it with my microcontroller over UART and sending AT commands. I have a nrf9160 Feather board (check here) which is flashed with the latest modem firmware. I have tested it with CoolTerm (serial terminal app) and it responds with AT Commands. Now I am looking for example set of commands which can help in sending/receiving data over TCP, this will really help a lot! 

Requesting your help/ any pointer

Thanks 

Silas 

Parents
  • Hi!

    I think you are looking for the Serial LTE Modem sample in NCS.

    Here is an example of how to establish and test a TCP connection, and send and receive data. 

    And here is the documentation for all the supported AT commands for this sample.

    Please let me know if you need anything else!

    Best regards,

    Heid

  • Hi Heidi

    Thanks for your prompt reply!

    I am actually new to using Segger Embedded Studio for nRF Connect. I could build the SLM application in SES and it produced merged.hex output file. How do I also get the .BIN file output which I need to load into the nRF Feather board? Sorry if I am asking a very common question :( 

    Thank you so much!

     Silas

  • HI Heidi

    I got the command #XTCPCONN from this excel (click here) which summarizes all commands. But that could be an older version. 

    Further for command AT#SOCKET,  I tried AT#XSOCKET=0,1,0  or  0,1,1  and it always returned error..

    Trying AT#XSOCKET=1,1,0 --> always worked (as you can see in the result attached). Further sending this command AT#XCONNECT? also returned +XCONNECT: 1 (which is connected)

    but finally it fails when tried to send some data using AT#XSEND="Test TCP"

    Would you please help Slight smile Thank you so much!

    Ready
    AT+CFUN=1
    OK
    AT+CIND=1,1,1
    OK
    AT+CIND?
    +CIND: 1,1,1
    OK
    AT+CPIN?
    +CPIN: READY
    OK
    AT+CESQ
    +CESQ: 99,99,255,255,255,255
    OK
    AT+CESQ
    +CESQ: 99,99,255,255,255,255
    OK
    +CIND: "service",1
    +CIND: "roam",1
    AT+CESQ
    +CESQ: 99,99,255,255,12,33
    OK
    AT+CEREG?
    +CEREG: 0,5,"0936","0C74150F",7
    OK
    AT+CGDCONT?
    +CGDCONT: 0,"IP","hologram","10.117.238.97",0,0
    OK
    AT#XSOCKET=1,1,0
    #XSOCKET: 1, 1, 0, 6
    OK
    AT#XSOCKET?
    #XSOCKET: 1, 6, 0
    OK
    AT#XBIND=1700
    OK
    AT#XCONNECT="138.68.40.173",1700
    #XSOCKET: -116, closed
    ERROR
    AT#XSOCKET=1,1,0
    #XSOCKET: 1, 1, 0, 6
    OK
    AT#XSOCKET?
    #XSOCKET: 1, 6, 0
    OK
    AT#XBIND=1700
    OK
    AT#XCONNECT="138.68.40.173",1700
    #XCONNECT: 1
    OK
    AT#XCONNECT?
    +XCONNECT: 1
    OK
    AT#XSEND="Test TCP"
    ERROR
    AT#XSOCKET=0
    #XSOCKET: 0, closed
    OK
    AT#XSOCKET=0,1,0
    ERROR
    AT#XSOCKET=0,1,1
    ERROR
    

  • Should I try getting the latest SLM app code from the nRF Connect on GitHub?

  • Hi! Sorry about the late reply. I've been testing and seeing the same issues you are seeing, with no solution yet. 

    I've been testing the SLM application on the master branch of NCS with no luck so I don't think upgrading will help. 

    I know there have been some issues with the SLM application previously, so I will see if anybody has experienced this. 

    The comment I made earlier about the #SOCKET command was incorrect, by the way. The documentation is wrong, it's 1 to open and 0 to close. 

    Best regards,

    Heidi

  • Ok That sounds pretty disappointing Disappointed

    Should I then use at_client application? We need to test either TCP or UDP for sending a few bytes of data successfully. That will help us going with nRF9160.  

    Thanks you so much!

  • Hi!

    Could you try changing this part of the prj.conf file to what I have attached below:

    CONFIG_LOG=y
    CONFIG_LOG_DEFAULT_LEVEL=4
    CONFIG_STACK_SENTINEL=y
    CONFIG_NEWLIB_LIBC=y
    CONFIG_NEWLIB_LIBC_FLOAT_PRINTF=y
    CONFIG_RING_BUFFER=y
    
    # Segger RTT
    CONFIG_USE_SEGGER_RTT=n
    CONFIG_RTT_CONSOLE=n
    CONFIG_UART_CONSOLE=y
    CONFIG_LOG_BACKEND_RTT=n
    CONFIG_LOG_BACKEND_UART=y

    Try testing some commands and running it a bit. This will give us some more information about why the commands are failing. 

    I realized on my end it was failing due to the SIM card being out of data, so I haven't actually been able to reproduce your issue yet. 

Reply
  • Hi!

    Could you try changing this part of the prj.conf file to what I have attached below:

    CONFIG_LOG=y
    CONFIG_LOG_DEFAULT_LEVEL=4
    CONFIG_STACK_SENTINEL=y
    CONFIG_NEWLIB_LIBC=y
    CONFIG_NEWLIB_LIBC_FLOAT_PRINTF=y
    CONFIG_RING_BUFFER=y
    
    # Segger RTT
    CONFIG_USE_SEGGER_RTT=n
    CONFIG_RTT_CONSOLE=n
    CONFIG_UART_CONSOLE=y
    CONFIG_LOG_BACKEND_RTT=n
    CONFIG_LOG_BACKEND_UART=y

    Try testing some commands and running it a bit. This will give us some more information about why the commands are failing. 

    I realized on my end it was failing due to the SIM card being out of data, so I haven't actually been able to reproduce your issue yet. 

Children
  • Hi Heidi

    That really worked! What I did was, in Toolchain Manager, I did "update SDK" for V1.3.1, and then updated the prj.conf for the SLM, open project in SES, and run the build, flashed BIN into nRF Feather board. 

    And then manually ran the AT commands: see the results below:

    I think the XSEND need to be AT#XSEND=1, "Test TCP", although 1 is default, we need to supply. I also tried closing connection, reopening and then sending JSON data. That also worked fine Slight smile

    Thank you so much for your help!! 

    *** Booting Zephyr OS build v2.3.0-rc1-ncs2  ***
    Ready
    [00:00:00.194,122] .[0m<inf> app: Serial LTE Modem.[0m
    AT+CFUN=1
    OK
    AT+CIND=1,1,1
    OK
    AT+CPIN?
    +CPIN: READY
    OK
    AT+CESQ
    +CESQ: 99,99,255,255,255,255
    OK
    AT+CESQ
    +CESQ: 99,99,255,255,255,255
    OK
    AT+CESQ
    +CESQ: 99,99,255,255,255,255
    OK
    AT+CESQ
    +CESQ: 99,99,255,255,4,29
    OK
    +CIND: "service",1
    +CIND: "roam",1
    AT+CGDCONT?
    +CGDCONT: 0,"IP","hologram","10.117.238.97",0,0
    OK
    AT#XSOCKET=1,1,0
    #XSOCKET: 1, 1, 0, 6
    OK
    AT#XSOCKET?
    #XSOCKET: 1, 6, 0
    OK
    AT#XBIND=1700
    OK
    [00:01:54.448,425] .[0m<dbg> modem_info.modem_info_string_get: Device contains 1 IP addresses.[0m
    AT#XCONNECT="138.68.40.173",1700
    #XCONNECT: 1
    OK
    AT#XCONNECT?
    +XCONNECT: 1
    OK
    AT#XSEND=1, "Test TCP"
    #XSEND: 8
    OK
    AT#XSOCKET=0
    #XSOCKET: 0, closed
    OK
    AT#XSOCKET?
    #XSOCKET: 0
    OK
    AT#XSOCKET=1,1,0
    #XSOCKET: 1, 1, 0, 6
    OK
    AT#XSOCKET?
    #XSOCKET: 1, 6, 0
    OK
    AT#XBIND=1700
    OK
    [00:08:58.125,640] .[0m<dbg> modem_info.modem_info_string_get: Device contains 1 IP addresses.[0m
    AT#XCONNECT="138.68.40.173",1700
    #XCONNECT: 1
    OK
    AT#XCONNECT?
    +XCONNECT: 1
    OK
    AT#XSEND=2,"{dev_euid:123, msg:ok}"
    #XSEND: 22
    OK
    AT#XSEND=2,"{dev_euid:123, msg:ok}"
    #XSEND: 22
    OK
    AT#XSEND=1, "Test TCP"
    #XSEND: 8
    OK
    AT#XSOCKET=0
    #XSOCKET: 0, closed
    OK
    
    

Related