we use a logger instance that sends the log lines per UDP to a server. we have used this for a long time already on the particle p1. but on the p2 we get watchdog restarts (watchdog set to 60s).
looks like UDP.sendPacket hangs when not connected. so i added a "if Particle.connected()" to only log while connected. that improves a lot. but still there are the occasional watchdog restarts.
i would assume UDP.sendPacket should not hang when not connected but rather return a negative value/error code.
UDP.sendPacket() does not depend on the state of cloud connection, but you assume correct that it will return a negative error code on P2 if WiFi is disconnected (
WiFi.ready() == false).
If you are using a custom log handler that in turn sends logs over UDP, what most likely happens is either an uncaught stack overflow in some thread (application or internal Device OS) that tries to log something due to a large call stack or perhaps a deadlock between logging/networking subsystems and something else.
An example application or at least the logger implementation and the conditions that trigger this lockup would be useful to understand the culprit.
looks like it is WiFi.ready() that is causing hangs / not returning within 60s....