mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-06 15:59:52 +03:00
show mem in console for EMSESP_DEBUG
This commit is contained in:
@@ -194,12 +194,18 @@ void System::loop() {
|
||||
#if defined(ESP8266)
|
||||
#if defined(EMSESP_DEBUG)
|
||||
static uint32_t last_memcheck_ = 0;
|
||||
if (currentMillis - last_memcheck_ > 8000) {
|
||||
if (currentMillis - last_memcheck_ > 5000) { // 5 seconds
|
||||
last_memcheck_ = currentMillis;
|
||||
LOG_INFO(F("Free heap: %d%% (%lu), frag:%u%%"), free_mem(), (unsigned long)ESP.getFreeHeap(), ESP.getHeapFragmentation());
|
||||
show_mem("core");
|
||||
}
|
||||
#elif defined(ESP32)
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
void System::show_mem(const char * note) {
|
||||
#if defined(ESP8266)
|
||||
#if defined(EMSESP_DEBUG)
|
||||
LOG_INFO(F("(%s) Free heap: %d%% (%lu), frag:%u%%"), note, free_mem(), (unsigned long)ESP.getFreeHeap(), ESP.getHeapFragmentation());
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
@@ -320,6 +326,7 @@ void System::show_users(uuid::console::Shell & shell) {
|
||||
void System::show_system(uuid::console::Shell & shell) {
|
||||
shell.printfln(F("Uptime: %s"), uuid::log::format_timestamp_ms(uuid::get_uptime_ms(), 3).c_str());
|
||||
|
||||
#ifndef EMSESP_STANDALONE
|
||||
#if defined(ESP8266)
|
||||
shell.printfln(F("Chip ID: 0x%08x"), ESP.getChipId());
|
||||
shell.printfln(F("SDK version: %s"), ESP.getSdkVersion());
|
||||
@@ -329,10 +336,8 @@ void System::show_system(uuid::console::Shell & shell) {
|
||||
shell.printfln(F("Boot mode: %u"), ESP.getBootMode());
|
||||
shell.printfln(F("CPU frequency: %u MHz"), ESP.getCpuFreqMHz());
|
||||
shell.printfln(F("Flash chip: 0x%08X (%u bytes)"), ESP.getFlashChipId(), ESP.getFlashChipRealSize());
|
||||
shell.printfln(F("Sketch size: %u bytes (%u bytes free)"), ESP.getSketchSize(), ESP.getFreeSketchSpace());
|
||||
shell.printfln(F("Reset reason: %s"), ESP.getResetReason().c_str());
|
||||
shell.printfln(F("Reset info: %s"), ESP.getResetInfo().c_str());
|
||||
shell.println();
|
||||
shell.printfln(F("Free heap: %lu bytes"), (unsigned long)ESP.getFreeHeap());
|
||||
shell.printfln(F("Free mem: %d %%"), free_mem());
|
||||
shell.printfln(F("Maximum free block size: %lu bytes"), (unsigned long)ESP.getMaxFreeBlockSize());
|
||||
@@ -341,14 +346,12 @@ void System::show_system(uuid::console::Shell & shell) {
|
||||
#elif defined(ESP32)
|
||||
shell.printfln(F("SDK version: %s"), ESP.getSdkVersion());
|
||||
shell.printfln(F("CPU frequency: %u MHz"), ESP.getCpuFreqMHz());
|
||||
#endif
|
||||
shell.printfln(F("Sketch size: %u bytes (%u bytes free)"), ESP.getSketchSize(), ESP.getFreeSketchSpace());
|
||||
shell.printfln(F("Free heap: %lu bytes"), (unsigned long)ESP.getFreeHeap());
|
||||
shell.printfln(F("Free mem: %d %%"), free_mem());
|
||||
#endif
|
||||
|
||||
shell.println();
|
||||
|
||||
#ifndef EMSESP_STANDALONE
|
||||
switch (WiFi.status()) {
|
||||
case WL_IDLE_STATUS:
|
||||
shell.printfln(F("WiFi: Idle"));
|
||||
@@ -368,6 +371,7 @@ void System::show_system(uuid::console::Shell & shell) {
|
||||
shell.printfln(F("BSSID: %s"), WiFi.BSSIDstr().c_str());
|
||||
shell.printfln(F("RSSI: %d dBm (%d %%)"), WiFi.RSSI(), wifi_quality());
|
||||
shell.printfln(F("MAC address: %s"), WiFi.macAddress().c_str());
|
||||
|
||||
#if defined(ESP8266)
|
||||
shell.printfln(F("Hostname: %s"), WiFi.hostname().c_str());
|
||||
#elif defined(ESP32)
|
||||
|
||||
@@ -63,6 +63,8 @@ class System {
|
||||
void set_heartbeat(bool system_heartbeat);
|
||||
void send_heartbeat();
|
||||
|
||||
static void show_mem(const char * note);
|
||||
|
||||
void check_upgrade();
|
||||
|
||||
private:
|
||||
@@ -72,7 +74,7 @@ class System {
|
||||
static uuid::syslog::SyslogService syslog_;
|
||||
#endif
|
||||
|
||||
static constexpr uint32_t SYSTEM_CHECK_FREQUENCY = 10000; // check every 10 seconds
|
||||
static constexpr uint32_t SYSTEM_CHECK_FREQUENCY = 5000; // check every 5 seconds
|
||||
static constexpr uint32_t LED_WARNING_BLINK = 1000; // pulse to show no connection, 1 sec
|
||||
static constexpr uint32_t LED_WARNING_BLINK_FAST = 100; // flash quickly for boot up sequence
|
||||
static constexpr uint32_t SYSTEM_HEARTBEAT_INTERVAL = 60000; // in milliseconds, how often the MQTT heartbeat is sent (1 min)
|
||||
|
||||
Reference in New Issue
Block a user