mirror of
https://github.com/meshtastic/firmware.git
synced 2025-04-24 17:32:18 +00:00
SX126x: Try next Interface when chip not found (#2363)
* If chip was not found, return false for init() * SX1268: Only overwrite frequency when out of bounds Happens when region is still UNSET
This commit is contained in:
parent
1f99d4756a
commit
8c68d888c8
@ -7,3 +7,12 @@ SX1268Interface::SX1268Interface(RADIOLIB_PIN_TYPE cs, RADIOLIB_PIN_TYPE irq, RA
|
|||||||
: SX126xInterface(cs, irq, rst, busy, spi)
|
: SX126xInterface(cs, irq, rst, busy, spi)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float SX1268Interface::getFreq()
|
||||||
|
{
|
||||||
|
// Set frequency to default of EU_433 if outside of allowed range (e.g. when region is UNSET)
|
||||||
|
if (savedFreq < 410 || savedFreq > 810)
|
||||||
|
return 433.125f;
|
||||||
|
else
|
||||||
|
return savedFreq;
|
||||||
|
}
|
@ -8,8 +8,7 @@
|
|||||||
class SX1268Interface : public SX126xInterface<SX1268>
|
class SX1268Interface : public SX126xInterface<SX1268>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/// override frequency of the SX1268 module regardless of the region (use EU433 value)
|
virtual float getFreq() override;
|
||||||
virtual float getFreq() override { return 433.175f; }
|
|
||||||
|
|
||||||
SX1268Interface(RADIOLIB_PIN_TYPE cs, RADIOLIB_PIN_TYPE irq, RADIOLIB_PIN_TYPE rst, RADIOLIB_PIN_TYPE busy, SPIClass &spi);
|
SX1268Interface(RADIOLIB_PIN_TYPE cs, RADIOLIB_PIN_TYPE irq, RADIOLIB_PIN_TYPE rst, RADIOLIB_PIN_TYPE busy, SPIClass &spi);
|
||||||
};
|
};
|
||||||
|
@ -47,6 +47,8 @@ template <typename T> bool SX126xInterface<T>::init()
|
|||||||
int res = lora.begin(getFreq(), bw, sf, cr, syncWord, power, preambleLength, tcxoVoltage, useRegulatorLDO);
|
int res = lora.begin(getFreq(), bw, sf, cr, syncWord, power, preambleLength, tcxoVoltage, useRegulatorLDO);
|
||||||
// \todo Display actual typename of the adapter, not just `SX126x`
|
// \todo Display actual typename of the adapter, not just `SX126x`
|
||||||
LOG_INFO("SX126x init result %d\n", res);
|
LOG_INFO("SX126x init result %d\n", res);
|
||||||
|
if (res == RADIOLIB_ERR_CHIP_NOT_FOUND)
|
||||||
|
return false;
|
||||||
|
|
||||||
LOG_INFO("Frequency set to %f\n", getFreq());
|
LOG_INFO("Frequency set to %f\n", getFreq());
|
||||||
LOG_INFO("Bandwidth set to %f\n", bw);
|
LOG_INFO("Bandwidth set to %f\n", bw);
|
||||||
|
Loading…
Reference in New Issue
Block a user