Skip to content

Commit 8ed8986

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 ec39772 commit 8ed8986

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
@@ -23,4 +23,11 @@ class CustomSTM32WLxWrapper : public RadioLibWrapper {
2323
}
2424

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

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
@@ -194,17 +201,17 @@ bool RadioLibWrapper::isChannelActive() {
194201
uint32_t max_backoff = min(base_ms * (1u << _busy_count), (uint32_t)16000);
195202
uint32_t backoff_until = millis() + random(max_backoff / 2, max_backoff);
196203
while (millis() < backoff_until) {
197-
vTaskDelay(1);
204+
YIELD_TASK();
198205
}
199206
return true;
200207
}
201-
vTaskDelay(1);
208+
YIELD_TASK();
202209
}
203210
// Channel free: reset busy counter and add small jitter
204211
_busy_count = 0;
205212
uint32_t jitter_until = millis() + random(0, 500);
206213
while (millis() < jitter_until) {
207-
vTaskDelay(1);
214+
YIELD_TASK();
208215
}
209216
return false;
210217
}

src/helpers/radiolib/RadioLibWrappers.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ class RadioLibWrapper : public mesh::Radio {
3939
}
4040

4141
virtual float getCurrentRSSI() =0;
42-
virtual uint8_t getCodingRate() const = 0;
43-
virtual float getFreqMHz() const = 0;
44-
42+
virtual uint8_t getCodingRate() const { return 8; } // default CR4/8, override in subclass
43+
virtual float getFreqMHz() const { return 0.0f; } // default unknown, override in subclass
44+
//
4545
bool isJapanMode() const {
4646
float freq = getFreqMHz();
4747
return (fabsf(freq - 920.800f) < 0.05f ||

0 commit comments

Comments
 (0)