diff --git a/components/LD2450/LD2450.cpp b/components/LD2450/LD2450.cpp index 789e220..29c600a 100644 --- a/components/LD2450/LD2450.cpp +++ b/components/LD2450/LD2450.cpp @@ -158,7 +158,6 @@ namespace esphome::ld2450 { // Try to read the header and abort on mismatch const uint8_t *header; - bool skip = false; uint8_t message_type; uint8_t first_byte = read(); if (first_byte == update_header[0]) @@ -173,16 +172,20 @@ namespace esphome::ld2450 } else { - skip = true; + continue; } - for (int i = 1; i < 4 && !skip; i++) + bool header_match = true; + for (int i = 1; i < 4; i++) { if (read() != header[i]) - skip = true; + { + header_match = false; + break; + } } - if (!skip) + if (header_match) // Flag successful header reading peek_status_ = message_type; } @@ -496,4 +499,4 @@ namespace esphome::ld2450 flush(); } -} // namespace esphome::ld2450 \ No newline at end of file +} // namespace esphome::ld2450