Skip to content

armgit / flix

Public Imported from GitHub
0

Making an ESP32-based quadcopter from scratch

Bring back espnow tx buffering keeping resends disabled Buffering is needed for sending large prints, otherwise the espnow internal buffer overflows. Make onSent always think there was success send, so there won't be any resends. Print lost espnow packets count on wifi console command.

Oleg Kalachev52b74afba6f1
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());