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

receive UDP on nRF9160-dk SLM application

Hi,

I want to receive UPD message on my nRF9160-DK.

I can send UDP messages from my Nordic device to a server and from that messages I get the public IP address of my module. But when I try to receive messages, I don't receive anything.  

I use the serial LTE modem application.

I see the following links to send messages:

https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/applications/serial_lte_modem/doc/TCPIP_AT_commands.html#udp-receive-data-xrecvfrom

https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/nrf/applications/serial_lte_modem/doc/slm_description.html

First try:

AT#XSOCKET=1,2,0


#XSOCKET: 1, 2, 0, 17


OK
AT#XSENDTO="x.x.x.x",20080,1,"Test UDP"


#XSENDTO: 8


OK
AT#XSOCKET=0


#XSOCKET: 0, closed


OK
AT#XSOCKET=1,2,1


#XSOCKET: 1, 2, 1, 17
OK


AT#XBIND=3442


OK


AT#XRECVFROM

and after this I get: "Error: 'AT#XRECVFROM' timed out"  and I cannot send AT command to LTE Link Monitor.

-------------------------------------------------------------------------

Second try:

AT#XSOCKET=1,2,0


#XSOCKET: 1, 2, 0, 17


OK





AT#XSENDTO="x.x.x.x",20080,1,"Test UDP"


#XSENDTO: 8


OK





AT#XSOCKET=0


#XSOCKET: 0, closed


OK


AT#XSOCKET=1,2,1


#XSOCKET: 1, 2, 1, 17


OK


AT#UDPRECVFROM="x.x.x.x",3442


+CME: 0

Here I don't know how to solve this error.


-------------------------------------------------------------------------




Third try:

I set the UDP proxy to use the command AT#XUDPSVR;
So in "Configure nRF Connect SDK Project" I select "Stateful connection-oriented UDP client/server <SLM_UDP_PROXY>"

AT#XUDPCLI=1,"x.x.x.x",20080


#XUDPCLI: 1 connected


OK


%CESQ: 32,1,19,2


%CESQ: 29,1,24,3


AT#XUDPSEND=1,"Test UDP"


#XUDPSEND: 8


OK





AT#XUDPCLI=0


#XUDPCLI: disconnected


OK


AT#XUDPSVR=1,3442 or AT#XUDPSVR=2,3442



#XUDPSVR: 1 started


OK

Here it seems to work but I don't receive anything and retrying I get sometimes: "Error: 'AT#XUDPSVR=1,3442 ' timed out"

I try using the IP that I get in the receiving messages and also with the IP that I get with the command "AT+CGDCONT?"

I try also using the example script "client_udp.py" but nothing.

I try many times with all possible combinations.

What can I do? The nRF9160-DK receives messages but doesn't print them on the LTE Link Monitor or I'm using wrong AT command? Is there an error in the client code? Is the IP that I use the error? Is it possible that my server doesn't know how to reach my APN even if I specify the correct public IP address?


Please, help me to receive a simple "hello".
Thank you in advance.

Best regards

  • Hi,

    Correct me if im wrong but are you sure the IP given by the LTE network is a PUBLIC IP ? Except specifically asked when you order the simcard, the IP are "private IP" on the operator's network...
    OlivierG

  • AndMar8 said:

    Which's your modem version? What about the firmware? Are you using the slm application?

     mfw v1.2.2, SLM from NCS v1.4.0.

     

    AndMar8 said:

    09:47:24.974       Error: 'at#xrecvfrom' timed out

     I assume you are using the LTE link monitor?

    It is note really meant for this kind of use case, but to communicate with the modem "directly". As such, almost all the AT commands it is "meant" to send returns a reply immediately. It therefore has a fairly short timeout. However, it should not be a problem that a command times out, as long as there is a response eventually.

     

    AndMar8 said:
    From here all AT commands (also a simple AT) returns me this same error (Error: 'at' timed out).

     The SLM implementation of #RECVFROM is blocking, so this is not surprising.

    Can you take a modem trace, so we can analyze the IP traffic?

    Also, if you could capture an IP trace from your server, that could also help.

  • > The SLM implementation of #RECVFROM is blocking, so this is not surprising.

    Sorry to write that, surprising is indeed not the behavior, it's more, that it is implemented in that way. Doesn't this block the modem for new AT-commands until it receives something? If the sent data is lost, you will not be able to even resend it. For me this implementation is very close to "useless"?

  • > I can send UDP messages from my Nordic device to a server and from that messages I get the public IP address of my module. But when I try to receive messages, I don't receive anything.

    How long does it take until you send the message back?

    If you get the public IP address from the message, do you also get the source port from them? And do you use that port to send a message back?

  • Hi, Sorry for the delay. I were able to collected the modem Trace. 
    Please find attached the zip file containing two modem traces. 

    I have also tested the receive mode using a different terminal. I use Termite as both putty and were not able to communicate with the SIP:

    Just for knowledge I have tested the sim card with a different modem from Quectel and I was able to receive the data coming from the node-red UDP node.

    I have also tested the UDP functionality with a desktop packet receiver and it works as well. 

    Here a screen shot from node-red showing the message I am receiving from the SIP. OFC I use the same address and port to send data back to the SIP.

    I am starting being clueless about why I am not able to receive the UDP packet using the nrf9160 SIP.

    I do not know if it can be useful but, can you please share your firmware HEX files just to test it.

    Thank you for your kind help.

    nRF9160_recvfrom_trace.zip

Related