Skip to content

Commit bfe9289

Browse files
committed
Display RSSI during broadcast RX.
1 parent b426ef5 commit bfe9289

File tree

1 file changed

+17
-10
lines changed

1 file changed

+17
-10
lines changed

Firmware/LoRaSerial_Firmware/States.ino

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -443,21 +443,27 @@ void updateRadioState()
443443
}
444444
} //End processWaitingSerial
445445

446-
//Blink Link LED if we've had successful data received or transmitted
447-
if (millis() - lastPacketReceived < 5000 || millis() - packetTimestamp < 5000)
446+
//Toggle 2 LEDs if we have recently transmitted
447+
if (millis() - packetTimestamp < 5000)
448448
{
449-
if (millis() - lastLinkBlink > 500) //Blink at 2Hz
449+
if (millis() - lastLinkBlink > 250) //Blink at 4Hz
450450
{
451451
lastLinkBlink = millis();
452-
//Toggle all RSSI LEDs
453-
if (digitalRead(pin_rssi1LED) == HIGH)
454-
setRSSI(0);
452+
if (digitalRead(pin_rssi2LED) == HIGH)
453+
setRSSI(0b0001);
455454
else
456-
setRSSI(0b1111); //All on
455+
setRSSI(0b0010);
457456
}
458457
}
458+
else if (millis() - lastPacketReceived < 5000)
459+
{
460+
updateRSSI(); //Adjust LEDs to RSSI level
461+
}
462+
463+
//Turn off RSSI after 5 seconds of no activity
459464
else
460-
setRSSI(0); //No link
465+
setRSSI(0);
466+
461467
}
462468
break;
463469

@@ -468,7 +474,7 @@ void updateRadioState()
468474
transactionComplete = false; //Reset ISR flag
469475
returnToReceiving();
470476
changeState(RADIO_BROADCASTING_RECEIVING_STANDBY); //No ack response when in broadcasting mode
471-
setRSSI(0); //Turn off RSSI LEDs
477+
setRSSI(0b0001);
472478
}
473479

474480
else if (timeToHop == true) //If the dio1ISR has fired, move to next frequency
@@ -515,6 +521,7 @@ void updateRadioState()
515521
txHead %= sizeof(serialTransmitBuffer);
516522
}
517523

524+
updateRSSI(); //Adjust LEDs to RSSI level
518525
frequencyCorrection += radio.getFrequencyError() / 1000000.0;
519526
returnToReceiving(); //No response when in broadcasting mode
520527
changeState(RADIO_BROADCASTING_RECEIVING_STANDBY);
@@ -580,7 +587,7 @@ void updateRadioState()
580587
if (trainCylonNumber == 0b1000 || trainCylonNumber == 0b0001)
581588
trainCylonDirection *= -1; //Change direction
582589

583-
if(trainCylonDirection > 0)
590+
if (trainCylonDirection > 0)
584591
trainCylonNumber <<= 1;
585592
else
586593
trainCylonNumber >>= 1;

0 commit comments

Comments
 (0)