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

How to listen port and receive UDP messages?

I would like to receive UDP messages sent from a server to nRF9160. Is it possible? If so, how can you do that?

Parents Reply Children
  • Hi, Didrik. Sorry for a late response.

    I'm thinking of applying a public static IP address to a SIM card and receiving a UDP message during eDRX mode. Is this possible?

    As long as I learned about UDP sever, a following step to receive a message as a server should be taken.

    1. create a socket
    2. bind the socket to a specific port
    3. poll until data is received or timeout
    4. recvfrom when data is received.

    During eDRX, nRF9160 server decreases power consumption so it can receive a message saving battery power..

    I'm not familiar with network. Thank you for advising me!

  • Hi, and sorry for the late response, but I was away on vacation.

    One problem with your suggestion is that on most networks the device is behind NAT, and the network will close the connection after 10-75  seconds (in most cases).

    You can therefore not expect your device to keep it's IP address, or be reachable from the outside.

    These problems can probably be worked around by employing your own APN, but that is not a trivial thing to do (from both a technical and business perspective).

    Instead, the common approach is to have the device initiate all communication.

    A modification of that solution is to have the server send an SMS to the device when the server wants to initiate communication. SMS-es has more guarantees regarding delivery than (UDP) IP packets, so the server can be quite confident that the SMS will reach the device. The device can then contact the server over IP (UDP or TCP) to receive the data.

    Best regards,

    Didrik

Related