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

Sending UDP using the Serial LTE Modem application - AT sequence

Hi

I have upgraded from an early version of SLM to the latest version in nRF Connect SDK ver. 1.3.1

the SLM application is running on a custom board with a nRF52840. Using the old version of SLM, the following commands resulted in successful communication:

  

at#xsocket=1,2
at#xudpsendto="xx.xxx.xx.xxx",xxxx,"testing"
at#xudprecvfrom="xx.xxx.xx.xxx",xxxx,100,1
at#xsocket=0

What is the correct sequence of AT commands in the new version? And is there some documentation on available commands in the SLM application?

  • Hi Bard,

    You can use the following commands:

    at#xsocket=1,2
    
    AT#XSENDTO=<url>,<port>,<datatype>,<data>
    
    AT#XRECVFROM[=<length>]
    
    AT#XSOCKET=0

  • Thank you, Martin. But is there some documentation on the usage of these commands? What is <datatype> and <op>? And how is addressing implemented? - the old AT#XUDPSENDTO had both IP address and Port in the call...

  • Hi Bard,
    We are working on improving the documentation to explain this better.

    #XSENDTO UDP send data Send data via UDP channel
    #XSENDTO=<url>,<port>,<datatype>,<data>
    Response:
    #XSENDTO: <size>
    <url> values String type, hostname or IP address
    Max 128 bytes. In case of IP address, IPv4 only, not support IPv6
    <port> values Integer, UDP service port
    <datatype> values 0 - hexidecimal string format, e.g. "DEADBEEF" for 0xDEADBEEF
    1 - plain text (default value)
    2 - Json
    3 - HTML
    4 - OMA TLV
    <data> values String type, arbitary data
    NOTE1 max NET_IPV4_MTU (576) bytes
    NOTE2 no NULL char in the middle
    <size> values Integer type, actual number of bytes sent
    example AT#XSENDTO="test.server.com",1234,"Test UDP"
    #XSENDTO: 8
    OK
    #XRECVFROM UDP receive data Receive data via UDP channel
    #XRECVFROM=<url>,<port>[,<size>]
    NOTE receive max NET_IPV4_MTU(576) bytes
    Response:
    <data>
    #XRECVFROM: <datatype>, <size>
    <url> values String type, hostname or IP address
    Max 128 bytes. In case of IP address, IPv4 only, not support IPv6
    <port> values Integer, UDP service port
    <size> values Requested number of bytes in command, , NET_IPV4_MTU if not specified
    Actual number of bytes received in response
    <datatype> values See #XSEND command
    example AT#UDPRECVFROM="test.server.com",1234
    Test OK
    #XRECVFROM: 1, 7
    OK
  • Hi Bard,

    There is now a draft pull request for the SLM documentation up.

    This version will be reviewed and most likely some changes will be added before its merged with NCS master.

  • Using the draft documentation, I ended up with this sequence:

    at#xsocket=1,2,0    // must have the last zero
    at#xsendto="xx.xxx.xx.xxx",xxxx,"Test UDP"
    
    // both below works ok
    at#xrecvfrom="xx.xxx.xx.xxx",xxxx
    at#xrecvfrom="xx.xxx.xx.xxx",xxxx,100,1
    
    at#xsocket=0

    But at#xrecvfrom hangs if there is no data from the network. Is there a way to test before fetch, or a timeout parameter?

Related