Add EEPROM EUI-48 device identity across firmware and API.

Read the factory 24AA025E48 serial after ADAU I2C boot, derive SoftAP SSID, BT name, STA hostname, and expose serialNumber on GET /api/health with graceful fallbacks.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-07-07 09:00:38 +02:00
co-authored by Cursor
parent 11ad6b43ad
commit cd94e36a9d
35 changed files with 999 additions and 83 deletions
+21 -1
View File
@@ -20,12 +20,15 @@
#include "esp_event.h"
#include "esp_log.h"
#include "esp_netif.h"
#include "esp_wifi.h"
#include "mdns.h"
#include "freertos/FreeRTOS.h"
#include "freertos/event_groups.h"
#include <algorithm>
#include <cstring>
#include <string>
namespace net {
@@ -104,12 +107,17 @@ StaClient& StaClient::operator=(StaClient&& other) noexcept
}
std::expected<void, NetError>
StaClient::connect(const core::WifiCredentials& creds)
StaClient::connect(const core::WifiCredentials& creds, std::string_view hostname)
{
if (connected_) {
return {};
}
std::string hostLabel;
if (!hostname.empty()) {
hostLabel.assign(hostname.begin(), hostname.end());
}
s_wifiEventGroup = xEventGroupCreate();
if (s_wifiEventGroup == nullptr) {
return std::unexpected(NetError::StaConnectFailed);
@@ -132,6 +140,13 @@ StaClient::connect(const core::WifiCredentials& creds)
return std::unexpected(NetError::WifiConfigFailed);
}
if (!hostLabel.empty()) {
esp_netif_t* netif = esp_netif_get_handle_from_ifkey("WIFI_STA_DEF");
if (netif != nullptr) {
esp_netif_set_hostname(netif, hostLabel.c_str());
}
}
wifi_config_t wifiCfg = {};
const std::string_view ssid = creds.ssid().value();
const std::size_t ssidCopy =
@@ -167,6 +182,11 @@ StaClient::connect(const core::WifiCredentials& creds)
if ((bits & kConnectedBit) != 0) {
connected_ = true;
if (!hostLabel.empty()) {
if (mdns_init() == ESP_OK) {
mdns_hostname_set(hostLabel.c_str());
}
}
ESP_LOGI(kTag, "connected to %.*s",
static_cast<int>(ssid.size()), ssid.data());
return {};