pull MAC from efuse

This commit is contained in:
proddy
2024-06-12 10:23:26 +02:00
parent 509c7ee900
commit b4a8d3c181

View File

@@ -45,6 +45,7 @@
#else // ESP32 Before IDF 4.0 #else // ESP32 Before IDF 4.0
#include "../rom/rtc.h" #include "../rom/rtc.h"
#endif #endif
#include <esp_mac.h>
#endif #endif
namespace emsesp { namespace emsesp {
@@ -291,7 +292,7 @@ void System::system_restart(const char * partitionname) {
} }
esp_ota_set_boot_partition(partition); 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 { } else {
LOG_INFO("Restarting EMS-ESP..."); 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(" Board profile: %s", board_profile().c_str());
shell.printfln(" Uptime: %s", uuid::log::format_timestamp_ms(uuid::get_uptime_ms(), 3).c_str()); shell.printfln(" Uptime: %s", uuid::log::format_timestamp_ms(uuid::get_uptime_ms(), 3).c_str());
#ifndef EMSESP_STANDALONE #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(" SDK version: %s", ESP.getSdkVersion());
shell.printfln(" CPU frequency: %lu MHz", ESP.getCpuFreqMHz()); shell.printfln(" CPU frequency: %lu MHz", ESP.getCpuFreqMHz());
shell.printfln(" Free heap/Max alloc: %lu KB / %lu KB", getHeapMem(), getMaxAllocMem()); shell.printfln(" Free heap/Max alloc: %lu KB / %lu KB", getHeapMem(), getMaxAllocMem());
@@ -1651,12 +1658,4 @@ bool System::ntp_connected() {
return 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 } // namespace emsesp