Skip to content

Small updates to member functions, adding one new one. #720

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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions keywords.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ receive KEYWORD2
idle KEYWORD2
sleep KEYWORD2

getTxPower KEYWORD2
getSpreadingFactor KEYWORD2
getSignalBandwidth KEYWORD2
setTxPower KEYWORD2
setFrequency KEYWORD2
setSpreadingFactor KEYWORD2
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=LoRa
version=0.8.0
version=0.8.1
author=Sandeep Mistry <[email protected]>
maintainer=Sandeep Mistry <[email protected]>
sentence=An Arduino library for sending and receiving data using LoRa radios.
Expand Down
12 changes: 12 additions & 0 deletions src/LoRa.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,11 @@ void LoRaClass::sleep()
writeRegister(REG_OP_MODE, MODE_LONG_RANGE_MODE | MODE_SLEEP);
}

int LoRaClass::getTxPower()
{
return _level;
}

void LoRaClass::setTxPower(int level, int outputPin)
{
if (PA_OUTPUT_RFO_PIN == outputPin) {
Expand All @@ -460,6 +465,8 @@ void LoRaClass::setTxPower(int level, int outputPin)
level = 14;
}

_level = level;

writeRegister(REG_PA_CONFIG, 0x70 | level);
} else {
// PA BOOST
Expand All @@ -468,6 +475,8 @@ void LoRaClass::setTxPower(int level, int outputPin)
level = 20;
}

_level = level;

// subtract 3 from level, so 18 - 20 maps to 15 - 17
level -= 3;

Expand All @@ -478,6 +487,9 @@ void LoRaClass::setTxPower(int level, int outputPin)
if (level < 2) {
level = 2;
}

_level = level;

//Default value PA_HF/LF or +17dBm
writeRegister(REG_PA_DAC, 0x84);
setOCP(100);
Expand Down
8 changes: 5 additions & 3 deletions src/LoRa.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ class LoRaClass : public Stream {
void idle();
void sleep();

int getTxPower();
int getSpreadingFactor();
long getSignalBandwidth();

void setTxPower(int level, int outputPin = PA_OUTPUT_PA_BOOST_PIN);
void setFrequency(long frequency);
void setSpreadingFactor(int sf);
Expand Down Expand Up @@ -105,9 +109,6 @@ class LoRaClass : public Stream {
void handleDio0Rise();
bool isTransmitting();

int getSpreadingFactor();
long getSignalBandwidth();

void setLdoFlag();
void setLdoFlagForced(const boolean);

Expand All @@ -123,6 +124,7 @@ class LoRaClass : public Stream {
int _ss;
int _reset;
int _dio0;
int _level;
long _frequency;
int _packetIndex;
int _implicitHeaderMode;
Expand Down