|
@ -83,17 +83,17 @@ void _terminalInitCommand() { |
|
|
terminalRegisterCommand(F("CRASH"), [](Embedis* e) { |
|
|
terminalRegisterCommand(F("CRASH"), [](Embedis* e) { |
|
|
crashDump(); |
|
|
crashDump(); |
|
|
crashClear(); |
|
|
crashClear(); |
|
|
DEBUG_MSG_P(PSTR("+OK\n")); |
|
|
|
|
|
|
|
|
terminalOK(); |
|
|
}); |
|
|
}); |
|
|
#endif
|
|
|
#endif
|
|
|
|
|
|
|
|
|
terminalRegisterCommand(F("COMMANDS"), [](Embedis* e) { |
|
|
terminalRegisterCommand(F("COMMANDS"), [](Embedis* e) { |
|
|
_terminalHelpCommand(); |
|
|
_terminalHelpCommand(); |
|
|
DEBUG_MSG_P(PSTR("+OK\n")); |
|
|
|
|
|
|
|
|
terminalOK(); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
terminalRegisterCommand(F("ERASE.CONFIG"), [](Embedis* e) { |
|
|
terminalRegisterCommand(F("ERASE.CONFIG"), [](Embedis* e) { |
|
|
DEBUG_MSG_P(PSTR("+OK\n")); |
|
|
|
|
|
|
|
|
terminalOK(); |
|
|
resetReason(CUSTOM_RESET_TERMINAL); |
|
|
resetReason(CUSTOM_RESET_TERMINAL); |
|
|
_eepromCommit(); |
|
|
_eepromCommit(); |
|
|
ESP.eraseConfig(); |
|
|
ESP.eraseConfig(); |
|
@ -102,17 +102,17 @@ void _terminalInitCommand() { |
|
|
|
|
|
|
|
|
terminalRegisterCommand(F("FACTORY.RESET"), [](Embedis* e) { |
|
|
terminalRegisterCommand(F("FACTORY.RESET"), [](Embedis* e) { |
|
|
resetSettings(); |
|
|
resetSettings(); |
|
|
DEBUG_MSG_P(PSTR("+OK\n")); |
|
|
|
|
|
|
|
|
terminalOK(); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
terminalRegisterCommand(F("GPIO"), [](Embedis* e) { |
|
|
terminalRegisterCommand(F("GPIO"), [](Embedis* e) { |
|
|
if (e->argc < 2) { |
|
|
if (e->argc < 2) { |
|
|
DEBUG_MSG_P(PSTR("-ERROR: Wrong arguments\n")); |
|
|
|
|
|
|
|
|
terminalError(F("Wrong arguments")); |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
int pin = String(e->argv[1]).toInt(); |
|
|
int pin = String(e->argv[1]).toInt(); |
|
|
//if (!gpioValid(pin)) {
|
|
|
//if (!gpioValid(pin)) {
|
|
|
// DEBUG_MSG_P(PSTR("-ERROR: Invalid GPIO\n"));
|
|
|
|
|
|
|
|
|
// terminalError(F("Invalid GPIO"));
|
|
|
// return;
|
|
|
// return;
|
|
|
//}
|
|
|
//}
|
|
|
if (e->argc > 2) { |
|
|
if (e->argc > 2) { |
|
@ -120,37 +120,37 @@ void _terminalInitCommand() { |
|
|
digitalWrite(pin, state); |
|
|
digitalWrite(pin, state); |
|
|
} |
|
|
} |
|
|
DEBUG_MSG_P(PSTR("GPIO %d is %s\n"), pin, digitalRead(pin) == HIGH ? "HIGH" : "LOW"); |
|
|
DEBUG_MSG_P(PSTR("GPIO %d is %s\n"), pin, digitalRead(pin) == HIGH ? "HIGH" : "LOW"); |
|
|
DEBUG_MSG_P(PSTR("+OK\n")); |
|
|
|
|
|
|
|
|
terminalOK(); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
terminalRegisterCommand(F("HEAP"), [](Embedis* e) { |
|
|
terminalRegisterCommand(F("HEAP"), [](Embedis* e) { |
|
|
infoMemory("Heap", getInitialFreeHeap(), getFreeHeap()); |
|
|
infoMemory("Heap", getInitialFreeHeap(), getFreeHeap()); |
|
|
DEBUG_MSG_P(PSTR("+OK\n")); |
|
|
|
|
|
|
|
|
terminalOK(); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
terminalRegisterCommand(F("STACK"), [](Embedis* e) { |
|
|
terminalRegisterCommand(F("STACK"), [](Embedis* e) { |
|
|
infoMemory("Stack", 4096, getFreeStack()); |
|
|
infoMemory("Stack", 4096, getFreeStack()); |
|
|
DEBUG_MSG_P(PSTR("+OK\n")); |
|
|
|
|
|
|
|
|
terminalOK(); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
terminalRegisterCommand(F("HELP"), [](Embedis* e) { |
|
|
terminalRegisterCommand(F("HELP"), [](Embedis* e) { |
|
|
_terminalHelpCommand(); |
|
|
_terminalHelpCommand(); |
|
|
DEBUG_MSG_P(PSTR("+OK\n")); |
|
|
|
|
|
|
|
|
terminalOK(); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
terminalRegisterCommand(F("INFO"), [](Embedis* e) { |
|
|
terminalRegisterCommand(F("INFO"), [](Embedis* e) { |
|
|
info(); |
|
|
info(); |
|
|
DEBUG_MSG_P(PSTR("+OK\n")); |
|
|
|
|
|
|
|
|
terminalOK(); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
terminalRegisterCommand(F("KEYS"), [](Embedis* e) { |
|
|
terminalRegisterCommand(F("KEYS"), [](Embedis* e) { |
|
|
_terminalKeysCommand(); |
|
|
_terminalKeysCommand(); |
|
|
DEBUG_MSG_P(PSTR("+OK\n")); |
|
|
|
|
|
|
|
|
terminalOK(); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
terminalRegisterCommand(F("GET"), [](Embedis* e) { |
|
|
terminalRegisterCommand(F("GET"), [](Embedis* e) { |
|
|
if (e->argc < 2) { |
|
|
if (e->argc < 2) { |
|
|
DEBUG_MSG_P(PSTR("-ERROR: Wrong arguments\n")); |
|
|
|
|
|
|
|
|
terminalError(F("Wrong arguments")); |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -165,28 +165,28 @@ void _terminalInitCommand() { |
|
|
DEBUG_MSG_P(PSTR("> %s => \"%s\"\n"), key.c_str(), value.c_str()); |
|
|
DEBUG_MSG_P(PSTR("> %s => \"%s\"\n"), key.c_str(), value.c_str()); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
DEBUG_MSG_P(PSTR("+OK\n")); |
|
|
|
|
|
|
|
|
terminalOK(); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
terminalRegisterCommand(F("RELOAD"), [](Embedis* e) { |
|
|
terminalRegisterCommand(F("RELOAD"), [](Embedis* e) { |
|
|
espurnaReload(); |
|
|
espurnaReload(); |
|
|
DEBUG_MSG_P(PSTR("+OK\n")); |
|
|
|
|
|
|
|
|
terminalOK(); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
terminalRegisterCommand(F("RESET"), [](Embedis* e) { |
|
|
terminalRegisterCommand(F("RESET"), [](Embedis* e) { |
|
|
DEBUG_MSG_P(PSTR("+OK\n")); |
|
|
|
|
|
|
|
|
terminalOK(); |
|
|
deferredReset(100, CUSTOM_RESET_TERMINAL); |
|
|
deferredReset(100, CUSTOM_RESET_TERMINAL); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
terminalRegisterCommand(F("RESET.SAFE"), [](Embedis* e) { |
|
|
terminalRegisterCommand(F("RESET.SAFE"), [](Embedis* e) { |
|
|
EEPROMr.write(EEPROM_CRASH_COUNTER, SYSTEM_CHECK_MAX); |
|
|
EEPROMr.write(EEPROM_CRASH_COUNTER, SYSTEM_CHECK_MAX); |
|
|
DEBUG_MSG_P(PSTR("+OK\n")); |
|
|
|
|
|
|
|
|
terminalOK(); |
|
|
deferredReset(100, CUSTOM_RESET_TERMINAL); |
|
|
deferredReset(100, CUSTOM_RESET_TERMINAL); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
terminalRegisterCommand(F("UPTIME"), [](Embedis* e) { |
|
|
terminalRegisterCommand(F("UPTIME"), [](Embedis* e) { |
|
|
DEBUG_MSG_P(PSTR("Uptime: %d seconds\n"), getUptime()); |
|
|
DEBUG_MSG_P(PSTR("Uptime: %d seconds\n"), getUptime()); |
|
|
DEBUG_MSG_P(PSTR("+OK\n")); |
|
|
|
|
|
|
|
|
terminalOK(); |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
terminalRegisterCommand(F("CONFIG"), [](Embedis* e) { |
|
|
terminalRegisterCommand(F("CONFIG"), [](Embedis* e) { |
|
@ -196,7 +196,7 @@ void _terminalInitCommand() { |
|
|
String output; |
|
|
String output; |
|
|
root.printTo(output); |
|
|
root.printTo(output); |
|
|
DEBUG_MSG(output.c_str()); |
|
|
DEBUG_MSG(output.c_str()); |
|
|
DEBUG_MSG_P(PSTR("\n+OK\n")); |
|
|
|
|
|
|
|
|
|
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
#if not SETTINGS_AUTOSAVE
|
|
|
#if not SETTINGS_AUTOSAVE
|
|
@ -249,6 +249,14 @@ void terminalRegisterCommand(const String& name, void (*call)(Embedis*)) { |
|
|
Embedis::command(name, call); |
|
|
Embedis::command(name, call); |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
void terminalOK() { |
|
|
|
|
|
DEBUG_MSG_P(PSTR("+OK\n")); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void terminalError(const String& error) { |
|
|
|
|
|
DEBUG_MSG_P(PSTR("-ERROR: %s\n"), error.c_str()); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
void terminalSetup() { |
|
|
void terminalSetup() { |
|
|
|
|
|
|
|
|
_serial.callback([](uint8_t ch) { |
|
|
_serial.callback([](uint8_t ch) { |
|
|