Skip to content

Commit 70771ee

Browse files
authored
Merge pull request #574 from LeeLeahy2/mp-hop-timer-debug
MP: Add debugHopTimer setting to compute and display link uptime
2 parents fbfc47b + 3e62831 commit 70771ee

File tree

3 files changed

+88
-60
lines changed

3 files changed

+88
-60
lines changed

Firmware/LoRaSerial/Commands.ino

Lines changed: 72 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -720,19 +720,29 @@ bool commandAT(const char * commandString)
720720
return true;
721721

722722
case ('1'): //ATI31 - Display the VC details
723-
systemPrintTimestamp();
724-
systemPrint("VC ");
725-
systemPrint(cmdVc);
726-
systemPrint(": ");
727-
if (!vc->flags.valid)
728-
systemPrintln("Down, Not valid");
729-
else
723+
if ((settings.operatingMode == MODE_VIRTUAL_CIRCUIT) && (!vc->flags.valid))
730724
{
731-
systemPrintln(vcStateNames[vc->vcState]);
732725
systemPrintTimestamp();
733-
systemPrint(" ID: ");
734-
systemPrintUniqueID(vc->uniqueId);
735-
systemPrintln(vc->flags.valid ? " (Valid)" : " (Invalid)");
726+
systemPrint("VC ");
727+
systemPrint(cmdVc);
728+
systemPrint(": ");
729+
if (!vc->flags.valid)
730+
systemPrintln("Down, Not valid");
731+
}
732+
else
733+
{
734+
if (settings.operatingMode == MODE_VIRTUAL_CIRCUIT)
735+
{
736+
systemPrintTimestamp();
737+
systemPrint("VC ");
738+
systemPrint(cmdVc);
739+
systemPrint(": ");
740+
systemPrintln(vcStateNames[vc->vcState]);
741+
systemPrintTimestamp();
742+
systemPrint(" ID: ");
743+
systemPrintUniqueID(vc->uniqueId);
744+
systemPrintln(vc->flags.valid ? " (Valid)" : " (Invalid)");
745+
}
736746

737747
//Heartbeat metrics
738748
systemPrintTimestamp();
@@ -762,57 +772,60 @@ bool commandAT(const char * commandString)
762772
outputSerialData(true);
763773
petWDT();
764774

765-
//Transmitter metrics
766-
systemPrintTimestamp();
767-
systemPrintln(" Sent");
768-
systemPrintTimestamp();
769-
systemPrint(" Frames: ");
770-
systemPrintln(vc->framesSent);
771-
systemPrintTimestamp();
772-
systemPrint(" Messages: ");
773-
systemPrintln(vc->messagesSent);
774-
outputSerialData(true);
775-
petWDT();
775+
if ((settings.operatingMode == MODE_VIRTUAL_CIRCUIT) && (!vc->flags.valid))
776+
{
777+
//Transmitter metrics
778+
systemPrintTimestamp();
779+
systemPrintln(" Sent");
780+
systemPrintTimestamp();
781+
systemPrint(" Frames: ");
782+
systemPrintln(vc->framesSent);
783+
systemPrintTimestamp();
784+
systemPrint(" Messages: ");
785+
systemPrintln(vc->messagesSent);
786+
outputSerialData(true);
787+
petWDT();
776788

777-
//Receiver metrics
778-
systemPrintTimestamp();
779-
systemPrintln(" Received");
780-
systemPrintTimestamp();
781-
systemPrint(" Frames: ");
782-
systemPrintln(vc->framesReceived);
783-
systemPrintTimestamp();
784-
systemPrint(" Messages: ");
785-
systemPrintln(vc->messagesReceived);
786-
systemPrintTimestamp();
787-
systemPrint(" Bad Lengths: ");
788-
systemPrintln(vc->badLength);
789-
systemPrintTimestamp();
790-
systemPrint(" Link Failures: ");
791-
systemPrintln(linkFailures);
792-
outputSerialData(true);
793-
petWDT();
789+
//Receiver metrics
790+
systemPrintTimestamp();
791+
systemPrintln(" Received");
792+
systemPrintTimestamp();
793+
systemPrint(" Frames: ");
794+
systemPrintln(vc->framesReceived);
795+
systemPrintTimestamp();
796+
systemPrint(" Messages: ");
797+
systemPrintln(vc->messagesReceived);
798+
systemPrintTimestamp();
799+
systemPrint(" Bad Lengths: ");
800+
systemPrintln(vc->badLength);
801+
systemPrintTimestamp();
802+
systemPrint(" Link Failures: ");
803+
systemPrintln(linkFailures);
804+
outputSerialData(true);
805+
petWDT();
794806

795-
//ACK Management metrics
796-
systemPrintTimestamp();
797-
systemPrintln(" ACK Management");
798-
systemPrintTimestamp();
799-
systemPrint(" Last RX ACK number: ");
800-
systemPrintln(vc->rxAckNumber);
801-
systemPrintTimestamp();
802-
systemPrint(" Next RX ACK number: ");
803-
systemPrintln(vc->rmtTxAckNumber);
804-
systemPrintTimestamp();
805-
systemPrint(" Last TX ACK number: ");
806-
systemPrintln(vc->txAckNumber);
807-
if (txDestVc == cmdVc)
808-
{
807+
//ACK Management metrics
809808
systemPrintTimestamp();
810-
systemPrint(" ackTimer: ");
811-
if (ackTimer)
812-
systemPrintTimestamp(ackTimer + timestampOffset);
813-
else
814-
systemPrint("Not Running");
815-
systemPrintln();
809+
systemPrintln(" ACK Management");
810+
systemPrintTimestamp();
811+
systemPrint(" Last RX ACK number: ");
812+
systemPrintln(vc->rxAckNumber);
813+
systemPrintTimestamp();
814+
systemPrint(" Next RX ACK number: ");
815+
systemPrintln(vc->rmtTxAckNumber);
816+
systemPrintTimestamp();
817+
systemPrint(" Last TX ACK number: ");
818+
systemPrintln(vc->txAckNumber);
819+
if (txDestVc == cmdVc)
820+
{
821+
systemPrintTimestamp();
822+
systemPrint(" ackTimer: ");
823+
if (ackTimer)
824+
systemPrintTimestamp(ackTimer + timestampOffset);
825+
else
826+
systemPrint("Not Running");
827+
systemPrintln();
828+
}
816829
}
817830
}
818831
return true;

Firmware/LoRaSerial/States.ino

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1160,6 +1160,8 @@ void updateRadioState()
11601160
//Start and adjust freq hop ISR based on remote's remaining clock
11611161
startChannelTimer();
11621162
channelTimerStart -= settings.maxDwellTime;
1163+
if (!settings.server)
1164+
virtualCircuitList[VC_SERVER].firstHeartbeatMillis = millis();
11631165
syncChannelTimer(txSyncClocksUsec, 1);
11641166
triggerEvent(TRIGGER_RX_SYNC_CLOCKS);
11651167

@@ -1320,6 +1322,8 @@ void updateRadioState()
13201322

13211323
//Start and adjust freq hop ISR based on remote's remaining clock
13221324
channelTimerStart -= settings.maxDwellTime;
1325+
if (!settings.server)
1326+
virtualCircuitList[VC_SERVER].firstHeartbeatMillis = millis();
13231327
syncChannelTimer(txSyncClocksUsec, 1);
13241328

13251329
if (settings.debugSync)
@@ -1434,6 +1438,9 @@ void updateRadioState()
14341438
//Sync clock if server sent the heartbeat
14351439
if (settings.server == false)
14361440
{
1441+
if (!settings.server)
1442+
virtualCircuitList[VC_SERVER].lastTrafficMillis = millis();
1443+
14371444
//Adjust freq hop ISR based on server's remaining clock
14381445
syncChannelTimer(txHeartbeatUsec, 0);
14391446

@@ -1495,8 +1502,15 @@ void updateRadioState()
14951502
if ((millis() - lastPacketReceived) > ((uint32_t)settings.heartbeatTimeout * LINK_BREAK_MULTIPLIER))
14961503
{
14971504
if (settings.debugSync)
1498-
{
14991505
systemPrintln("HEARTBEAT Timeout");
1506+
if ((!settings.server) && settings.debugHopTimer)
1507+
{
1508+
systemPrint("Link Uptime: ");
1509+
systemPrintln(virtualCircuitList[VC_SERVER].lastTrafficMillis
1510+
- virtualCircuitList[VC_SERVER].firstHeartbeatMillis);
1511+
}
1512+
if (settings.debugSync || settings.debugHopTimer)
1513+
{
15001514
outputSerialData(true);
15011515
dumpClockSynchronization();
15021516
}

Firmware/LoRaSerial/settings.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,7 @@ typedef struct struct_settings {
487487
bool debug = false; //Print basic events: ie, radio state changes
488488
bool debugDatagrams = false; //Print the datagrams
489489
bool debugHeartbeat = false; //Print the HEARTBEAT timing values
490+
bool debugHopTimer = false; //Print the hop timer when the link fails
490491

491492
bool debugNvm = false; //Debug NVM operation
492493
bool debugRadio = false; //Print radio info

0 commit comments

Comments
 (0)