I have a relatively simple ESP32 application using UDP over WiFi and the Arduino IDE. The receiver app is being polled every two seconds by a test app. All datagrams are 5 bytes long. Generally, the receiver responds in about 150ms, but every 5,000 packets or so, the receiver fails to respond until another poll arrives, and then the missing response is received along with the response to the next poll. Initially I though I was losing UDP packets on the WiFi, but it seems that sometimes a received packet is not received until "bumped" by the next received poll.
Datagram arrival is being monitored as follows
pktSize = udp.parsePacket();
pktSize is not set non-zero very occasionally until another packet arises.
On a hunch, I've replace the #include "WiFi.h" with #include "esp_wifi.h" which seems to fix the problem, and also reduce the response time to a poll from about 150ms to 60ms.
Does anyone have any idea of what is going on? What is the difference between "Wifi.h" and "esp_wifi.h" - Most esp32 apps I see seem to use "WiFi.h"?
Thanks