From b4a8d3c181aa38470b5f784b9b36cd82f4e853a3 Mon Sep 17 00:00:00 2001 From: proddy Date: Wed, 12 Jun 2024 10:23:26 +0200 Subject: [PATCH] pull MAC from efuse --- src/system.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/system.cpp b/src/system.cpp index a80521db3..dbebf49c1 100644 --- a/src/system.cpp +++ b/src/system.cpp @@ -45,6 +45,7 @@ #else // ESP32 Before IDF 4.0 #include "../rom/rtc.h" #endif +#include #endif namespace emsesp { @@ -291,7 +292,7 @@ void System::system_restart(const char * partitionname) { } esp_ota_set_boot_partition(partition); } - LOG_INFO("Restarting EMS-ESP from partition '%s'", partitionname); + LOG_INFO("Restarting EMS-ESP from %s partition", partitionname); } else { LOG_INFO("Restarting EMS-ESP..."); } @@ -967,6 +968,12 @@ void System::show_system(uuid::console::Shell & shell) { shell.printfln(" Board profile: %s", board_profile().c_str()); shell.printfln(" Uptime: %s", uuid::log::format_timestamp_ms(uuid::get_uptime_ms(), 3).c_str()); #ifndef EMSESP_STANDALONE + // https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/system/misc_system_api.html + unsigned char mac_base[6] = {0}; + esp_efuse_mac_get_default(mac_base); + esp_read_mac(mac_base, ESP_MAC_WIFI_STA); + shell.printfln(" Base MAC Address: %02X:%02X:%02X:%02X:%02X:%02X", mac_base[0], mac_base[1], mac_base[2], mac_base[3], mac_base[4], mac_base[5]); + shell.printfln(" SDK version: %s", ESP.getSdkVersion()); shell.printfln(" CPU frequency: %lu MHz", ESP.getCpuFreqMHz()); shell.printfln(" Free heap/Max alloc: %lu KB / %lu KB", getHeapMem(), getMaxAllocMem()); @@ -1651,12 +1658,4 @@ bool System::ntp_connected() { return ntp_connected_; } -std::string System::getMacAddress() const { -#ifndef EMSESP_STANDALONE - return WiFi.macAddress().c_str(); -#else - return "10:10:10:10:10:10"; -#endif -} - } // namespace emsesp