refactor: drop unused radio API

Transceiver::flushTx() had no caller; suspendTx() is the only flush.
RadioScheduler::hasRoom() was only ever asked about a normal job, so it no
longer takes a priority flag.  The tests check the reserved stop slots
through submit() instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
cjkas 2026-10-13 15:11:35 +02:00
parent 0b7c57a9ab
commit 29d642b6f4
5 changed files with 12 additions and 22 deletions

View file

@ -43,8 +43,8 @@ uint32_t RadioScheduler::submit(somfy_tx_job_t &job, bool priority, uint16_t del
this->count++;
return job.seq;
}
bool RadioScheduler::hasRoom(bool priority) const {
return !this->suspendMask && admits(TX_JOB_QUEUE_SIZE - this->count, priority) && this->outcomesFit();
bool RadioScheduler::hasRoom() const {
return !this->suspendMask && admits(TX_JOB_QUEUE_SIZE - this->count, false) && this->outcomesFit();
}
bool RadioScheduler::outcomesFit() const {
// Each job not yet ended reports at most two outcomes: started, then how it

View file

@ -26,8 +26,8 @@ class RadioScheduler {
// delayMs after it was queued and after the job ahead of it ended, and holds
// up the jobs queued behind it.
uint32_t submit(somfy_tx_job_t &job, bool priority, uint16_t delayMs, uint32_t now);
// Whether a job would be taken right now.
bool hasRoom(bool priority) const;
// Whether a normal (not priority) job would be taken right now.
bool hasRoom() const;
// For the radio task: takes the job to send next. False when there is
// none due, waitMs then says how long until there is (RADIO_WAIT_FOREVER
// when nothing waits). A job taken goes on air through start() and

View file

@ -4660,15 +4660,7 @@ bool Transceiver::txHasRoom() {
// Without a radio task submitTx() fails straight away so there is no point waiting.
if(!txTaskHandle) return true;
TxQueueLock lock;
return this->sched.hasRoom(false);
}
void Transceiver::flushTx() {
{
TxQueueLock lock;
this->sched.flush(millis());
}
// Stop waiting on a delayed job that is gone.
if(txTaskHandle) xTaskNotifyGive(txTaskHandle);
return this->sched.hasRoom();
}
void Transceiver::suspendTx(uint8_t reason) {
{
@ -4742,7 +4734,7 @@ void Transceiver::txTask(void *arg) {
haveJob = trans->sched.next(millis(), job, waitMs);
}
if(haveJob) trans->runJob(job);
// submitTx() and flushTx() wake us for a new job or a flush.
// submitTx() and suspendTx() wake us for a new job or a flush.
else ulTaskNotifyTake(pdTRUE, waitMs == RADIO_WAIT_FOREVER ? portMAX_DELAY : pdMS_TO_TICKS(waitMs) + 1);
}
}

View file

@ -462,7 +462,6 @@ class Transceiver {
// Hands a job to the radio task, see RadioScheduler::submit(). Returns its
// ticket, 0 when the radio can't take it. Safe from any task.
uint32_t submitTx(somfy_tx_job_t &job, bool priority = false, uint16_t delayMs = 0);
void flushTx();
void suspendTx(uint8_t reason);
void resumeTx(uint8_t reason);
bool txSuspended();

View file

@ -136,16 +136,15 @@ static void test_normal_jobs_leave_the_reserved_slots() {
RadioScheduler s;
for(uint8_t i = 0; i < TX_JOB_QUEUE_SIZE - TX_RESERVED_SLOTS; i++)
TEST_ASSERT_NOT_EQUAL(0, submit(s, REMOTE_B));
TEST_ASSERT_FALSE(s.hasRoom(false));
TEST_ASSERT_TRUE(s.hasRoom(true));
TEST_ASSERT_FALSE(s.hasRoom());
TEST_ASSERT_EQUAL_UINT32(0, submit(s, REMOTE_B));
TEST_ASSERT_NOT_EQUAL(0, submit(s, REMOTE_A, 0, true));
}
static void test_stops_use_the_reserved_slots() {
RadioScheduler s;
for(uint8_t i = 0; i < TX_JOB_QUEUE_SIZE - TX_RESERVED_SLOTS; i++) submit(s, REMOTE_B);
for(uint8_t i = 0; i < TX_RESERVED_SLOTS; i++)
TEST_ASSERT_NOT_EQUAL(0, submit(s, REMOTE_A, 0, true));
TEST_ASSERT_FALSE(s.hasRoom(true));
TEST_ASSERT_EQUAL_UINT32(0, submit(s, REMOTE_A, 0, true));
}
static void test_a_refused_job_has_no_ticket() {
@ -160,7 +159,7 @@ static void test_taking_a_job_frees_its_slot() {
RadioScheduler s;
for(uint8_t i = 0; i < TX_JOB_QUEUE_SIZE - TX_RESERVED_SLOTS; i++) submit(s, REMOTE_B);
runNext(s);
TEST_ASSERT_TRUE(s.hasRoom(false));
TEST_ASSERT_TRUE(s.hasRoom());
}
/*********************************************************************
@ -368,7 +367,7 @@ static void test_no_outcome_is_lost_when_events_arent_collected() {
}
TEST_ASSERT_TRUE(accepted > 0);
TEST_ASSERT_TRUE(accepted < 200);
TEST_ASSERT_FALSE(s.hasRoom(false));
TEST_ASSERT_FALSE(s.hasRoom());
uint32_t started = 0, finished = 0;
somfy_tx_event_t evt;
while(s.popEvent(evt)) {
@ -377,7 +376,7 @@ static void test_no_outcome_is_lost_when_events_arent_collected() {
}
TEST_ASSERT_EQUAL_UINT32(accepted, started);
TEST_ASSERT_EQUAL_UINT32(accepted, finished);
TEST_ASSERT_TRUE(s.hasRoom(false));
TEST_ASSERT_TRUE(s.hasRoom());
TEST_ASSERT_NOT_EQUAL(0, submit(s, REMOTE_A));
}
static void test_flush_reports_every_drop_when_events_arent_collected() {
@ -422,7 +421,7 @@ static void test_suspend_flushes_and_refuses_jobs() {
s.suspend(TX_SUSPEND_SCAN, 0);
TEST_ASSERT_TRUE(s.suspended());
assertEvent(s, tx_event_t::dropped, a);
TEST_ASSERT_FALSE(s.hasRoom(true));
TEST_ASSERT_FALSE(s.hasRoom());
TEST_ASSERT_EQUAL_UINT32(0, submit(s, REMOTE_A));
TEST_ASSERT_EQUAL_UINT32(0, submit(s, REMOTE_A, 0, true));
assertNoEvents(s);