UDP receiving stops unexpectedly

Hi All,

Working with the E131 and FastLED libraries. Pretty simple use case which is to listen for UDP packets, extract an array of uint8_t values from them and, after some minor validation, dump them out to a string of RGB leds.

I modified the E131 library a little so that I could use unicast rather than multicast IP addressing, not that this seems to impact my issue.

My photon regularly stops processing the incoming packets. It’ll go anywhere from 5 to 15 min of receiving and processing just fine and then poof - no more lights. A udp.stop() and udp.begin(5568) fixes it right up.

I have high confidence that the WiFi network is behaving properly, but I can’t rule it out completely at this point. I’ve eyeballed the Photon itself and it never disconnects from the network if the status led is to be believed.

Other than getting disconnected from the WiFi, what sorts of events can cause the Photon to need it’s UDP stack to be reinitialized? Right now I just run a timer between packets and do the restart if it’s been more than 5 sec, but this is the sledgehammer approach.


If you are using UDP, you pretty much have to use SYSTEM_THREAD(ENABLED).

In loop, monitor WiFi.ready(). Whenever you go from previously not ready to now ready you need to call udp.begin(port), otherwise the listener will stop working. This usually requires a global variable flag to indicate whether WiFi was previously ready or not.


That makes sense. I didn’t read the fine print where threading is opt-in. I’ll set that up, and willing to bet it solves the problem.