WIP: Fix packet loss in the ESP-NOW and RS232 bridges#3038
Draft
ViezeVingertjes wants to merge 6 commits into
Draft
WIP: Fix packet loss in the ESP-NOW and RS232 bridges#3038ViezeVingertjes wants to merge 6 commits into
ViezeVingertjes wants to merge 6 commits into
Conversation
ViezeVingertjes
force-pushed
the
fix/espnow-bridge-reliability
branch
from
July 26, 2026 09:57
1fdfdfb to
7fcd271
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ESP-NOW
onDataRecv()called_mgr->allocNew()andqueueInbound()straight from theWi-Fi task.
PacketQueuehas no locking, so packets leaked from the 32 entrypool until
allocNew()returned NULL and the node dropped both LoRa andbridged receives. Callbacks now only fill a ring buffer; the rest happens in
loop(), like RS232Bridge already did.sendPacket()ranwriteTo()into a 246 byte buffer and checked the sizeafterwards.
writeTo()can emit 253 bytes.esp_now_send()returningESP_ERR_ESPNOW_NO_MEMunder burst load discardedthe packet. Frames now queue and retry, with a timeout so a lost send callback
cannot wedge the queue.
bridge.secretcaused a modulo by zero.RS232
No threading bug, but it discarded fully received frames when the pool was empty.
Frames now queue and convert once a slot frees up. Parser moved into
BridgeSerialFramer, fixing zero length frames reachingreadFrom()andrejected frames swallowing the next header.
New commands
get bridge.rxstats,get bridge.txstats,set bridge.stats reset, on bothbridge types. Comparing one node's TX against another's
RX inshows whetherframes are lost on the link or locally.
Known limit: packets above 246 bytes still cannot cross the ESP-NOW bridge.
Counted as
TX bignow. Fixing it needs fragmentation.62 new unit tests in the existing
nativeenv (77 total). Builds checked onESP32, nRF52, RP2040 and STM32.
Contains LLM assisted changes
[Currently being tested]