mirror of
https://github.com/meshcore-dev/MeshCore.git
synced 2026-04-20 22:13:47 +00:00
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:
parent
4276d84070
commit
56a2d93aa4
3 changed files with 20 additions and 6 deletions
|
|
@ -23,4 +23,11 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
void doResetAGC() override { sx126xResetAGC((SX126x *)_radio); }
|
void doResetAGC() override { sx126xResetAGC((SX126x *)_radio); }
|
||||||
|
|
||||||
|
uint8_t getCodingRate() const override {
|
||||||
|
return ((CustomSTM32WLx *)_radio)->codingRate + 4;
|
||||||
|
}
|
||||||
|
float getFreqMHz() const override {
|
||||||
|
return ((CustomSTM32WLx *)_radio)->freqMHz;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,13 @@
|
||||||
#define RADIOLIB_STATIC_ONLY 1
|
#define RADIOLIB_STATIC_ONLY 1
|
||||||
#include "RadioLibWrappers.h"
|
#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_IDLE 0
|
||||||
#define STATE_RX 1
|
#define STATE_RX 1
|
||||||
#define STATE_TX_WAIT 3
|
#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 max_backoff = min(base_ms * (1u << _busy_count), (uint32_t)16000);
|
||||||
uint32_t backoff_until = millis() + random(max_backoff / 2, max_backoff);
|
uint32_t backoff_until = millis() + random(max_backoff / 2, max_backoff);
|
||||||
while (millis() < backoff_until) {
|
while (millis() < backoff_until) {
|
||||||
vTaskDelay(1);
|
YIELD_TASK();
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
vTaskDelay(1);
|
YIELD_TASK();
|
||||||
}
|
}
|
||||||
// Channel free: reset busy counter and add small jitter
|
// Channel free: reset busy counter and add small jitter
|
||||||
_busy_count = 0;
|
_busy_count = 0;
|
||||||
uint32_t jitter_until = millis() + random(0, 500);
|
uint32_t jitter_until = millis() + random(0, 500);
|
||||||
while (millis() < jitter_until) {
|
while (millis() < jitter_until) {
|
||||||
vTaskDelay(1);
|
YIELD_TASK();
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -39,9 +39,9 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual float getCurrentRSSI() =0;
|
virtual float getCurrentRSSI() =0;
|
||||||
virtual uint8_t getCodingRate() const = 0;
|
virtual uint8_t getCodingRate() const { return 8; } // default CR4/8, override in subclass
|
||||||
virtual float getFreqMHz() const = 0;
|
virtual float getFreqMHz() const { return 0.0f; } // default unknown, override in subclass
|
||||||
|
//
|
||||||
bool isJapanMode() const {
|
bool isJapanMode() const {
|
||||||
float freq = getFreqMHz();
|
float freq = getFreqMHz();
|
||||||
return (fabsf(freq - 920.800f) < 0.05f ||
|
return (fabsf(freq - 920.800f) < 0.05f ||
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue