Skip to content

Commit 3248544

Browse files
author
jeroenst
committed
Implemented connection timeout command as requested in CR JoaoLopesF#63
1 parent 5899138 commit 3248544

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

src/RemoteDebug.cpp

+17-1
Original file line numberDiff line numberDiff line change
@@ -576,8 +576,9 @@ void RemoteDebug::handle() {
576576
if (_password != "" && !_passwordOk) { // Request password - 18/08/08
577577
maxTime = 60000; // One minute to password
578578
}
579+
else maxTime = connectionTimeout; // When password is ok set normal timeout
579580

580-
if ((millis() - _lastTimeCommand) > maxTime) {
581+
if ((maxTime > 0) && ((millis() - _lastTimeCommand) > maxTime)) {
581582

582583
debugPrintln("* Closing session by inactivity");
583584

@@ -1326,6 +1327,7 @@ void RemoteDebug::showHelp() {
13261327
help.concat(" s -> set debug silence on/off\r\n");
13271328
help.concat(" l -> show debug level\r\n");
13281329
help.concat(" t -> show time (millis)\r\n");
1330+
help.concat(" timeout -> set connection timeout (sec, 0 = disabled)\r\n");
13291331
help.concat(" profiler:\r\n");
13301332
help.concat(
13311333
" p -> show time between actual and last message (in millis)\r\n");
@@ -1617,6 +1619,20 @@ void RemoteDebug::processCommand() {
16171619

16181620
debugPrintf("* Show time: %s\r\n", (_showTime) ? "On" : "Off");
16191621

1622+
} else if (_command.startsWith("timeout")) {
1623+
1624+
// Set or get connection timeout
1625+
1626+
if (options.length() > 0) { // With minimal time
1627+
if ((options.toInt() >= 60) || (options.toInt() == 0)) {
1628+
connectionTimeout = options.toInt() * 1000;
1629+
}
1630+
else {
1631+
debugPrintf("* Connection Timeout must be minimal 60 seconds.\r\n");
1632+
}
1633+
}
1634+
debugPrintf("* Connection Timeout: %d seconds (0=disabled)\r\n", connectionTimeout/1000);
1635+
16201636
} else if (_command == "s") {
16211637

16221638
// Toogle silence (new) = 28/08/18

src/RemoteDebug.h

+2
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,8 @@ class RemoteDebug: public Print
353353
boolean _resetCommandEnabled=false; // Enable command to reset the board
354354

355355
boolean _newLine = true; // New line write ?
356+
357+
uint32_t connectionTimeout = MAX_TIME_INACTIVE; // Connection Timeout
356358

357359
String _command = ""; // Command received
358360
String _lastCommand = ""; // Last Command received

0 commit comments

Comments
 (0)