Fix build for non-FreeRTOS and non-SX1262 platforms

- Replace vTaskDelay(1) with YIELD_TASK() macro for platform compatibility
  (FreeRTOS: vTaskDelay, others: delay)
- Make getCodingRate() and getFreqMHz() non-pure virtual with defaults
  (default CR4/8, default freq 0.0f for unknown platforms)
- Add getCodingRate() and getFreqMHz() to CustomSTM32WLxWrapper

All environments now build successfully.
This commit is contained in:
jirogit 2026-03-28 02:50:06 -07:00
parent 4276d84070
commit 56a2d93aa4
3 changed files with 20 additions and 6 deletions

View file

@ -23,4 +23,11 @@ public:
}
void doResetAGC() override { sx126xResetAGC((SX126x *)_radio); }
uint8_t getCodingRate() const override {
return ((CustomSTM32WLx *)_radio)->codingRate + 4;
}
float getFreqMHz() const override {
return ((CustomSTM32WLx *)_radio)->freqMHz;
}
};

View file

@ -2,6 +2,13 @@
#define RADIOLIB_STATIC_ONLY 1
#include "RadioLibWrappers.h"
// Platform-safe yield for use in busy-wait loops
#ifdef NRF52_PLATFORM
#define YIELD_TASK() vTaskDelay(1)
#else
#define YIELD_TASK() delay(1)
#endif
#define STATE_IDLE 0
#define STATE_RX 1
#define STATE_TX_WAIT 3
@ -194,17 +201,17 @@ bool RadioLibWrapper::isChannelActive() {
uint32_t max_backoff = min(base_ms * (1u << _busy_count), (uint32_t)16000);
uint32_t backoff_until = millis() + random(max_backoff / 2, max_backoff);
while (millis() < backoff_until) {
vTaskDelay(1);
YIELD_TASK();
}
return true;
}
vTaskDelay(1);
YIELD_TASK();
}
// Channel free: reset busy counter and add small jitter
_busy_count = 0;
uint32_t jitter_until = millis() + random(0, 500);
while (millis() < jitter_until) {
vTaskDelay(1);
YIELD_TASK();
}
return false;
}

View file

@ -39,9 +39,9 @@ public:
}
virtual float getCurrentRSSI() =0;
virtual uint8_t getCodingRate() const = 0;
virtual float getFreqMHz() const = 0;
virtual uint8_t getCodingRate() const { return 8; } // default CR4/8, override in subclass
virtual float getFreqMHz() const { return 0.0f; } // default unknown, override in subclass
//
bool isJapanMode() const {
float freq = getFreqMHz();
return (fabsf(freq - 920.800f) < 0.05f ||