Support Meshtext beacons across LoRa radio families
Add checked protocol adapters for every project LoRa family and enable Indicator LoRa TX. Preserve normal modem restoration, LR1110 fast hops, LR2021 side detectors and physical-band power limits. Fix SX1276 beacon CAD completion dispatch, concrete-chip validation on multi-chip variants, no-GPS sensor hook linkage and STM32 file construction. Add fault, negative-control and preset coverage to CI. Keep flash-constrained STM32 artifacts disabled after measured opt-in overflows.
This commit is contained in:
1 parent
009bfff383
commit
8a49a98709
32 files changed
+1506
-38
No files matched your search
@@ -155,7 +155,7 @@ bool textValue(const char* text, char* output) {
|
||||
return true;
|
||||
}
|
||||
File makeFile(FILESYSTEM* fs) {
|
||||
#if defined(NRF52_PLATFORM)
|
||||
#if defined(NRF52_PLATFORM) || defined(STM32_PLATFORM)
|
||||
return File(*fs);
|
||||
#else
|
||||
(void)fs;
|
||||
@@ -163,11 +163,9 @@ File makeFile(FILESYSTEM* fs) {
|
||||
#endif
|
||||
}
|
||||
bool openRead(FILESYSTEM* fs, const char* path, File& file) {
|
||||
#if defined(NRF52_PLATFORM)
|
||||
#if defined(NRF52_PLATFORM) || defined(STM32_PLATFORM)
|
||||
(void)fs;
|
||||
return file.open(path, FILE_O_READ);
|
||||
#elif defined(STM32_PLATFORM)
|
||||
file = fs->open(path, FILE_O_READ);
|
||||
#else
|
||||
file = fs->open(path, "r");
|
||||
#endif
|
||||
@@ -176,10 +174,8 @@ bool openRead(FILESYSTEM* fs, const char* path, File& file) {
|
||||
bool openWrite(FILESYSTEM* fs, const char* path, File& file) {
|
||||
bool present = false;
|
||||
if (!filePresence(fs, path, present) || (present && !fs->remove(path))) return false;
|
||||
#if defined(NRF52_PLATFORM)
|
||||
#if defined(NRF52_PLATFORM) || defined(STM32_PLATFORM)
|
||||
return file.open(path, FILE_O_WRITE);
|
||||
#elif defined(STM32_PLATFORM)
|
||||
file = fs->open(path, FILE_O_WRITE);
|
||||
#else
|
||||
file = fs->open(path, "w");
|
||||
#endif
|
||||
|
||||
@@ -16,6 +16,15 @@ class CustomLLCC68 : public LLCC68 {
|
||||
|
||||
public:
|
||||
CustomLLCC68(Module *mod) : LLCC68(mod) { }
|
||||
int16_t setProfileProtocol(uint8_t syncWord) {
|
||||
// Retain RadioLib's ordinary setters: this wrapper does not own the
|
||||
// CustomSX1262 fast RX packet cache, despite sharing its chip family.
|
||||
int16_t status = LLCC68::setSyncWord(syncWord);
|
||||
if (status == RADIOLIB_ERR_NONE) status = LLCC68::setCRC(1);
|
||||
if (status == RADIOLIB_ERR_NONE) status = LLCC68::explicitHeader();
|
||||
if (status == RADIOLIB_ERR_NONE) status = LLCC68::invertIQ(false);
|
||||
return status;
|
||||
}
|
||||
int16_t setMorseFastRssi() {
|
||||
return setSX126xMorseRssiWindow(this);
|
||||
}
|
||||
|
||||
@@ -16,6 +16,9 @@ public:
|
||||
CustomLLCC68Wrapper(CustomLLCC68& radio, mesh::MainBoard& board) : RadioLibWrapper(radio, board) { }
|
||||
bool supportsMorseTx() const override { return true; }
|
||||
bool supportsMorseRx() const override { return MESH_ENABLE_MORSE_RX && supportsRadioDeepInit(); }
|
||||
#if MESH_ENABLE_MESHTEXT_WIRE
|
||||
bool supportsMeshtext() const override { return true; }
|
||||
#endif
|
||||
|
||||
void powerOff() {
|
||||
if (isCarrierWaveActive()) setCarrierWave(0, 0);
|
||||
@@ -23,6 +26,14 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
#if MESH_ENABLE_MESHTEXT_WIRE
|
||||
bool applyProtocol(mesh::RadioProfileProtocol protocol) override {
|
||||
if (protocol != mesh::RadioProfileProtocol::MeshCore
|
||||
&& protocol != mesh::RadioProfileProtocol::Meshtext) return false;
|
||||
const uint8_t sync = protocol == mesh::RadioProfileProtocol::Meshtext ? 0x2b : 0x12;
|
||||
return static_cast<CustomLLCC68*>(_radio)->setProfileProtocol(sync) == RADIOLIB_ERR_NONE;
|
||||
}
|
||||
#endif
|
||||
int16_t prepareMorseReceiver(float frequency_mhz) override {
|
||||
if (!_board->prepareRadioFrequency(frequency_mhz)) return RADIOLIB_ERR_INVALID_FREQUENCY;
|
||||
_morse_rx_fsk_mode = true;
|
||||
|
||||
@@ -172,6 +172,19 @@ class CustomLR1110 : public LR1110 {
|
||||
return LR1110::setCodingRate(cr, longInterleave);
|
||||
}
|
||||
|
||||
// Protocol changes are outside the acknowledged fast-RX context. Use
|
||||
// checked RadioLib setters so cached packet fields and hardware agree,
|
||||
// including after a partial failure and a later MeshCore restoration.
|
||||
int16_t setProfileProtocol(uint8_t syncWord) {
|
||||
_profileSwitch.invalidate();
|
||||
_profilePacketDirty = false;
|
||||
int16_t status = LR1110::setSyncWord(syncWord);
|
||||
if (status == RADIOLIB_ERR_NONE) status = LR1110::setCRC(2);
|
||||
if (status == RADIOLIB_ERR_NONE) status = LR1110::explicitHeader();
|
||||
if (status == RADIOLIB_ERR_NONE) status = LR1110::invertIQ(false);
|
||||
return status;
|
||||
}
|
||||
|
||||
// A single acknowledged SetModulationParams replaces three RadioLib
|
||||
// setters. Keep RadioLib's cached tuple and automatic LDRO calculation.
|
||||
int16_t setLoRaModulationParams(float bw, uint8_t sf, uint8_t cr) {
|
||||
|
||||
@@ -18,10 +18,21 @@ public:
|
||||
: RadioLibWrapper(radio, board), _deep_init(NULL) { }
|
||||
bool supportsCarrierWave() const override { return true; }
|
||||
bool supportsMorseRx() const override { return MESH_ENABLE_MORSE_RX && supportsRadioDeepInit(); }
|
||||
#if MESH_ENABLE_MESHTEXT_WIRE
|
||||
bool supportsMeshtext() const override { return true; }
|
||||
#endif
|
||||
|
||||
void setDeepInitCallback(DeepInitCallback callback) { _deep_init = callback; }
|
||||
|
||||
protected:
|
||||
#if MESH_ENABLE_MESHTEXT_WIRE
|
||||
bool applyProtocol(mesh::RadioProfileProtocol protocol) override {
|
||||
if (protocol != mesh::RadioProfileProtocol::MeshCore
|
||||
&& protocol != mesh::RadioProfileProtocol::Meshtext) return false;
|
||||
const uint8_t sync = protocol == mesh::RadioProfileProtocol::Meshtext ? 0x2b : 0x12;
|
||||
return static_cast<CustomLR1110*>(_radio)->setProfileProtocol(sync) == RADIOLIB_ERR_NONE;
|
||||
}
|
||||
#endif
|
||||
int16_t startMorseReceiver() override {
|
||||
return static_cast<CustomLR1110*>(_radio)->LR1110::startReceive(
|
||||
RADIOLIB_LR11X0_RX_TIMEOUT_INF, 0, 0, 0);
|
||||
|
||||
@@ -16,6 +16,14 @@ class CustomLR1121 : public LR1121 {
|
||||
public:
|
||||
CustomLR1121(Module *mod) : LR1121(mod) { }
|
||||
|
||||
int16_t setProfileProtocol(uint8_t syncWord) {
|
||||
int16_t status = LR1121::setSyncWord(syncWord);
|
||||
if (status == RADIOLIB_ERR_NONE) status = LR1121::setCRC(2);
|
||||
if (status == RADIOLIB_ERR_NONE) status = LR1121::explicitHeader();
|
||||
if (status == RADIOLIB_ERR_NONE) status = LR1121::invertIQ(false);
|
||||
return status;
|
||||
}
|
||||
|
||||
void setRfSwitchTable(const uint32_t (&pins)[Module::RFSWITCH_MAX_PINS],
|
||||
const Module::RfSwitchMode_t table[]) {
|
||||
_morse_rf_switch.capture(this->mod, pins, table);
|
||||
|
||||
@@ -12,6 +12,9 @@ public:
|
||||
CustomLR1121Wrapper(CustomLR1121& radio, mesh::MainBoard& board) : RadioLibWrapper(radio, board) { }
|
||||
bool supportsMorseTx() const override { return true; }
|
||||
bool supportsMorseRx() const override { return MESH_ENABLE_MORSE_RX && supportsRadioDeepInit(); }
|
||||
#if MESH_ENABLE_MESHTEXT_WIRE
|
||||
bool supportsMeshtext() const override { return true; }
|
||||
#endif
|
||||
void setDeepInitCallback(DeepInitCallback callback) { _deep_init = callback; }
|
||||
|
||||
void powerOff() {
|
||||
@@ -21,6 +24,14 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
#if MESH_ENABLE_MESHTEXT_WIRE
|
||||
bool applyProtocol(mesh::RadioProfileProtocol protocol) override {
|
||||
if (protocol != mesh::RadioProfileProtocol::MeshCore
|
||||
&& protocol != mesh::RadioProfileProtocol::Meshtext) return false;
|
||||
const uint8_t sync = protocol == mesh::RadioProfileProtocol::Meshtext ? 0x2b : 0x12;
|
||||
return static_cast<CustomLR1121*>(_radio)->setProfileProtocol(sync) == RADIOLIB_ERR_NONE;
|
||||
}
|
||||
#endif
|
||||
int16_t startMorseReceiver() override {
|
||||
return static_cast<CustomLR1121*>(_radio)->LR1121::startReceive(
|
||||
RADIOLIB_LR11X0_RX_TIMEOUT_INF, 0, 0, 0);
|
||||
|
||||
@@ -52,6 +52,14 @@ class CustomLR2021 : public LR2021 {
|
||||
public:
|
||||
CustomLR2021(Module *mod) : LR2021(mod) { irqDioNum = LR2021_IRQ_DIO; }
|
||||
|
||||
int16_t setProfileProtocol(uint8_t syncWord) {
|
||||
int16_t status = LR2021::setSyncWord(syncWord);
|
||||
if (status == RADIOLIB_ERR_NONE) status = LR2021::setCRC(2);
|
||||
if (status == RADIOLIB_ERR_NONE) status = LR2021::explicitHeader();
|
||||
if (status == RADIOLIB_ERR_NONE) status = LR2021::invertIQ(false);
|
||||
return status;
|
||||
}
|
||||
|
||||
int16_t beginMorseReceive(float frequency_mhz) {
|
||||
const uint8_t gain = mesh::lr2021::isHighBand(frequency_mhz) ? gainModeHf : gainModeLf;
|
||||
int16_t status = LR2021::beginGFSK(frequency_mhz,
|
||||
|
||||
@@ -20,6 +20,9 @@ public:
|
||||
CustomLR2021Wrapper(CustomLR2021& radio, mesh::MainBoard& board) : RadioLibWrapper(radio, board) { }
|
||||
bool supportsMorseTx() const override { return true; }
|
||||
bool supportsMorseRx() const override { return MESH_ENABLE_MORSE_RX && supportsRadioDeepInit(); }
|
||||
#if MESH_ENABLE_MESHTEXT_WIRE
|
||||
bool supportsMeshtext() const override { return true; }
|
||||
#endif
|
||||
|
||||
void powerOff() {
|
||||
if (isCarrierWaveActive()) setCarrierWave(0, 0);
|
||||
@@ -27,6 +30,14 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
#if MESH_ENABLE_MESHTEXT_WIRE
|
||||
bool applyProtocol(mesh::RadioProfileProtocol protocol) override {
|
||||
if (protocol != mesh::RadioProfileProtocol::MeshCore
|
||||
&& protocol != mesh::RadioProfileProtocol::Meshtext) return false;
|
||||
const uint8_t sync = protocol == mesh::RadioProfileProtocol::Meshtext ? 0x2b : 0x12;
|
||||
return static_cast<CustomLR2021*>(_radio)->setProfileProtocol(sync) == RADIOLIB_ERR_NONE;
|
||||
}
|
||||
#endif
|
||||
int16_t startMorseReceiver() override {
|
||||
return static_cast<CustomLR2021*>(_radio)->LR2021::startReceive(
|
||||
RADIOLIB_LR2021_RX_TIMEOUT_INF, 0, 0, 0);
|
||||
@@ -97,8 +108,9 @@ protected:
|
||||
}
|
||||
|
||||
int16_t applyCachedTxPower(int8_t dbm) override {
|
||||
const float frequency = _params_valid
|
||||
? _cur_freq : ((CustomLR2021 *)_radio)->getFreqMHz();
|
||||
// A TX-only excursion deliberately preserves the normal wrapper cache.
|
||||
// Clamp for the physically selected band, not that normal RX frequency.
|
||||
const float frequency = ((CustomLR2021 *)_radio)->getFreqMHz();
|
||||
return _radio->setOutputPower(mesh::clampLoRaTxPower(dbm, frequency));
|
||||
}
|
||||
|
||||
@@ -158,6 +170,14 @@ protected:
|
||||
}
|
||||
|
||||
bool applySideDetectorConfig(uint8_t primary_sf, float bw) {
|
||||
#if MESH_ENABLE_TX_BEACONS
|
||||
// Saved RX side detectors are not part of an independent TX-only tuple.
|
||||
// Disable them without changing their configuration, then restore the
|
||||
// normal set when the owner's receive-restoration transaction runs.
|
||||
if (isBeaconRadioOwned() && !_beacon_restoring) {
|
||||
return ((CustomLR2021 *)_radio)->setSideDetector(nullptr, 0) == RADIOLIB_ERR_NONE;
|
||||
}
|
||||
#endif
|
||||
if (_profiles.enabled()) {
|
||||
return ((CustomLR2021 *)_radio)->setSideDetector(nullptr, 0) == RADIOLIB_ERR_NONE;
|
||||
}
|
||||
|
||||
@@ -12,6 +12,16 @@ class CustomSTM32WLx : public STM32WLx {
|
||||
|
||||
public:
|
||||
CustomSTM32WLx(STM32WLx_Module *mod) : STM32WLx(mod) { }
|
||||
// STM32WLx inherits the SX126x LoRa packet setters. Unlike CustomSX1262,
|
||||
// this driver has no acknowledged fast-hop cache: every protocol change
|
||||
// repairs the complete CRC/header/IQ tuple through the ordinary API.
|
||||
int16_t setProfileProtocol(uint8_t syncWord) {
|
||||
int16_t status = STM32WLx::setSyncWord(syncWord);
|
||||
if (status == RADIOLIB_ERR_NONE) status = STM32WLx::setCRC(1);
|
||||
if (status == RADIOLIB_ERR_NONE) status = STM32WLx::explicitHeader();
|
||||
if (status == RADIOLIB_ERR_NONE) status = STM32WLx::invertIQ(false);
|
||||
return status;
|
||||
}
|
||||
int16_t setMorseFastRssi() {
|
||||
return setSX126xMorseRssiWindow(this);
|
||||
}
|
||||
|
||||
@@ -18,12 +18,24 @@ public:
|
||||
~CustomSTM32WLxWrapper() { unregisterInterruptAction(); }
|
||||
CustomSTM32WLxWrapper(CustomSTM32WLx& radio, mesh::MainBoard& board) : RadioLibWrapper(radio, board) { }
|
||||
bool supportsMorseTx() const override { return true; }
|
||||
#if MESH_ENABLE_MESHTEXT_WIRE
|
||||
bool supportsMeshtext() const override { return true; }
|
||||
#endif
|
||||
#if MESH_ENABLE_MORSE_RX
|
||||
bool supportsMorseRx() const override { return supportsRadioDeepInit(); }
|
||||
#endif
|
||||
void setDeepInitCallback(DeepInitCallback callback) { _deep_init = callback; }
|
||||
|
||||
protected:
|
||||
#if MESH_ENABLE_MESHTEXT_WIRE
|
||||
bool applyProtocol(mesh::RadioProfileProtocol protocol) override {
|
||||
uint8_t sync;
|
||||
if (protocol == mesh::RadioProfileProtocol::MeshCore) sync = 0x12;
|
||||
else if (protocol == mesh::RadioProfileProtocol::Meshtext) sync = 0x2b;
|
||||
else return false;
|
||||
return static_cast<CustomSTM32WLx*>(_radio)->setProfileProtocol(sync) == RADIOLIB_ERR_NONE;
|
||||
}
|
||||
#endif
|
||||
#if MESH_ENABLE_MORSE_RX
|
||||
float morseReceiverBandwidthKHz() const override { return 4.8f; }
|
||||
int16_t prepareMorseReceiver(float frequency_mhz) override {
|
||||
@@ -71,6 +83,9 @@ protected:
|
||||
|
||||
public:
|
||||
bool setCodingRate(uint8_t cr) override {
|
||||
#if MESH_ENABLE_TX_BEACONS
|
||||
if (isBeaconRadioOwned()) return false;
|
||||
#endif
|
||||
if (isCarrierWaveActive()) return false;
|
||||
return ((CustomSTM32WLx *)_radio)->setCodingRate(cr) == RADIOLIB_ERR_NONE;
|
||||
}
|
||||
|
||||
@@ -41,8 +41,7 @@ public:
|
||||
CustomSX1262Wrapper(CustomSX1262& radio, mesh::MainBoard& board) : RadioLibWrapper(radio, board) { }
|
||||
bool supportsCarrierWave() const override { return true; }
|
||||
bool supportsMorseRx() const override { return MESH_ENABLE_MORSE_RX && supportsRadioDeepInit(); }
|
||||
#if MESH_ENABLE_MESHTEXT_WIRE && (MESH_ENABLE_MESHTEXT_CHAT \
|
||||
|| (MESH_ENABLE_TX_BEACONS && !defined(SENSECAP_INDICATOR_LORA)))
|
||||
#if MESH_ENABLE_MESHTEXT_WIRE
|
||||
bool supportsMeshtext() const override { return true; }
|
||||
#endif
|
||||
|
||||
@@ -73,8 +72,10 @@ protected:
|
||||
}
|
||||
#if MESH_ENABLE_MESHTEXT_WIRE
|
||||
bool applyProtocol(mesh::RadioProfileProtocol protocol) override {
|
||||
// Compiling a shared codec must not change unqualified MC-only modem
|
||||
// behavior or require its foreign sync-word SPI path.
|
||||
if (protocol != mesh::RadioProfileProtocol::MeshCore
|
||||
&& protocol != mesh::RadioProfileProtocol::Meshtext) return false;
|
||||
// Respect an explicitly disabled wire implementation, including builds
|
||||
// that retain other beacon or Companion features.
|
||||
if (!supportsMeshtext()) return protocol == mesh::RadioProfileProtocol::MeshCore;
|
||||
auto* radio = static_cast<CustomSX1262*>(_radio);
|
||||
const uint8_t sync = protocol == mesh::RadioProfileProtocol::Meshtext ? 0x2b : 0x12;
|
||||
|
||||
@@ -16,6 +16,15 @@ class CustomSX1268 : public SX1268 {
|
||||
|
||||
public:
|
||||
CustomSX1268(Module *mod) : SX1268(mod) { }
|
||||
int16_t setProfileProtocol(uint8_t syncWord) {
|
||||
// This driver has no owned fast packet cache. Apply the complete
|
||||
// RadioLib packet tuple, including its normal-IQ register workaround.
|
||||
int16_t status = SX1268::setSyncWord(syncWord);
|
||||
if (status == RADIOLIB_ERR_NONE) status = SX1268::setCRC(1);
|
||||
if (status == RADIOLIB_ERR_NONE) status = SX1268::explicitHeader();
|
||||
if (status == RADIOLIB_ERR_NONE) status = SX1268::invertIQ(false);
|
||||
return status;
|
||||
}
|
||||
int16_t setMorseFastRssi() {
|
||||
return setSX126xMorseRssiWindow(this);
|
||||
}
|
||||
|
||||
@@ -20,6 +20,9 @@ public:
|
||||
CustomSX1268Wrapper(CustomSX1268& radio, mesh::MainBoard& board) : RadioLibWrapper(radio, board) { }
|
||||
bool supportsMorseTx() const override { return true; }
|
||||
bool supportsMorseRx() const override { return MESH_ENABLE_MORSE_RX && supportsRadioDeepInit(); }
|
||||
#if MESH_ENABLE_MESHTEXT_WIRE
|
||||
bool supportsMeshtext() const override { return true; }
|
||||
#endif
|
||||
|
||||
void powerOff() {
|
||||
if (isCarrierWaveActive()) setCarrierWave(0, 0);
|
||||
@@ -27,6 +30,14 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
#if MESH_ENABLE_MESHTEXT_WIRE
|
||||
bool applyProtocol(mesh::RadioProfileProtocol protocol) override {
|
||||
if (protocol != mesh::RadioProfileProtocol::MeshCore
|
||||
&& protocol != mesh::RadioProfileProtocol::Meshtext) return false;
|
||||
const uint8_t sync = protocol == mesh::RadioProfileProtocol::Meshtext ? 0x2b : 0x12;
|
||||
return static_cast<CustomSX1268*>(_radio)->setProfileProtocol(sync) == RADIOLIB_ERR_NONE;
|
||||
}
|
||||
#endif
|
||||
float morseReceiverBandwidthKHz() const override { return 4.8f; }
|
||||
int16_t prepareMorseReceiver(float frequency_mhz) override {
|
||||
if (!_board->prepareRadioFrequency(frequency_mhz)) return RADIOLIB_ERR_INVALID_FREQUENCY;
|
||||
|
||||
@@ -15,6 +15,17 @@ class CustomSX1276 : public SX1276 {
|
||||
public:
|
||||
CustomSX1276(Module *mod) : SX1276(mod) { }
|
||||
|
||||
int16_t setProfileProtocol(uint8_t syncWord) {
|
||||
// Both wire protocols use CRC-on, explicit-header, normal-IQ LoRa.
|
||||
// Use RadioLib's setters so its CRC/header caches and IQ workaround
|
||||
// registers agree with the hardware before the next RX or TX.
|
||||
int16_t status = SX1276::setSyncWord(syncWord);
|
||||
if (status == RADIOLIB_ERR_NONE) status = SX1276::setCRC(true);
|
||||
if (status == RADIOLIB_ERR_NONE) status = SX1276::explicitHeader();
|
||||
if (status == RADIOLIB_ERR_NONE) status = SX1276::invertIQ(false);
|
||||
return status;
|
||||
}
|
||||
|
||||
int16_t beginMorseReceive(float frequency_mhz) {
|
||||
int16_t status = SX1276::beginFSK(frequency_mhz,
|
||||
mesh::MorseRx::ReceiverBitRateKbps, 0.6f, 2.6f, 2, 16, false);
|
||||
@@ -110,25 +121,27 @@ class CustomSX1276 : public SX1276 {
|
||||
int16_t state = startChannelScan();
|
||||
RADIOLIB_ASSERT(state);
|
||||
|
||||
// SX127x getChannelScanResult() reports a free channel before CAD has
|
||||
// completed, so wait on its IRQ pins with the same bounded policy used
|
||||
// by the generic wrapper.
|
||||
const unsigned long started = millis();
|
||||
unsigned long last_watchdog_service = started;
|
||||
while(!this->mod->hal->digitalRead(this->mod->getIrq())) {
|
||||
this->mod->hal->yield();
|
||||
// SX127x getChannelScanResult() reports FREE even before CAD completes.
|
||||
// DIO0 proves CAD_DONE; then read CAD_DETECTED from the actual IRQ flags,
|
||||
// including when completion/detection already happened before this poll.
|
||||
const uint32_t started = millis();
|
||||
uint32_t last_watchdog_service = started;
|
||||
for (;;) {
|
||||
if(this->mod->hal->digitalRead(this->mod->getIrq())) {
|
||||
return getChannelScanResult();
|
||||
}
|
||||
if(this->mod->hal->digitalRead(this->mod->getGpio())) {
|
||||
return(RADIOLIB_PREAMBLE_DETECTED);
|
||||
}
|
||||
const unsigned long now = millis();
|
||||
if(now - last_watchdog_service >= 1000UL) {
|
||||
const uint32_t now = millis();
|
||||
if(uint32_t(now - started) >= timeout_ms) {
|
||||
return(RADIOLIB_ERR_RX_TIMEOUT);
|
||||
}
|
||||
if(uint32_t(now - last_watchdog_service) >= 1000UL) {
|
||||
board.serviceWatchdog();
|
||||
last_watchdog_service = now;
|
||||
}
|
||||
if(now - started >= timeout_ms) {
|
||||
return(RADIOLIB_ERR_RX_TIMEOUT);
|
||||
}
|
||||
this->mod->hal->yield();
|
||||
}
|
||||
return(RADIOLIB_CHANNEL_FREE);
|
||||
}
|
||||
};
|
||||
@@ -13,6 +13,9 @@ public:
|
||||
CustomSX1276Wrapper(CustomSX1276& radio, mesh::MainBoard& board) : RadioLibWrapper(radio, board) { }
|
||||
bool supportsCarrierWave() const override { return supportsRadioDeepInit(); }
|
||||
bool supportsMorseRx() const override { return MESH_ENABLE_MORSE_RX && supportsRadioDeepInit(); }
|
||||
#if MESH_ENABLE_MESHTEXT_WIRE
|
||||
bool supportsMeshtext() const override { return true; }
|
||||
#endif
|
||||
|
||||
void powerOff() {
|
||||
if (isCarrierWaveActive()) setCarrierWave(0, 0);
|
||||
@@ -20,6 +23,14 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
#if MESH_ENABLE_MESHTEXT_WIRE
|
||||
bool applyProtocol(mesh::RadioProfileProtocol protocol) override {
|
||||
if (protocol != mesh::RadioProfileProtocol::MeshCore
|
||||
&& protocol != mesh::RadioProfileProtocol::Meshtext) return false;
|
||||
const uint8_t sync = protocol == mesh::RadioProfileProtocol::Meshtext ? 0x2b : 0x12;
|
||||
return static_cast<CustomSX1276*>(_radio)->setProfileProtocol(sync) == RADIOLIB_ERR_NONE;
|
||||
}
|
||||
#endif
|
||||
int16_t startMorseReceiver() override {
|
||||
return static_cast<CustomSX1276*>(_radio)->receiveDirect();
|
||||
}
|
||||
@@ -109,6 +120,13 @@ protected:
|
||||
int16_t performChannelScan() override {
|
||||
return ((CustomSX1276 *)_radio)->tryScanChannel(cadScanTimeoutMillis(), *_board);
|
||||
}
|
||||
#if MESH_ENABLE_TX_BEACONS
|
||||
int16_t performChannelScanWithTimeout(unsigned long timeout_ms) override {
|
||||
// Beacon CAD has its own modulation-derived deadline. Preserve SX127x's
|
||||
// DIO0 completion rule instead of the generic UNKNOWN-result poll.
|
||||
return static_cast<CustomSX1276*>(_radio)->tryScanChannel(timeout_ms, *_board);
|
||||
}
|
||||
#endif
|
||||
|
||||
bool radioDeepInit() override {
|
||||
if (!prepareRadioHardReset()) return false;
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#define RADIOLIB_STATIC_ONLY 1
|
||||
#include "RadioLibWrappers.h"
|
||||
#include "RadioInterruptEvents.h"
|
||||
#include "RadioProfileChip.h"
|
||||
#include <new>
|
||||
#if defined(ESP32_PLATFORM)
|
||||
#include <esp_heap_caps.h>
|
||||
@@ -440,19 +441,19 @@ mesh::RadioParamApplyResult RadioLibWrapper::trySetParams(float freq, float bw,
|
||||
bool RadioLibWrapper::validateProfile(const mesh::RadioProfileParams& p) const {
|
||||
if (!mesh::RadioProfiles::valid(p)) return false;
|
||||
if (p.protocol == mesh::RadioProfileProtocol::Meshtext && !supportsMeshtext()) return false;
|
||||
#if defined(USE_SX1276)
|
||||
#if MESH_RADIO_PROFILE_CHIP == 1276
|
||||
return p.freq >= 137 && p.freq <= 1020 && p.sf >= 7 && p.bw <= 500;
|
||||
#elif defined(USE_SX1272)
|
||||
#elif MESH_RADIO_PROFILE_CHIP == 1272
|
||||
return p.freq >= 860 && p.freq <= 1020 && p.sf >= 7 && p.bw >= 125 && p.bw <= 500;
|
||||
#elif defined(USE_LLCC68)
|
||||
#elif MESH_RADIO_PROFILE_CHIP == 68
|
||||
return p.freq >= 150 && p.freq <= 960
|
||||
&& ((p.bw == 125 && p.sf <= 9) || (p.bw == 250 && p.sf <= 10)
|
||||
|| (p.bw == 500 && p.sf <= 11));
|
||||
#elif defined(USE_LR2021)
|
||||
#elif MESH_RADIO_PROFILE_CHIP == 2021
|
||||
return (p.freq <= 1090 || p.freq >= 1900) && p.bw >= 31.25 && p.bw <= 1000;
|
||||
#elif defined(USE_LR1110)
|
||||
#elif MESH_RADIO_PROFILE_CHIP == 1110
|
||||
return p.freq <= 960 && p.bw >= 62.5 && p.bw <= 500;
|
||||
#elif defined(USE_SX1268)
|
||||
#elif MESH_RADIO_PROFILE_CHIP == 1268
|
||||
return p.freq >= 410 && p.freq <= 810 && p.bw <= 500;
|
||||
#else
|
||||
return p.freq <= 960 && p.bw <= 500;
|
||||
|
||||
@@ -233,7 +233,13 @@ protected:
|
||||
const float bw = _params_valid ? _cur_bw : static_cast<float>(LORA_BW);
|
||||
return cadScanTimeoutMillis(sf, bw);
|
||||
}
|
||||
#if MESH_ENABLE_TX_BEACONS
|
||||
// A TX-only excursion supplies its own timeout without using the cached
|
||||
// normal RX tuple. Chips with different CAD completion rules override it.
|
||||
virtual int16_t performChannelScanWithTimeout(unsigned long timeout_ms);
|
||||
#else
|
||||
int16_t performChannelScanWithTimeout(unsigned long timeout_ms);
|
||||
#endif
|
||||
virtual int startReceiveMode();
|
||||
virtual void stopReceiveDutyCycle();
|
||||
virtual bool isPacketReady();
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
#pragma once
|
||||
|
||||
// Variant headers can advertise more than one optional chip (Generic E22
|
||||
// defines both USE_SX1262 and USE_SX1268). Validate the concrete transceiver
|
||||
// selected by the build, not whichever optional USE_* branch appears first.
|
||||
#define MESH_PROFILE_CHIP_CustomSX1262 1262
|
||||
#define MESH_PROFILE_CHIP_CustomSTM32WLx 1262
|
||||
#define MESH_PROFILE_CHIP_CustomSX1268 1268
|
||||
#define MESH_PROFILE_CHIP_CustomSX1276 1276
|
||||
#define MESH_PROFILE_CHIP_CustomLLCC68 68
|
||||
#define MESH_PROFILE_CHIP_CustomLR1110 1110
|
||||
#define MESH_PROFILE_CHIP_CustomLR1121 1121
|
||||
#define MESH_PROFILE_CHIP_CustomLR2021 2021
|
||||
#define MESH_PROFILE_CHIP_(name) MESH_PROFILE_CHIP_##name
|
||||
#define MESH_PROFILE_CHIP(name) MESH_PROFILE_CHIP_(name)
|
||||
|
||||
#if defined(RADIO_CLASS)
|
||||
#define MESH_RADIO_PROFILE_CHIP MESH_PROFILE_CHIP(RADIO_CLASS)
|
||||
#elif defined(USE_SX1276)
|
||||
#define MESH_RADIO_PROFILE_CHIP 1276
|
||||
#elif defined(USE_SX1272)
|
||||
#define MESH_RADIO_PROFILE_CHIP 1272
|
||||
#elif defined(USE_LLCC68)
|
||||
#define MESH_RADIO_PROFILE_CHIP 68
|
||||
#elif defined(USE_LR2021)
|
||||
#define MESH_RADIO_PROFILE_CHIP 2021
|
||||
#elif defined(USE_LR1110)
|
||||
#define MESH_RADIO_PROFILE_CHIP 1110
|
||||
#elif defined(USE_LR1121)
|
||||
#define MESH_RADIO_PROFILE_CHIP 1121
|
||||
#elif defined(USE_SX1268)
|
||||
#define MESH_RADIO_PROFILE_CHIP 1268
|
||||
#else
|
||||
#define MESH_RADIO_PROFILE_CHIP 1262
|
||||
#endif
|
||||
@@ -1333,7 +1333,10 @@ void EnvironmentSensorManager::initBasicGPS() {
|
||||
gps_active = false; //Set GPS visibility off until setting is changed
|
||||
#endif
|
||||
}
|
||||
#endif // ENV_INCLUDE_GPS
|
||||
|
||||
// These hooks also exist in no-GPS images. WisBlock slot power can still
|
||||
// supply storage, Ethernet, or another peripheral without a GPS provider.
|
||||
bool EnvironmentSensorManager::supportsSharedPeripheralMode() const {
|
||||
#if defined(RAK_4631) && !defined(RAK_WISMESH_TAG)
|
||||
return true;
|
||||
@@ -1395,6 +1398,7 @@ bool EnvironmentSensorManager::isGpsPowered() const {
|
||||
#endif
|
||||
}
|
||||
|
||||
#if ENV_INCLUDE_GPS
|
||||
// gps code for rak might be moved to MicroNMEALoactionProvider
|
||||
// or make a new location provider ...
|
||||
#ifdef RAK_WISBLOCK_GPS
|
||||
|
||||
Reference in new issue
Block a user