diff --git a/esphome/components/packet_interface/radio_link.h b/esphome/components/packet_interface/radio_link.h index 823a9819016..5a7d3bf87e1 100644 --- a/esphome/components/packet_interface/radio_link.h +++ b/esphome/components/packet_interface/radio_link.h @@ -49,9 +49,10 @@ class RadioLink : public RadioLinkBase, public Listener { this->radio_->register_listener(this); this->disable_loop(); } - // Runs only during a busy period; a busy flag that never clears keeps it running + // Runs only during a busy period; a busy flag that never clears keeps it running. A radio that failed meanwhile + // is not read again, as reading it may wait on the radio every time void loop() override { - if (!this->radio_->is_receiving()) + if (!this->radio_->is_ready() || !this->radio_->is_receiving()) this->radio_free_(); } diff --git a/tests/components/packet_interface/radio_link.cpp b/tests/components/packet_interface/radio_link.cpp index a2a3275784a..4867d134bc1 100644 --- a/tests/components/packet_interface/radio_link.cpp +++ b/tests/components/packet_interface/radio_link.cpp @@ -105,6 +105,16 @@ TEST_F(RadioLinkTest, FailedRadioRefusesSends) { EXPECT_TRUE(this->radio_.sent.empty()); } +TEST_F(RadioLinkTest, RadioFailingWhileBusyEndsBusyPeriod) { + set_time(START); + this->radio_.receiving = true; + EXPECT_FALSE(this->send_()); + EXPECT_TRUE(this->link_.is_in_loop_state()); + this->radio_.fail(); + this->link_.loop(); + EXPECT_TRUE(this->link_.is_idle()); +} + TEST_F(RadioLinkTest, ReceivedPacketCarriesSignal) { Packet received; PacketMetaData meta; diff --git a/tests/unit_tests/test_lora_packet_interface.py b/tests/unit_tests/test_lora_packet_interface.py index c0c90799d56..442384cc3b6 100644 --- a/tests/unit_tests/test_lora_packet_interface.py +++ b/tests/unit_tests/test_lora_packet_interface.py @@ -137,7 +137,6 @@ class _FullConfig(dict): "packet_mode": True, "payload_length": 0, "sync_value": [], - "preamble_detect": 0, }, {}, "sync_value",