Repeater, room server, sensor, companion: a node with the RX duty cycle on no longer stops transmitting

Changelog: Repeater, room server, sensor, companion: a node with the RX duty cycle (`radio.rxps`) on no longer stops transmitting, `set radio.rxps off` takes effect at once, and a node silent for weeks keeps sending
Changelog-cs: Repeater, room server, sensor, companion: uzel se zapnutým RX duty cycle (`radio.rxps`) už nepřestane vysílat, `set radio.rxps off` platí hned a uzel, který týdny mlčel, dál vysílá
Changelog-topic: rxps-stall-46
This commit is contained in:
tth committed 2026-12-04 00:09:28 +01:00
1 parent 63823f526b
commit 9daead0089
3 files changed
+60 -3

No files matched your search

+36
View File
@@ -40,6 +40,8 @@ public:
int standby_calls = 0;
int start_receive_calls = 0;
int read_data_calls = 0;
bool fire_dio1_in_start_tx = false;
bool fire_dio1_in_start_rx = false;
void setPacketReceivedAction(void (*func)(void)) override { isr_fn = func; }
void fireDio1() { if (isr_fn) isr_fn(); }
@@ -58,6 +60,18 @@ public:
int16_t startReceive() override {
start_receive_calls++;
irq_flags = 0;
if (fire_dio1_in_start_rx) {
fire_dio1_in_start_rx = false;
irq_flags = (1UL << RADIOLIB_IRQ_RX_DONE);
fireDio1();
}
return RADIOLIB_ERR_NONE;
}
int16_t startTransmit(uint8_t*, size_t) override {
if (fire_dio1_in_start_tx) {
fire_dio1_in_start_tx = false;
fireDio1();
}
return RADIOLIB_ERR_NONE;
}
size_t getPacketLength(bool) override { return next_pkt_len; }
@@ -230,6 +244,28 @@ TEST_F(RxpsFixture, KickRxClearsIrqAndResetsReceivingState) {
EXPECT_GT(wrap.reset_receiving_calls, 0);
}
TEST_F(RxpsFixture, TxDoneInsideStartTransmitIsNotLost) {
// Simulate TX_DONE arriving before startTransmit() returns (e.g. BLE
// SoftDevice preemption on nRF52).
radio.fire_dio1_in_start_tx = true;
uint8_t tx[4] = {1, 2, 3, 4};
ASSERT_TRUE(wrap.startSendRaw(tx, sizeof(tx)));
EXPECT_TRUE(wrap.isSendComplete());
wrap.onSendFinished();
}
TEST_F(RxpsFixture, RxDoneInsideStartReceiveIsNotLost) {
ASSERT_TRUE(wrap.setRxPowerSaving(false, 20000, 60000));
radio.fire_dio1_in_start_rx = true;
radio.next_pkt_len = 6;
uint8_t buf[16];
// First recvRaw() re-arms continuous RX; DIO1 fires before startReceive() returns.
EXPECT_EQ(wrap.recvRaw(buf, sizeof(buf)), 0);
// Next recvRaw() must see STATE_INT_READY and read the packet.
EXPECT_EQ(wrap.recvRaw(buf, sizeof(buf)), 6);
EXPECT_EQ(wrap.getPacketsRecv(), 1u);
}
} // namespace
int main(int argc, char** argv) {