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:
@@ -3,5 +3,5 @@ idf_component_register(
|
||||
"main.cpp"
|
||||
"hardware_bootstrap.cpp"
|
||||
INCLUDE_DIRS "."
|
||||
REQUIRES core net secure_store adau1701 si4684 tuner audio bt1035 bluetooth station integration
|
||||
REQUIRES core net secure_store adau1701 si4684 tuner audio bt1035 bluetooth station integration eeprom24aa
|
||||
)
|
||||
|
||||
@@ -18,6 +18,9 @@
|
||||
#include "audio/AudioService.hpp"
|
||||
#include "board_pins.hpp"
|
||||
#include "bt1035/Bt1035Driver.hpp"
|
||||
#include "core/DeviceIdentity.hpp"
|
||||
#include "driver/i2c_master.h"
|
||||
#include "eeprom24aa/Eeprom24aa.hpp"
|
||||
#include "secure_store/NvsAudioProfileStore.hpp"
|
||||
#include "si4684/Si4684Band.hpp"
|
||||
#include "si4684/Si4684Driver.hpp"
|
||||
@@ -69,6 +72,7 @@ bt1035::Bt1035Driver gBt1035(
|
||||
.sysCtlGpio = board::pins::Bt1035SysCtl,
|
||||
});
|
||||
|
||||
core::DeviceIdentity gDeviceIdentity = core::DeviceIdentity::unknown();
|
||||
bool gReady = false;
|
||||
} // namespace
|
||||
|
||||
@@ -91,6 +95,21 @@ std::expected<void, HardwareBootError> HardwareBootstrap::boot()
|
||||
}
|
||||
}
|
||||
|
||||
const auto* busHandle =
|
||||
static_cast<i2c_master_bus_handle_t>(gAdau1701.i2cBusHandle());
|
||||
eeprom24aa::Eeprom24aa eeprom(busHandle,
|
||||
static_cast<std::uint8_t>(
|
||||
board::pins::Eeprom24aaAddr));
|
||||
if (auto identity = eeprom.readDeviceIdentity(); identity) {
|
||||
gDeviceIdentity = std::move(*identity);
|
||||
ESP_LOGI(kTag, "unit serial %.*s",
|
||||
static_cast<int>(gDeviceIdentity.serialNumber().size()),
|
||||
gDeviceIdentity.serialNumber().data());
|
||||
} else {
|
||||
gDeviceIdentity = core::DeviceIdentity::unknown();
|
||||
ESP_LOGW(kTag, "EUI-48 read failed — using fallback identity");
|
||||
}
|
||||
|
||||
if (auto audioResult = gAudioService.loadAndApply(); !audioResult) {
|
||||
ESP_LOGW(kTag, "ADAU1701 profile apply failed");
|
||||
}
|
||||
@@ -100,6 +119,11 @@ std::expected<void, HardwareBootError> HardwareBootstrap::boot()
|
||||
return std::unexpected(HardwareBootError::Bt1035BootFailed);
|
||||
}
|
||||
|
||||
if (auto nameResult =
|
||||
gBt1035.setDeviceName(gDeviceIdentity.bluetoothName()); !nameResult) {
|
||||
ESP_LOGW(kTag, "BT1035 device name set failed");
|
||||
}
|
||||
|
||||
gReady = true;
|
||||
ESP_LOGI(kTag, "companion chips ready");
|
||||
return {};
|
||||
@@ -129,4 +153,9 @@ bt1035::Bt1035Driver& HardwareBootstrap::bt1035Driver()
|
||||
return gBt1035;
|
||||
}
|
||||
|
||||
const core::DeviceIdentity& HardwareBootstrap::deviceIdentity() noexcept
|
||||
{
|
||||
return gDeviceIdentity;
|
||||
}
|
||||
|
||||
} // namespace hardware
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "core/CompanionChipStatus.hpp"
|
||||
#include "core/DeviceIdentity.hpp"
|
||||
|
||||
#include "bt1035/Bt1035Driver.hpp"
|
||||
|
||||
@@ -124,6 +125,18 @@ public:
|
||||
* @date 2026-07-06
|
||||
*/
|
||||
[[nodiscard]] static bt1035::Bt1035Driver& bt1035Driver();
|
||||
|
||||
/**
|
||||
* @brief deviceIdentity — per-board identity from the 24AA025E48 EUI-48.
|
||||
*
|
||||
* @dname deviceIdentity
|
||||
* @return Reference to identity loaded during boot().
|
||||
* @pubstate reads gDeviceIdentity after boot(); unknown() on EEPROM failure.
|
||||
*
|
||||
* @author Michele Bigi
|
||||
* @date 2026-07-07
|
||||
*/
|
||||
[[nodiscard]] static const core::DeviceIdentity& deviceIdentity() noexcept;
|
||||
};
|
||||
|
||||
} // namespace hardware
|
||||
|
||||
@@ -85,7 +85,8 @@ extern "C" void app_main()
|
||||
bluetoothService,
|
||||
stationService,
|
||||
integration,
|
||||
hardware::HardwareBootstrap::companionChipStatus());
|
||||
hardware::HardwareBootstrap::companionChipStatus(),
|
||||
hardware::HardwareBootstrap::deviceIdentity());
|
||||
if (!netResult) {
|
||||
ESP_LOGE(kTag, "network bootstrap failed");
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user