Skip to content

Commit

Permalink
Merge pull request #3 from robojay/fixes_and_nano
Browse files Browse the repository at this point in the history
Adds Arduino Nano, Fixes Signal Detect/Transmit Power/Bandwidth
  • Loading branch information
kc1awv authored Jan 29, 2022
2 parents 9dfd39a + e9a70e6 commit e0df89c
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 22 deletions.
4 changes: 1 addition & 3 deletions include/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
int loraSpreadingFactor = 8;
int loraCodingRate = 7;
int loraTxPower = 20;
uint32_t loraBandwidth = 125E6;
uint32_t loraBandwidth = 125E3;
uint32_t loraFrequency = 43845E4;

uint8_t txBuffer[MTU];
Expand All @@ -71,8 +71,6 @@
bool outboundReady = false;

bool statSignalDetected = false;
bool statSignalSynced = false;
bool statRxOngoing = false;
bool dcd = false;
bool dcdLed = false;
bool dcdWaiting = false;
Expand Down
6 changes: 6 additions & 0 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,9 @@ platform = atmelavr
board = moteinomega
framework = arduino
monitor_speed = 38400

[env:nanoatmega328]
platform = atmelavr
board = nanoatmega328
framework = arduino
monitor_speed = 38400
18 changes: 4 additions & 14 deletions src/KISSLoRaTNC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,26 +99,15 @@ void serialCallback(uint8_t txByte) {
void updateModemStatus() {
uint8_t status = LoRa.modemStatus();
lastStatusUpdate = millis();
if (status & (SIG_DETECT == 0x01)) {
if ((status & SIG_DETECT) != 0) {
statSignalDetected = true;
//Serial.println("SIG_DETECT");
}
else {
statSignalDetected = false;
}
if (status & (SIG_SYNCED == 0x01)) {
statSignalSynced = true;
}
else {
statSignalSynced = false;
}
if (status & (RX_ONGOING == 0x01)) {
statRxOngoing = true;
}
else {
statRxOngoing = false;
}

if (statSignalDetected || statSignalSynced || statRxOngoing) {
if (statSignalDetected) {
if (dcdCount < dcdThreshold) {
dcdCount++;
dcd = true;
Expand Down Expand Up @@ -210,6 +199,7 @@ bool startRadio() {
Serial.println("SUCCESS");
LoRa.setSpreadingFactor(loraSpreadingFactor);
LoRa.setCodingRate4(loraCodingRate);
LoRa.setSignalBandwidth(loraBandwidth);
LoRa.enableCrc();
LoRa.onReceive(receiveCallback);
LoRa.receive();
Expand Down
11 changes: 6 additions & 5 deletions src/LoRa.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ int LoRaClass::begin(long frequency)
return 1;
}


void LoRaClass::setTxPower(int level, int outputPin)
{
if (PA_OUTPUT_RFO_PIN == outputPin) {
Expand All @@ -138,20 +137,22 @@ void LoRaClass::setTxPower(int level, int outputPin)
} else if (level > 14) {
level = 14;
}
writeRegister(REG_PA_CONFIG, PA_MAX_POWER | (level +1));
writeRegister(REG_PA_DAC, PA_DAC_DISABLE);
writeRegister(REG_PA_CONFIG, PA_MAX_POWER | level);
} else {
// PA BOOST
if (level < 2) {
level = 2;
} else if (level > 23) {
level = 23;
} else if (level > 20) {
level = 20;
}
if (level > 20) {
if (level > 17) {
writeRegister(REG_PA_DAC, PA_DAC_ENABLE);
level -= 3;
} else {
writeRegister(REG_PA_DAC, PA_DAC_DISABLE);
}
writeRegister(REG_PA_CONFIG, PA_SELECT | (level - 2));
}
}

Expand Down

0 comments on commit e0df89c

Please sign in to comment.