mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-06 15:59:52 +03:00
minor changes
This commit is contained in:
@@ -26,7 +26,7 @@ MyESP::MyESP() {
|
|||||||
_wifi_password = NULL;
|
_wifi_password = NULL;
|
||||||
_wifi_ssid = NULL;
|
_wifi_ssid = NULL;
|
||||||
_mqtt_reconnect_delay = MQTT_RECONNECT_DELAY_MIN;
|
_mqtt_reconnect_delay = MQTT_RECONNECT_DELAY_MIN;
|
||||||
_verboseMessages = true;
|
_suspendMessages = true;
|
||||||
_command = (char *)malloc(TELNET_MAX_COMMAND_LENGTH); // reserve buffer for Serial/Telnet commands
|
_command = (char *)malloc(TELNET_MAX_COMMAND_LENGTH); // reserve buffer for Serial/Telnet commands
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -44,6 +44,9 @@ void MyESP::end() {
|
|||||||
|
|
||||||
// general debug to the telnet or serial channels
|
// general debug to the telnet or serial channels
|
||||||
void MyESP::myDebug(const char * format, ...) {
|
void MyESP::myDebug(const char * format, ...) {
|
||||||
|
if (!_suspendMessages)
|
||||||
|
return;
|
||||||
|
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start(args, format);
|
va_start(args, format);
|
||||||
char test[1];
|
char test[1];
|
||||||
@@ -70,6 +73,11 @@ void MyESP::myDebug_P(PGM_P format_P, ...) {
|
|||||||
ets_vsnprintf(buffer, len, format, args);
|
ets_vsnprintf(buffer, len, format, args);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
|
|
||||||
|
// capture & print timestamp
|
||||||
|
char timestamp[10] = {0};
|
||||||
|
snprintf_P(timestamp, sizeof(timestamp), PSTR("[%06lu] "), millis() % 1000000);
|
||||||
|
SerialAndTelnet.print(timestamp);
|
||||||
|
|
||||||
SerialAndTelnet.println(buffer);
|
SerialAndTelnet.println(buffer);
|
||||||
|
|
||||||
delete[] buffer;
|
delete[] buffer;
|
||||||
@@ -84,7 +92,6 @@ void MyESP::_wifiCallback(justwifi_messages_t code, char * parameter) {
|
|||||||
String hostname = WiFi.hostname();
|
String hostname = WiFi.hostname();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
myDebug_P(PSTR("[WIFI] ----------------------------------------------"));
|
|
||||||
myDebug_P(PSTR("[WIFI] SSID %s"), WiFi.SSID().c_str());
|
myDebug_P(PSTR("[WIFI] SSID %s"), WiFi.SSID().c_str());
|
||||||
myDebug_P(PSTR("[WIFI] CH %d"), WiFi.channel());
|
myDebug_P(PSTR("[WIFI] CH %d"), WiFi.channel());
|
||||||
myDebug_P(PSTR("[WIFI] RSSI %d"), WiFi.RSSI());
|
myDebug_P(PSTR("[WIFI] RSSI %d"), WiFi.RSSI());
|
||||||
@@ -94,14 +101,12 @@ void MyESP::_wifiCallback(justwifi_messages_t code, char * parameter) {
|
|||||||
myDebug_P(PSTR("[WIFI] MASK %s"), WiFi.subnetMask().toString().c_str());
|
myDebug_P(PSTR("[WIFI] MASK %s"), WiFi.subnetMask().toString().c_str());
|
||||||
myDebug_P(PSTR("[WIFI] DNS %s"), WiFi.dnsIP().toString().c_str());
|
myDebug_P(PSTR("[WIFI] DNS %s"), WiFi.dnsIP().toString().c_str());
|
||||||
myDebug_P(PSTR("[WIFI] HOST %s"), hostname.c_str());
|
myDebug_P(PSTR("[WIFI] HOST %s"), hostname.c_str());
|
||||||
myDebug_P(PSTR("[WIFI] ----------------------------------------------"));
|
|
||||||
|
|
||||||
if (WiFi.getMode() & WIFI_AP) {
|
if (WiFi.getMode() & WIFI_AP) {
|
||||||
myDebug_P(PSTR("[WIFI] MODE AP --------------------------------------"));
|
myDebug_P(PSTR("[WIFI] MODE AP --------------------------------------"));
|
||||||
myDebug_P(PSTR("[WIFI] SSID %s"), jw.getAPSSID().c_str());
|
myDebug_P(PSTR("[WIFI] SSID %s"), jw.getAPSSID().c_str());
|
||||||
myDebug_P(PSTR("[WIFI] IP %s"), WiFi.softAPIP().toString().c_str());
|
myDebug_P(PSTR("[WIFI] IP %s"), WiFi.softAPIP().toString().c_str());
|
||||||
myDebug_P(PSTR("[WIFI] MAC %s"), WiFi.softAPmacAddress().c_str());
|
myDebug_P(PSTR("[WIFI] MAC %s"), WiFi.softAPmacAddress().c_str());
|
||||||
myDebug_P(PSTR("[WIFI] ----------------------------------------------"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// start MDNS
|
// start MDNS
|
||||||
@@ -364,38 +369,41 @@ void MyESP::_telnet_setup() {
|
|||||||
|
|
||||||
// Show help of commands
|
// Show help of commands
|
||||||
void MyESP::_consoleShowHelp() {
|
void MyESP::_consoleShowHelp() {
|
||||||
String help = "\n\r**********************************************\n\r* Remote Telnet Command Center & Log Monitor "
|
#if defined(ARDUINO_ARCH_ESP32)
|
||||||
"*\n\r**********************************************\n\r";
|
String hostname = String(WiFi.getHostname());
|
||||||
help += "* Device hostname: " + WiFi.hostname() + "\tIP: " + WiFi.localIP().toString() + "\tMAC address: " + WiFi.macAddress() + "\n\r";
|
#else
|
||||||
help += "* Connected to WiFi AP: " + WiFi.SSID() + "\n\r";
|
String hostname = WiFi.hostname();
|
||||||
help += "* Boot time: ";
|
|
||||||
help.concat(_boottime);
|
|
||||||
help += "\n\r* ";
|
|
||||||
help.concat(_app_name);
|
|
||||||
help += " Version ";
|
|
||||||
help.concat(_app_version);
|
|
||||||
help += "\n\r* Free RAM: ";
|
|
||||||
help.concat(ESP.getFreeHeap());
|
|
||||||
help += " bytes\n\r";
|
|
||||||
#ifdef DEBUG_SUPPORT
|
|
||||||
help += "* !! in DEBUG_SUPPORT mode !!\n\r";
|
|
||||||
#endif
|
#endif
|
||||||
help += "*\n\r* Commands:\n\r* ?=this help, CTRL-D=quit, $=show free memory, !=reboot ESP, &=suspend all messages\n\r";
|
|
||||||
|
|
||||||
// print custom commands if available
|
|
||||||
|
SerialAndTelnet.println("*********************************");
|
||||||
|
SerialAndTelnet.println("* Console and Log Monitoring *");
|
||||||
|
SerialAndTelnet.println("*********************************");
|
||||||
|
SerialAndTelnet.printf("* %s %s\n\r", _app_name, _app_version);
|
||||||
|
SerialAndTelnet.printf("* Hostname: %s IP: %s MAC: %s\n\r",
|
||||||
|
hostname.c_str(),
|
||||||
|
WiFi.localIP().toString().c_str(),
|
||||||
|
WiFi.macAddress().c_str());
|
||||||
|
SerialAndTelnet.printf("* Connected to WiFi AP: %s\n\r", WiFi.SSID().c_str());
|
||||||
|
SerialAndTelnet.printf("* Boot time: %s\n\r", _boottime);
|
||||||
|
SerialAndTelnet.printf("* Free RAM: %d bytes\n\r", ESP.getFreeHeap());
|
||||||
|
#ifdef DEBUG_SUPPORT
|
||||||
|
SerialAndTelnet.println("* !! in DEBUG_SUPPORT mode !!\n\r");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
SerialAndTelnet.println("*\n\r* Commands:\n\r* ?=this help, CTRL-D=quit, $=show free memory, !=reboot ESP, &=suspend all messages");
|
||||||
|
|
||||||
|
// print custom commands if available. Take from progmem
|
||||||
if (_consoleCallbackProjectCmds) {
|
if (_consoleCallbackProjectCmds) {
|
||||||
for (uint8_t i = 0; i < _helpProjectCmds_count; i++) {
|
for (uint8_t i = 0; i < _helpProjectCmds_count; i++) {
|
||||||
help += FPSTR("* ");
|
SerialAndTelnet.print(FPSTR("* "));
|
||||||
help += FPSTR(_helpProjectCmds[i].key);
|
SerialAndTelnet.print(FPSTR(_helpProjectCmds[i].key));
|
||||||
for (int j = 0; j < (8 - strlen(_helpProjectCmds[i].key)); j++) { // padding
|
for (uint8_t j = 0; j < (8 - strlen(_helpProjectCmds[i].key)); j++) {
|
||||||
help += FPSTR(" ");
|
SerialAndTelnet.print(FPSTR(" ")); // padding
|
||||||
}
|
}
|
||||||
help += FPSTR(_helpProjectCmds[i].description);
|
SerialAndTelnet.println(FPSTR(_helpProjectCmds[i].description));
|
||||||
help += FPSTR("\n\r");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SerialAndTelnet.println(help.c_str());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// reset / restart
|
// reset / restart
|
||||||
@@ -427,8 +435,8 @@ void MyESP::consoleProcessCommand() {
|
|||||||
} else if (cmd == '!') {
|
} else if (cmd == '!') {
|
||||||
resetESP();
|
resetESP();
|
||||||
} else if (cmd == '&') {
|
} else if (cmd == '&') {
|
||||||
_verboseMessages = !_verboseMessages; // toggle
|
myDebug("Suspend all messages is %s", !_suspendMessages ? "disabled" : "enabled");
|
||||||
myDebug("Suspend all messages is %s", _verboseMessages ? "disabled" : "enabled");
|
_suspendMessages = !_suspendMessages; // toggle
|
||||||
} else {
|
} else {
|
||||||
// custom Project commands
|
// custom Project commands
|
||||||
if (_consoleCallbackProjectCmds) {
|
if (_consoleCallbackProjectCmds) {
|
||||||
@@ -436,7 +444,7 @@ void MyESP::consoleProcessCommand() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_verboseMessages) {
|
if (!_suspendMessages) {
|
||||||
myDebug("Warning, all log messages have been supsended. Use & to re-enable.");
|
myDebug("Warning, all log messages have been supsended. Use & to re-enable.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -154,9 +154,9 @@ class MyESP {
|
|||||||
uint8_t _helpProjectCmds_count; // # available commands
|
uint8_t _helpProjectCmds_count; // # available commands
|
||||||
void _consoleShowHelp();
|
void _consoleShowHelp();
|
||||||
void (*_consoleCallbackProjectCmds)(); // Callable for projects commands
|
void (*_consoleCallbackProjectCmds)(); // Callable for projects commands
|
||||||
void _consoleProcessCommand();
|
void _consoleProcessCommand();
|
||||||
bool _isCRLF(char character);
|
bool _isCRLF(char character);
|
||||||
bool _verboseMessages;
|
bool _suspendMessages;
|
||||||
|
|
||||||
// general
|
// general
|
||||||
char * _app_hostname;
|
char * _app_hostname;
|
||||||
|
|||||||
@@ -338,7 +338,7 @@ bool ems_getBusConnected();
|
|||||||
_EMS_SYS_LOGGING ems_getLogging();
|
_EMS_SYS_LOGGING ems_getLogging();
|
||||||
uint8_t ems_getEmsTypesCount();
|
uint8_t ems_getEmsTypesCount();
|
||||||
bool ems_getEmsRefreshed();
|
bool ems_getEmsRefreshed();
|
||||||
void ems_getVersions();
|
void ems_getAllVersions();
|
||||||
_EMS_MODEL_ID ems_getThermostatModel();
|
_EMS_MODEL_ID ems_getThermostatModel();
|
||||||
|
|
||||||
void ems_printAllTypes();
|
void ems_printAllTypes();
|
||||||
|
|||||||
Reference in New Issue
Block a user