ESPNow doesn't recover from buffer error
Port, board and/or hardware
ESP32_GENERIC_C3-20250809-v1.26.0; ESP32 C3 Supermini
MicroPython version
MicroPython v1.26.0 on 2025-08-09; ESP32C3 module with ESP32C3
Reproduction
From the sender, send a too-large message via ESP32 (>250 bytes), followed by more 'correct' messages:
e.send(peer, "a" * 10)
e.send(peer, "a" * 10)
e.send(peer, "a" * 10)
e.send(peer, "a" * 251)
e.send(peer, "a" * 10)
e.send(peer, "a" * 10)
e.send(peer, "a" * 10)
Receive the messages, catching errors:
while True:
try:
print(e.recv())
except Exception as err:
print(err)
Expected behaviour
The first too-large message should raise an exception. Subsequent 'correct' messages should then continue as normal.
Observed behaviour
The first messages appear as expected - once the long message is received, the exception is printed repeatedly and no further messages are seen:
[b' n\xf1h\x98\x90', b'bbbbbbbbbb']
[b' n\xf1h\x98\x90', b'bbbbbbbbbb']
[b' n\xf1h\x98\x90', b'bbbbbbbbbb']
ValueError: ESPNow.recv(): buffer error
ValueError: ESPNow.recv(): buffer error
ValueError: ESPNow.recv(): buffer error
ValueError: ESPNow.recv(): buffer error
ValueError: ESPNow.recv(): buffer error
<repeats forever>
Additional Information
A workaround for this issue is to deinit on ValueError, i.e.:
try:
e.recv()
except ValueError:
e.active(False)
e.active(True)
Code of Conduct
Yes, I agree
esp32: ESPNow.config() "buffer" option renamed to "rxbuf".
This PR renames the ESPNow.config() option to set the size of the buffer for incoming espnow messages from "buffer" to "rxbuf". This now matches the documentation and usage in the esp8266 espnow module.
This corrects the bug reported by @peterhinch in discussion #11691.
ports/esp32/modespnow.c: ESPNow.config(): correct "buffer" option to "rxbuf" to match documentation and esp8266 usage.