Skip to content

Commit 7f6694c

Browse files
authored
Merge pull request #499 from LeeLeahy2/command-reset
Use a common reset function
2 parents e811e12 + 735ddb5 commit 7f6694c

File tree

3 files changed

+20
-17
lines changed

3 files changed

+20
-17
lines changed

Firmware/LoRaSerial/Commands.ino

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -199,17 +199,7 @@ bool commandAT(const char * commandString)
199199
}
200200

201201
reportOK();
202-
if (serialOperatingMode == MODE_VIRTUAL_CIRCUIT)
203-
{
204-
//Notify the PC of the serial port failure
205-
serialOutputByte(START_OF_VC_SERIAL);
206-
serialOutputByte(3);
207-
serialOutputByte(PC_SERIAL_RECONNECT);
208-
serialOutputByte(myVc);
209-
}
210-
outputSerialData(true);
211-
systemFlush();
212-
systemReset();
202+
commandReset();
213203
return true;
214204
}
215205
}
@@ -852,6 +842,7 @@ void reportOK()
852842
commandComplete(true);
853843
}
854844

845+
//Notify the host that the command is complete
855846
void commandComplete(bool success)
856847
{
857848
if (settings.operatingMode == MODE_VIRTUAL_CIRCUIT)
@@ -867,6 +858,22 @@ void commandComplete(bool success)
867858
}
868859
}
869860

861+
//Notify the host of the reset then reboot the system
862+
void commandReset()
863+
{
864+
if (serialOperatingMode == MODE_VIRTUAL_CIRCUIT)
865+
{
866+
//Notify the PC of the serial port failure
867+
serialOutputByte(START_OF_VC_SERIAL);
868+
serialOutputByte(3);
869+
serialOutputByte(PC_SERIAL_RECONNECT);
870+
serialOutputByte(myVc);
871+
}
872+
outputSerialData(true);
873+
systemFlush();
874+
systemReset();
875+
}
876+
870877
//Remove any preceeding or following whitespace chars
871878
char * trimCommand()
872879
{

Firmware/LoRaSerial/States.ino

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1722,9 +1722,7 @@ void updateRadioState()
17221722
&& tempSettings.server == false)
17231723
{
17241724
//Reboot the radio with the newly generated random netID/Key parameters
1725-
petWDT();
1726-
systemFlush();
1727-
systemReset();
1725+
commandReset;
17281726
}
17291727
}
17301728
break;

Firmware/LoRaSerial/Train.ino

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,5 @@ void endClientServerTraining(uint8_t event)
205205
trainingServerRunning = false;
206206

207207
//Reboot the radio with the new parameters
208-
petWDT();
209-
systemFlush();
210-
systemReset();
208+
commandReset();
211209
}

0 commit comments

Comments
 (0)