add more info to system/info and show system cmd

This commit is contained in:
proddy
2024-09-07 10:22:27 +02:00
parent 1b650dd118
commit 03127e5ff8
3 changed files with 35 additions and 25 deletions

View File

@@ -79,13 +79,7 @@ static void setup_commands(std::shared_ptr<Commands> & commands) {
commands->add_command(ShellContext::MAIN, commands->add_command(ShellContext::MAIN,
CommandFlags::USER, CommandFlags::USER,
string_vector{F_(show), F_(system)}, string_vector{F_(show), F_(system)},
[=](Shell & shell, const std::vector<std::string> & arguments) { [=](Shell & shell, const std::vector<std::string> & arguments) { to_app(shell).system_.show_system(shell); });
shell.println();
shell.printfln("%s%sEMS-ESP version %s%s", COLOR_BRIGHT_GREEN, COLOR_BOLD_ON, EMSESP_APP_VERSION, COLOR_RESET);
shell.println();
to_app(shell).system_.show_system(shell);
shell.println();
});
commands->add_command(ShellContext::MAIN, commands->add_command(ShellContext::MAIN,
CommandFlags::ADMIN, CommandFlags::ADMIN,

View File

@@ -300,7 +300,7 @@ void System::system_restart(const char * partitionname) {
if (partition && strcmp(partition->label, partitionname) == 0) { if (partition && strcmp(partition->label, partitionname) == 0) {
esp_ota_set_boot_partition(partition); esp_ota_set_boot_partition(partition);
} else } else
// try and find the parition by name // try and find the partition by name
if (strcmp(esp_ota_get_running_partition()->label, partitionname) != 0) { if (strcmp(esp_ota_get_running_partition()->label, partitionname) != 0) {
partition = esp_ota_get_next_update_partition(nullptr); partition = esp_ota_get_next_update_partition(nullptr);
if (!partition) { if (!partition) {
@@ -525,8 +525,8 @@ void System::button_OnDblClick(PButton & b) {
// button long press // button long press
void System::button_OnLongPress(PButton & b) { void System::button_OnLongPress(PButton & b) {
LOG_NOTICE("Button pressed - long press - restart other partition"); LOG_NOTICE("Button pressed - long press - restart from factory/boot partition");
EMSESP::system_.system_restart("boot"); EMSESP::system_.system_restart("boot"); // this is default when first installed. it may contain the bootloader code.
} }
// button indefinite press - do nothing for now // button indefinite press - do nothing for now
@@ -987,15 +987,17 @@ void System::show_users(uuid::console::Shell & shell) {
shell.println(); shell.println();
} }
// shell command 'show system'
void System::show_system(uuid::console::Shell & shell) { void System::show_system(uuid::console::Shell & shell) {
refreshHeapMem(); // refresh free heap and max alloc heap refreshHeapMem(); // refresh free heap and max alloc heap
shell.println();
shell.println("System:"); shell.println("System:");
shell.printfln(" Version: %s", EMSESP_APP_VERSION); shell.printfln(" Version: %s", EMSESP_APP_VERSION);
shell.printfln(" Platform: %s", EMSESP_PLATFORM); shell.printfln(" Platform: %s (%s)", EMSESP_PLATFORM, ESP.getChipModel());
shell.printfln(" NVS device information: %s", getBBQKeesGatewayDetails().c_str()); shell.printfln(" Model: %s", getBBQKeesGatewayDetails().c_str());
#ifndef EMSESP_STANDALONE #ifndef EMSESP_STANDALONE
shell.printfln(" Boot partition: %s", esp_ota_get_boot_partition()->label); shell.printfln(" Partition Boot/Running: %s/%s", esp_ota_get_boot_partition()->label, esp_ota_get_running_partition()->label);
#endif #endif
shell.printfln(" Language: %s", locale().c_str()); shell.printfln(" Language: %s", locale().c_str());
shell.printfln(" Board profile: %s", board_profile().c_str()); shell.printfln(" Board profile: %s", board_profile().c_str());
@@ -1013,8 +1015,11 @@ void System::show_system(uuid::console::Shell & shell) {
shell.printfln(" App used/free: %lu KB / %lu KB", appUsed(), appFree()); shell.printfln(" App used/free: %lu KB / %lu KB", appUsed(), appFree());
uint32_t FSused = LittleFS.usedBytes() / 1024; uint32_t FSused = LittleFS.usedBytes() / 1024;
shell.printfln(" FS used/free: %lu KB / %lu KB", FSused, FStotal() - FSused); shell.printfln(" FS used/free: %lu KB / %lu KB", FSused, FStotal() - FSused);
shell.println(); if (PSram()) {
shell.printfln(" PSRAM size/free: %lu KB / %lu KB", PSram(), ESP.getFreePsram() / 1024);
}
shell.println();
shell.println("Network:"); shell.println("Network:");
// show ethernet mac address if we have an eth controller present // show ethernet mac address if we have an eth controller present
@@ -1116,6 +1121,8 @@ void System::show_system(uuid::console::Shell & shell) {
shell.printfln(" Queued: %d", syslog_.queued()); shell.printfln(" Queued: %d", syslog_.queued());
} }
shell.println();
#endif #endif
} }
@@ -1418,6 +1425,7 @@ bool System::command_info(const char * value, const int8_t id, JsonObject output
node["uptimeSec"] = uuid::get_uptime_sec(); node["uptimeSec"] = uuid::get_uptime_sec();
#ifndef EMSESP_STANDALONE #ifndef EMSESP_STANDALONE
node["platform"] = EMSESP_PLATFORM; node["platform"] = EMSESP_PLATFORM;
node["cpuType"] = ESP.getChipModel();
node["arduino"] = ARDUINO_VERSION; node["arduino"] = ARDUINO_VERSION;
node["sdk"] = ESP.getSdkVersion(); node["sdk"] = ESP.getSdkVersion();
node["freeMem"] = getHeapMem(); node["freeMem"] = getHeapMem();
@@ -1425,9 +1433,16 @@ bool System::command_info(const char * value, const int8_t id, JsonObject output
node["freeCaps"] = heap_caps_get_free_size(MALLOC_CAP_8BIT) / 1024; // includes heap and psram node["freeCaps"] = heap_caps_get_free_size(MALLOC_CAP_8BIT) / 1024; // includes heap and psram
node["usedApp"] = EMSESP::system_.appUsed(); // kilobytes node["usedApp"] = EMSESP::system_.appUsed(); // kilobytes
node["freeApp"] = EMSESP::system_.appFree(); // kilobytes node["freeApp"] = EMSESP::system_.appFree(); // kilobytes
node["partition"] = esp_ota_get_running_partition()->label; node["partitionBootRunning"] = std::string(esp_ota_get_boot_partition()->label) + "/"
+ esp_ota_get_running_partition()->label; // will sycle app0/app0 - app1/app1 after OTA. boot/factory is on first install.
#endif #endif
node["resetReason"] = EMSESP::system_.reset_reason(0) + " / " + EMSESP::system_.reset_reason(1); node["resetReason"] = EMSESP::system_.reset_reason(0) + " / " + EMSESP::system_.reset_reason(1);
node["psram"] = (EMSESP::system_.PSram() > 0); // boolean
if (EMSESP::system_.PSram()) {
node["psramSize"] = EMSESP::system_.PSram();
node["freePsram"] = ESP.getFreePsram() / 1024;
}
node["model"] = EMSESP::system_.getBBQKeesGatewayDetails();
// Network Status // Network Status
node = output["network"].to<JsonObject>(); node = output["network"].to<JsonObject>();
@@ -1639,6 +1654,7 @@ bool System::command_info(const char * value, const int8_t id, JsonObject output
node["webLogBuffer"] = EMSESP::webLogService.num_log_messages(); node["webLogBuffer"] = EMSESP::webLogService.num_log_messages();
#endif #endif
node["modbusEnabled"] = settings.modbus_enabled; node["modbusEnabled"] = settings.modbus_enabled;
node["forceHeatingOff"] = settings.boiler_heatingoff;
}); });
// Devices - show EMS devices if we have any // Devices - show EMS devices if we have any

View File

@@ -109,7 +109,7 @@ void WebStatusService::hardwareStatus(AsyncWebServerRequest * request) {
root["free_heap"] = EMSESP::system_.getHeapMem(); root["free_heap"] = EMSESP::system_.getHeapMem();
root["arduino_version"] = ARDUINO_VERSION; root["arduino_version"] = ARDUINO_VERSION;
root["sdk_version"] = ESP.getSdkVersion(); root["sdk_version"] = ESP.getSdkVersion();
root["partition"] = esp_ota_get_running_partition()->label; root["partition"] = esp_ota_get_running_partition()->label; // active partition
root["flash_chip_size"] = ESP.getFlashChipSize() / 1024; root["flash_chip_size"] = ESP.getFlashChipSize() / 1024;
root["flash_chip_speed"] = ESP.getFlashChipSpeed(); root["flash_chip_speed"] = ESP.getFlashChipSpeed();
root["app_used"] = EMSESP::system_.appUsed(); root["app_used"] = EMSESP::system_.appUsed();