Merge branch 'master' into dev

This commit is contained in:
liquidraver committed 2026-07-03 19:58:07 +02:00
commit 6ef03fb10e
29 files changed
+1886 -65

No files matched your search

+65
View File
@@ -248,6 +248,71 @@ void LoRaRadioBase::buildModemConfig(struct lora_modem_config &cfg, bool tx)
cfg.cad.mode = LORA_CAD_MODE_LBT;
}
uint32_t LoRaRadioBase::getActiveFrequencyHz() const
{
float freq_mhz = _has_radio_override ? _override_freq
: (_prefs ? _prefs->freq : (LoRaConfig::FREQ_HZ / 1000000.0f));
return (uint32_t)(freq_mhz * 1000000.0f + 0.5f);
}
uint16_t LoRaRadioBase::getActiveBandwidthKHzX10() const
{
float bw_khz = _has_radio_override ? _override_bw
: (_prefs ? _prefs->bw : (float)LoRaConfig::BANDWIDTH);
return (uint16_t)(bw_khz * 10.0f + 0.5f);
}
uint8_t LoRaRadioBase::getActiveSpreadingFactor() const
{
return _has_radio_override ? _override_sf
: (_prefs ? _prefs->sf : LoRaConfig::SPREADING_FACTOR);
}
uint8_t LoRaRadioBase::getActiveCodingRate() const
{
return _has_radio_override ? _override_cr
: (_prefs ? _prefs->cr : LoRaConfig::CODING_RATE);
}
uint16_t LoRaRadioBase::getActivePreambleLength() const
{
return preambleLengthForSF(getActiveSpreadingFactor());
}
uint8_t LoRaRadioBase::getActiveSyncWord() const
{
/* buildModemConfig() currently sets public_network=false, which maps
* Zephyr's LoRa API to the Semtech private sync word. */
return 0x12;
}
int8_t LoRaRadioBase::getConfiguredTxPower() const
{
int power = _prefs ? _prefs->tx_power_dbm : LoRaConfig::TX_POWER_DBM;
#ifdef CONFIG_ZEPHCORE_MAX_TX_POWER_DBM
if (power > CONFIG_ZEPHCORE_MAX_TX_POWER_DBM) {
power = CONFIG_ZEPHCORE_MAX_TX_POWER_DBM;
}
#endif
if (power < -9) {
power = -9;
}
return (int8_t)power;
}
int8_t LoRaRadioBase::getEffectiveTxPower() const
{
int power = (int)getConfiguredTxPower() - (int)_tx_power_reduction_db;
if (power < -9) {
power = -9;
}
return (int8_t)power;
}
/**
* Compare radio-relevant fields of two modem configs.
* Ignores the tx flag — that only selects TX vs RX mode, the actual
+13
View File
@@ -82,6 +82,19 @@ public:
virtual bool setRxBoost(bool enable);
bool isRxBoostEnabled() const { return _rx_boost_enabled; }
/* Read-only view of the modem config currently used by buildModemConfig().
* These honor temporary radio overrides for freq/bw/sf/cr and the same TX
* clamps/APC reduction as the actual lora_config() path. */
uint32_t getActiveFrequencyHz() const;
uint16_t getActiveBandwidthKHzX10() const;
uint8_t getActiveSpreadingFactor() const;
uint8_t getActiveCodingRate() const;
uint16_t getActivePreambleLength() const;
uint8_t getActiveSyncWord() const;
int8_t getConfiguredTxPower() const;
int8_t getEffectiveTxPower() const;
bool isTxActive() const { return atomic_get(&_tx_active) != 0; }
/* Duty-cycle preamble false-positive counter.
* Incremented by the driver whenever RX_TX_TIMEOUT fires in
* duty-cycle mode and the chip is silently re-armed. High