diff --git a/flix/util.h b/flix/util.h index 5440848..aa9e705 100644 --- a/flix/util.h +++ b/flix/util.h @@ -47,13 +47,14 @@ void splitString(String& str, String& token0, String& token1, String& token2) { if (token2.c_str() == NULL) token2 = ""; } -// Simplified ESP-NOW Serial without tx buffering and resends +// Simplified ESP-NOW Serial without resends class ESPNOWSerial : public ESP_NOW_Serial_Class { public: + int lost = 0; using ESP_NOW_Serial_Class::ESP_NOW_Serial_Class; - void onSent(bool success) override {} // disable resends - size_t write(const uint8_t *data, size_t len) override { - return ESP_NOW_Peer::send(data, len); // pure send without buffering + void onSent(bool success) override { + if (!success) lost++; + ESP_NOW_Serial_Class::onSent(true); // always report success to avoid resends } }; diff --git a/flix/wifi.ino b/flix/wifi.ino index 8d45ca2..eea9d8a 100644 --- a/flix/wifi.ino +++ b/flix/wifi.ino @@ -90,6 +90,7 @@ void printWiFiInfo() { print("Peer MAC: %s\n", MacAddress(espnow.addr()).toString().c_str()); print("Encrypted: %d\n", espnow.isEncrypted()); print("Channel: %d\n", espnow.getChannel()); + print("Lost packets: %d\n", espnow.lost); } else if (WiFi.getMode() == WIFI_MODE_AP) { print("Mode: Access Point (AP)\n"); print("MAC: %s\n", WiFi.softAPmacAddress().c_str());