I am trying to get a very simple proof-of-concept running for a project. The project uses UDP Multicast communications. In the "Loop" of the project I need to check if any UDP data has been received. I am using the following code:
What I find is that when there is no data received the "parsePacket" call takes 1-second. This of course delays the whole loop.
Is there a better way of checking for data than this?
I searched but could not find any asynchronous interface that would accpt a callback, this would be my ideal. Is this possible with Portenta and UDPMulticast?
It seems the problem is that in the "WiFiUDP" class the constructor hard-codes the socket timeout to be 1,000mS and provides no public method or member to adjust this. Really poor design.
The "UDPSocket" class exposes the "set_timeout" method (used in the "WiFiUDP" constructor, but neither the socket itself nor the method are accessible from a sketch.
Except of course the socket variable is "private". I don't think private members may be accessed in a subclass, only "protected" members may be accessed by a derived class.
Yes, that is how I proved my hypothesis was correct. Problem is that there are a number of PRs for libraries outstanding for several months, so, the chances of it being merged soon are not great.
Thanks for the posts, I really appreciate your efforts.