Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions src/LoRa.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -547,11 +547,20 @@ void LoRaClass::setSignalBandwidth(long sbw)

void LoRaClass::setLdoFlag()
{
// Section 4.1.1.5
long symbolDuration = 1000 / ( getSignalBandwidth() / (1L << getSpreadingFactor()) ) ;

// Section 4.1.1.6
boolean ldoOn = symbolDuration > 16;
// Set Low data rate optimization flag when symbol longer than 16 mS
long bandwidth = getSignalBandwidth();
int datarate = getSpreadingFactor();
boolean ldoOn = false;

if( ( ( bandwidth == 125E3 ) && ( ( datarate == 11 ) || ( datarate == 12 ) ) ) ||
( ( bandwidth == 250E3 ) && ( datarate == 12 ) ) )
{
ldoOn = true;;
}
else
{
ldoOn = false;;
}

uint8_t config3 = readRegister(REG_MODEM_CONFIG_3);
bitWrite(config3, 3, ldoOn);
Expand Down