MCPcopy Create free account
hub / github.com/JoaoLopesF/RemoteDebug / processCommand

Method processCommand

src/RemoteDebug.cpp:1411–1765  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1409// Process user command over telnet or web socket
1410
1411void RemoteDebug::processCommand() {
1412
1413 static uint32_t lastTime = 0;
1414
1415 // Bug -> sometimes the command is process twice
1416 // Workaround -> check time
1417 // TODO: see correction for this
1418
1419 if (lastTime > 0 && (millis() - lastTime) < 500) {
1420 debugPrintln("* Bug workaround: ignoring command repeating");
1421 return;
1422 }
1423 lastTime = millis();
1424
1425 D("cmd: %s" , _command.c_str());
1426
1427 // Password request ? - 18/07/18
1428
1429 if (_password != "" && !_passwordOk) { // Process the password - 18/08/18 - adjust in 04/09/08 and 2018-10-19
1430
1431 if (_command == _password) {
1432
1433 debugPrintln("* Password ok, allowing access now...");
1434
1435 _passwordOk = true;
1436
1437#ifdef ALPHA_VERSION // In test, not good yet
1438 sendTelnetCommand(TELNET_WILL, TELNET_ECHO); // Send a command to telnet to restore echoes = 18/08/18
1439#endif
1440 showHelp();
1441
1442 } else {
1443
1444 debugPrintln("* Wrong password!");
1445
1446 #ifdef REMOTEDEBUG_PWD_ATTEMPTS
1447
1448 _passwordAttempt++;
1449
1450 if (_passwordAttempt > REMOTEDEBUG_PWD_ATTEMPTS) {
1451
1452 debugPrintln("* Many attempts. Closing session now.");
1453
1454 // Disconnect
1455
1456 disconnect();
1457
1458 } else {
1459
1460 showHelp();
1461 }
1462
1463 #endif
1464 }
1465
1466 return;
1467
1468 }

Callers

nothing calls this directly

Calls 1

stopMethod · 0.45

Tested by

no test coverage detected