Fix low data-rate optimisation on SX1262

This commit is contained in:
Mark Qvist 2024-02-13 13:14:13 +01:00
parent 32424b91a6
commit 184d228991

View File

@ -755,8 +755,8 @@ void sx126x::setSpreadingFactor(int sf)
_sf = sf; _sf = sf;
setModulationParams(sf, _bw, _cr, _ldro);
handleLowDataRate(); handleLowDataRate();
setModulationParams(sf, _bw, _cr, _ldro);
} }
long sx126x::getSignalBandwidth() long sx126x::getSignalBandwidth()
@ -778,9 +778,11 @@ long sx126x::getSignalBandwidth()
} }
void sx126x::handleLowDataRate(){ void sx126x::handleLowDataRate(){
// TODO: Why was this enabled without any logic to check LDRO conditions? if ( long( (1<<_sf) / (getSignalBandwidth()/1000)) > 16) {
//_ldro = 1; _ldro = 0x01;
//setModulationParams(_sf, _bw, _cr, _ldro); } else {
_ldro = 0x00;
}
} }
void sx126x::optimizeModemSensitivity(){ void sx126x::optimizeModemSensitivity(){
@ -789,31 +791,31 @@ void sx126x::optimizeModemSensitivity(){
void sx126x::setSignalBandwidth(long sbw) void sx126x::setSignalBandwidth(long sbw)
{ {
if (sbw <= 7.8E3) { if (sbw <= 7.8E3) {
_bw = 0x00; _bw = 0x00;
} else if (sbw <= 10.4E3) { } else if (sbw <= 10.4E3) {
_bw = 0x08; _bw = 0x08;
} else if (sbw <= 15.6E3) { } else if (sbw <= 15.6E3) {
_bw = 0x01; _bw = 0x01;
} else if (sbw <= 20.8E3) { } else if (sbw <= 20.8E3) {
_bw = 0x09; _bw = 0x09;
} else if (sbw <= 31.25E3) { } else if (sbw <= 31.25E3) {
_bw = 0x02; _bw = 0x02;
} else if (sbw <= 41.7E3) { } else if (sbw <= 41.7E3) {
_bw = 0x0A; _bw = 0x0A;
} else if (sbw <= 62.5E3) { } else if (sbw <= 62.5E3) {
_bw = 0x03; _bw = 0x03;
} else if (sbw <= 125E3) { } else if (sbw <= 125E3) {
_bw = 0x04; _bw = 0x04;
} else if (sbw <= 250E3) { } else if (sbw <= 250E3) {
_bw = 0x05; _bw = 0x05;
} else /*if (sbw <= 250E3)*/ { } else /*if (sbw <= 250E3)*/ {
_bw = 0x06; _bw = 0x06;
} }
setModulationParams(_sf, _bw, _cr, _ldro); handleLowDataRate();
setModulationParams(_sf, _bw, _cr, _ldro);
handleLowDataRate();
optimizeModemSensitivity(); optimizeModemSensitivity();
} }