Merge pull request #5 from tomelec/patch-1

LoRa: Enable LowDataRateOptimize for symbol length >16ms
This commit is contained in:
Mark Qvist 2019-10-23 08:02:53 +02:00 committed by GitHub
commit 3e866178f1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 0 deletions

View File

@ -418,6 +418,8 @@ void LoRaClass::setSpreadingFactor(int sf)
}
writeRegister(REG_MODEM_CONFIG_2, (readRegister(REG_MODEM_CONFIG_2) & 0x0f) | ((sf << 4) & 0xf0));
handleLowDataRate();
}
long LoRaClass::getSignalBandwidth()
@ -437,6 +439,18 @@ long LoRaClass::getSignalBandwidth()
}
}
void LoRaClass::handleLowDataRate(){
int sf = (readRegister(REG_MODEM_CONFIG_2) >> 4);
if ( long( (1<<sf) / (getSignalBandwidth()/1000)) > 16) {
// set auto AGC and LowDataRateOptimize
writeRegister(REG_MODEM_CONFIG_3, (1<<3)|(1<<2));
}
else {
// set auto AGC
writeRegister(REG_MODEM_CONFIG_3, (1<<2));
}
}
void LoRaClass::setSignalBandwidth(long sbw)
{
int bw;
@ -464,6 +478,8 @@ void LoRaClass::setSignalBandwidth(long sbw)
}
writeRegister(REG_MODEM_CONFIG_1, (readRegister(REG_MODEM_CONFIG_1) & 0x0f) | (bw << 4));
handleLowDataRate();
}
void LoRaClass::setCodingRate4(int denominator)

2
LoRa.h
View File

@ -82,6 +82,8 @@ private:
static void onDio0Rise();
void handleLowDataRate();
private:
SPISettings _spiSettings;
int _ss;