Fix the bug where no information can be received the first time after…#1753
Fix the bug where no information can be received the first time after…#1753MGJ520 wants to merge 3 commits intomeshcore-dev:devfrom
Conversation
… reconfiguring the radio
|
|
||
| radio_set_params(_prefs.freq, _prefs.bw, _prefs.sf, _prefs.cr); | ||
| //You need to clear the old registers, otherwise the LoRa module won't receive any information the first time. | ||
| _radio->onSendFinished(); |
There was a problem hiding this comment.
Calling _radio->onSendFinished() unconditionally from app-layer reconfiguration code is unsafe when a TX is still in progress. In the dispatcher flow, send completion drives packet accounting/release (src/Dispatcher.cpp:62-79). For radios like ESP-NOW, onSendFinished() just flips completion state (src/helpers/esp32/ESPNOWRadio.cpp:90-92), so this can mark an unsent/unfinished packet as sent and release it prematurely on the next dispatcher cycle.
Why this matters:
This is a correctness issue (possible packet loss with false success accounting) and can be timing-dependent, making field failures hard to reproduce.
Suggested direction:
Use a dedicated “re-enter RX after reconfigure” API that does not mutate TX-completion state, or gate reconfiguration on “no outbound TX in progress” before forcing RX restart.
There was a problem hiding this comment.
ok,I understand, thank you for reviewing.
Fix issue where no messages can be received after reconfiguring the radio, specifically on the first receive attempt.
For example: 1. First, after the two devices successfully communicate through direct connection, they simultaneously modify the radio configuration.