[Solved] After Spark.sleep() finished, UDP packets cannot be sent

Hi, I found situation that once Spark.sleep() called, UDP packets cannot be sent.

Here is my circumstance.

0 sec: Program Started
10 sec : Send UDP packet --> Server Recived
20 sec: Spark.sleep (10 sec)
30 sec: Spark woke up, Connecting to WiFi --> I confirmed it is connected. (from Access Point config)
90 sec: If WiFi.ready() ==true -> Serial.print & Send UDP packet --> Server didn’t receive UDP packet.

Even if WiFi.ready()==true, UDP packet didn’t sent.

Can anybody help me understanding this situation?
Thanks for your help.

1 Like

Self-solved problem.

I should had to call Udp.begin(port) every time Spark.sleep terminated.

Don’t forget calling Udp.begin(port) after connection has been lost and recovered.


I edited your title to “[SOLVED] …”


Well, this instance of this encountering of the problem may be solved, but the problem will be encountered again, as the need to re-call UDP.begin() is not documented, and would not be guessed from the current documentation which simply says that the WiFi is re-established.

Please everyone report bugs / workarounds needing documentation here: https://community.spark.io/t/documentation-needs/4555/

1 Like

And, I guess, at some point there should be a call of UDP.stop(). To avoid running into the problem of running out of sockets as @bko mentions here for example.

This also needs documenting better.

(Added at above thread :wink: )