Skip to content

Commit 3c89ef8

Browse files
committed
Purge buffer before reset
If we are resetting on a fresh boot and radio powered down with us there is a chance we read the wrong StartUpMessage and end up sending config messages before the radio is ready. This will purge the buffer before the reset.
1 parent f3f38f4 commit 3c89ef8

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/MainClasses/ANTPLUS_AntPlusRouter.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,10 @@ uint8_t AntPlusRouter::resetRadio(uint8_t waitForStartup) {
146146
_profiles[i]->stop();
147147
}
148148
}
149+
// purge buffer of any left over messages
150+
do {
151+
_ant->readPacket();
152+
} while (_ant->getResponse().isAvailable());
149153
send(rs);
150154
_radioStarted = ANTPLUS_DRIVER_STATE_UNKNOWN;
151155
if (waitForStartup == ANTPLUS_RESET_WAIT_FOR_STARTUP) {

0 commit comments

Comments
 (0)