mirror of
https://github.com/esphome/esphome.git
synced 2026-03-02 18:58:20 -07:00
[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:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user