Skip to content

Commit 52f1d69

Browse files
committed
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.
1 parent db23aa0 commit 52f1d69

3 files changed

Lines changed: 20 additions & 6 deletions

File tree

src/helpers/radiolib/CustomSTM32WLxWrapper.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,11 @@ class CustomSTM32WLxWrapper : public RadioLibWrapper {
2424
uint8_t getSpreadingFactor() const override { return ((CustomSTM32WLx *)_radio)->spreadingFactor; }
2525

2626
void doResetAGC() override { sx126xResetAGC((SX126x *)_radio); }
27+
28+
uint8_t getCodingRate() const override {
29+
return ((CustomSTM32WLx *)_radio)->codingRate + 4;
30+
}
31+
float getFreqMHz() const override {
32+
return ((CustomSTM32WLx *)_radio)->freqMHz;
33+
}
2734
};

src/helpers/radiolib/RadioLibWrappers.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22
#define RADIOLIB_STATIC_ONLY 1
33
#include "RadioLibWrappers.h"
44

5+
// Platform-safe yield for use in busy-wait loops
6+
#ifdef NRF52_PLATFORM
7+
#define YIELD_TASK() vTaskDelay(1)
8+
#else
9+
#define YIELD_TASK() delay(1)
10+
#endif
11+
512
#define STATE_IDLE 0
613
#define STATE_RX 1
714
#define STATE_TX_WAIT 3
@@ -196,17 +203,17 @@ bool RadioLibWrapper::isChannelActive() {
196203
uint32_t max_backoff = min(base_ms * (1u << _busy_count), (uint32_t)16000);
197204
uint32_t backoff_until = millis() + random(max_backoff / 2, max_backoff);
198205
while (millis() < backoff_until) {
199-
vTaskDelay(1);
206+
YIELD_TASK();
200207
}
201208
return true;
202209
}
203-
vTaskDelay(1);
210+
YIELD_TASK();
204211
}
205212
// Channel free: reset busy counter and add small jitter
206213
_busy_count = 0;
207214
uint32_t jitter_until = millis() + random(0, 500);
208215
while (millis() < jitter_until) {
209-
vTaskDelay(1);
216+
YIELD_TASK();
210217
}
211218
return false;
212219
}

src/helpers/radiolib/RadioLibWrappers.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ class RadioLibWrapper : public mesh::Radio {
4343
virtual uint8_t getSpreadingFactor() const { return LORA_SF; }
4444
static uint16_t preambleLengthForSF(uint8_t sf) { return sf <= 8 ? 32 : 16; }
4545
void updatePreamble(uint8_t sf) { _preamble_sf = sf; _radio->setPreambleLength(preambleLengthForSF(sf)); }
46-
virtual uint8_t getCodingRate() const = 0;
47-
virtual float getFreqMHz() const = 0;
48-
46+
virtual uint8_t getCodingRate() const { return 8; } // default CR4/8, override in subclass
47+
virtual float getFreqMHz() const { return 0.0f; } // default unknown, override in subclass
48+
//
4949
bool isJapanMode() const {
5050
float freq = getFreqMHz();
5151
return (fabsf(freq - 920.800f) < 0.05f ||

0 commit comments

Comments
 (0)