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.
This commit is contained in:
Oleg Kalachev
2026-06-09 03:23:30 +03:00
parent 0ca2473655
commit 52b74afba6
2 changed files with 6 additions and 4 deletions
+5 -4
View File
@@ -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
}
};
+1
View File
@@ -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());