[hlk_fm22x] Drain exact frame bytes on oversize response

Discard exactly length+1 (payload + checksum) instead of flushing
the entire RX buffer, which could eat bytes from the next frame.
This commit is contained in:
J. Nick Koston
2026-02-08 02:51:27 -06:00
parent eb3bad823b
commit 78f98fa08f

View File

@@ -135,7 +135,8 @@ void HlkFm22xComponent::recv_command_() {
if (length > HLK_FM22X_MAX_RESPONSE_SIZE) {
ESP_LOGE(TAG, "Response too large: %u bytes", length);
while (this->available())
// Discard exactly the remaining payload and checksum for this frame
for (uint16_t i = 0; i < length + 1 && this->available(); ++i)
this->read();
return;
}