a star every time it sends. I can see weird pauses sometimes in the output of stars which probably correspond to the dropping of UDP frames. But, why?! That sketch does nothing but send UPD frames and wait around in between times. There's nothing running to bog it down.
This is all with a WROOM-32 module. I suspect that the PCB antenna might be garbage but this module is running on a board right next to the PC and the signal strength seems decent enough. Has anyone gotten UDP packets to reliably send from the ESP32? Yes, I know UDP is not reliable but it should be sending more than 75% of the packets. It ought to get to at least 95% of the packets delivered in this case, and probably closer to 99 - 99.9%. Instead I really am getting only like 75% or less through whether I send at 500ms or 100ms. I shudder to even attempt 10ms.
Code: Select all
#include <WiFi.h>
byte i = 0;
byte serialBuffer[2048];
int serialBufferLength = 0;
uint32_t lastFlushMicros = 0;
WiFiUDP wifiUDPServer;
IPAddress broadcastAddr(192,168,4,255);
void setup()
{
Serial.begin(115200);
WiFi.mode(WIFI_AP);
WiFi.softAP("ESP32DUE", "1234PASSWORD");
Serial.print("Wifi setup as SSID ");
Serial.println("ESP32DUE");
Serial.print("IP address: ");
Serial.println(WiFi.softAPIP());
Serial.print("Done with init\n");
}
void loop()
{
serialBufferLength = 400;
delay(100);
//If the max time has passed or the buffer is almost filled then send a frame out
//if ((micros() - lastFlushMicros > 100000) ) {
Serial.write('*');
wifiUDPServer.begin(17222);
wifiUDPServer.beginPacket(broadcastAddr, 17222);
wifiUDPServer.write(serialBuffer, serialBufferLength);
wifiUDPServer.endPacket();
wifiUDPServer.stop();
//lastFlushMicros = micros();
//}
}