Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set Low data rate optimization flag #466

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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