Integrate companion-chip status into GET /api/health (fw 0.6.0).
Expose Si4684, ADAU1701, and BT1035 boot flags via CompanionChipStatus after HardwareBootstrap; update API manual schema for Slice 8. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "core/CompanionChipStatus.hpp"
|
||||
#include "core/ISecureStore.hpp"
|
||||
#include "net/NetError.hpp"
|
||||
#include "net/NetState.hpp"
|
||||
@@ -65,7 +66,8 @@ public:
|
||||
*/
|
||||
[[nodiscard]] static std::expected<NetBootstrap, NetError>
|
||||
start(core::ISecureStore& store, tuner::TunerService& tuner,
|
||||
audio::AudioService& audio);
|
||||
audio::AudioService& audio,
|
||||
core::CompanionChipStatus companionChips);
|
||||
|
||||
NetBootstrap(const NetBootstrap&) = delete;
|
||||
NetBootstrap& operator=(const NetBootstrap&) = delete;
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "core/CompanionChipStatus.hpp"
|
||||
#include "core/ISecureStore.hpp"
|
||||
#include "net/NetError.hpp"
|
||||
#include "net/NetState.hpp"
|
||||
@@ -52,6 +53,7 @@ struct HttpRouteContext {
|
||||
core::ISecureStore* store; ///< Secure store for Wi-Fi provisioning.
|
||||
tuner::TunerService* tuner; ///< Tuner service for tuner REST routes.
|
||||
audio::AudioService* audio; ///< Audio service for ADAU1701 REST routes.
|
||||
core::CompanionChipStatus companionChips; ///< Boot flags for /api/health.
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -131,10 +133,10 @@ public:
|
||||
* @author Michele Bigi
|
||||
* @date 2026-07-06
|
||||
*/
|
||||
[[nodiscard]] std::expected<void, NetError> start(core::ISecureStore& store,
|
||||
NetState netState,
|
||||
tuner::TunerService& tuner,
|
||||
audio::AudioService& audio);
|
||||
[[nodiscard]] std::expected<void, NetError> start(
|
||||
core::ISecureStore& store, NetState netState,
|
||||
tuner::TunerService& tuner, audio::AudioService& audio,
|
||||
core::CompanionChipStatus companionChips);
|
||||
|
||||
private:
|
||||
httpd_handle* server_;
|
||||
|
||||
@@ -100,7 +100,8 @@ constexpr char kTag[] = "NetBootstrap";
|
||||
*/
|
||||
[[nodiscard]] std::expected<NetBootstrap, NetError>
|
||||
startSetupMode(core::ISecureStore& store, tuner::TunerService& tuner,
|
||||
audio::AudioService& audio)
|
||||
audio::AudioService& audio,
|
||||
core::CompanionChipStatus companionChips)
|
||||
{
|
||||
esp_netif_create_default_wifi_ap();
|
||||
|
||||
@@ -111,7 +112,8 @@ startSetupMode(core::ISecureStore& store, tuner::TunerService& tuner,
|
||||
|
||||
SetupWebServer webServer;
|
||||
if (auto webResult =
|
||||
webServer.start(store, NetState::SoftApSetup, tuner, audio);
|
||||
webServer.start(store, NetState::SoftApSetup, tuner, audio,
|
||||
companionChips);
|
||||
!webResult) {
|
||||
return std::unexpected(webResult.error());
|
||||
}
|
||||
@@ -134,7 +136,8 @@ startSetupMode(core::ISecureStore& store, tuner::TunerService& tuner,
|
||||
*/
|
||||
[[nodiscard]] std::expected<NetBootstrap, NetError>
|
||||
startStaMode(core::ISecureStore& store, tuner::TunerService& tuner,
|
||||
audio::AudioService& audio)
|
||||
audio::AudioService& audio,
|
||||
core::CompanionChipStatus companionChips)
|
||||
{
|
||||
auto credsResult = store.loadWifiCredentials();
|
||||
if (!credsResult) {
|
||||
@@ -151,7 +154,8 @@ startStaMode(core::ISecureStore& store, tuner::TunerService& tuner,
|
||||
|
||||
SetupWebServer webServer;
|
||||
if (auto webResult =
|
||||
webServer.start(store, NetState::StaConnected, tuner, audio);
|
||||
webServer.start(store, NetState::StaConnected, tuner, audio,
|
||||
companionChips);
|
||||
!webResult) {
|
||||
return std::unexpected(webResult.error());
|
||||
}
|
||||
@@ -165,7 +169,8 @@ startStaMode(core::ISecureStore& store, tuner::TunerService& tuner,
|
||||
|
||||
std::expected<NetBootstrap, NetError>
|
||||
NetBootstrap::start(core::ISecureStore& store, tuner::TunerService& tuner,
|
||||
audio::AudioService& audio)
|
||||
audio::AudioService& audio,
|
||||
core::CompanionChipStatus companionChips)
|
||||
{
|
||||
if (auto platform = initPlatform(); !platform) {
|
||||
return std::unexpected(platform.error());
|
||||
@@ -176,14 +181,14 @@ NetBootstrap::start(core::ISecureStore& store, tuner::TunerService& tuner,
|
||||
}
|
||||
|
||||
if (store.hasWifiCredentials()) {
|
||||
auto staResult = startStaMode(store, tuner, audio);
|
||||
auto staResult = startStaMode(store, tuner, audio, companionChips);
|
||||
if (staResult) {
|
||||
return staResult;
|
||||
}
|
||||
ESP_LOGW(kTag, "STA join failed — falling back to setup SoftAP");
|
||||
}
|
||||
|
||||
return startSetupMode(store, tuner, audio);
|
||||
return startSetupMode(store, tuner, audio, companionChips);
|
||||
}
|
||||
|
||||
NetBootstrap::NetBootstrap(std::optional<SoftApHost> softAp,
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
|
||||
#include "core/AudioProfile.hpp"
|
||||
#include "core/AudioProfileJson.hpp"
|
||||
#include "core/CompanionChipStatus.hpp"
|
||||
#include "core/FirmwareVersion.hpp"
|
||||
#include "core/HealthStatus.hpp"
|
||||
#include "core/HealthStatusJson.hpp"
|
||||
@@ -44,7 +45,7 @@ namespace net {
|
||||
|
||||
namespace {
|
||||
constexpr char kTag[] = "SetupWebServer";
|
||||
constexpr char kFirmwareVersion[] = "0.5.0";
|
||||
constexpr char kFirmwareVersion[] = "0.6.0";
|
||||
constexpr unsigned kRebootDelaySec = 3;
|
||||
|
||||
extern const uint8_t www_index_html_gz_start[] asm(
|
||||
@@ -165,8 +166,17 @@ template <std::size_t N>
|
||||
*/
|
||||
esp_err_t healthGetHandler(httpd_req_t* req)
|
||||
{
|
||||
const core::HealthStatus status =
|
||||
core::HealthStatus::ok(core::FirmwareVersion(kFirmwareVersion));
|
||||
auto* ctx = routeContextFrom(req);
|
||||
const core::CompanionChipStatus chips =
|
||||
ctx != nullptr
|
||||
? ctx->companionChips
|
||||
: core::CompanionChipStatus{
|
||||
.si4684Ready = false,
|
||||
.adau1701Ready = false,
|
||||
.bt1035Ready = false,
|
||||
};
|
||||
const core::HealthStatus status = core::HealthStatus::ok(
|
||||
core::FirmwareVersion(kFirmwareVersion), chips);
|
||||
const std::string json = core::serializeHealthStatusJson(status);
|
||||
httpd_resp_set_type(req, "application/json");
|
||||
return httpd_resp_send(req, json.c_str(), json.size());
|
||||
@@ -622,7 +632,7 @@ SetupWebServer::SetupWebServer()
|
||||
, netState_(NetState::Uninitialized)
|
||||
, tuner_(nullptr)
|
||||
, audio_(nullptr)
|
||||
, routeContext_{nullptr, nullptr, nullptr}
|
||||
, routeContext_{nullptr, nullptr, nullptr, {}}
|
||||
{
|
||||
}
|
||||
|
||||
@@ -639,7 +649,7 @@ SetupWebServer::SetupWebServer(SetupWebServer&& other) noexcept
|
||||
other.netState_ = NetState::Uninitialized;
|
||||
other.tuner_ = nullptr;
|
||||
other.audio_ = nullptr;
|
||||
other.routeContext_ = {nullptr, nullptr, nullptr};
|
||||
other.routeContext_ = {nullptr, nullptr, nullptr, {}};
|
||||
}
|
||||
|
||||
SetupWebServer& SetupWebServer::operator=(SetupWebServer&& other) noexcept
|
||||
@@ -659,7 +669,7 @@ SetupWebServer& SetupWebServer::operator=(SetupWebServer&& other) noexcept
|
||||
other.netState_ = NetState::Uninitialized;
|
||||
other.tuner_ = nullptr;
|
||||
other.audio_ = nullptr;
|
||||
other.routeContext_ = {nullptr, nullptr, nullptr};
|
||||
other.routeContext_ = {nullptr, nullptr, nullptr, {}};
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
@@ -670,14 +680,15 @@ SetupWebServer::~SetupWebServer()
|
||||
httpd_stop(server_);
|
||||
server_ = nullptr;
|
||||
}
|
||||
routeContext_ = {nullptr, nullptr, nullptr};
|
||||
routeContext_ = {nullptr, nullptr, nullptr, {}};
|
||||
}
|
||||
|
||||
std::expected<void, NetError> SetupWebServer::start(
|
||||
core::ISecureStore& store,
|
||||
NetState netState,
|
||||
tuner::TunerService& tuner,
|
||||
audio::AudioService& audio)
|
||||
audio::AudioService& audio,
|
||||
core::CompanionChipStatus companionChips)
|
||||
{
|
||||
if (server_ != nullptr) {
|
||||
return {};
|
||||
@@ -690,6 +701,7 @@ std::expected<void, NetError> SetupWebServer::start(
|
||||
routeContext_.store = &store;
|
||||
routeContext_.tuner = &tuner;
|
||||
routeContext_.audio = &audio;
|
||||
routeContext_.companionChips = companionChips;
|
||||
|
||||
httpd_config_t config = HTTPD_DEFAULT_CONFIG();
|
||||
config.server_port = 80;
|
||||
@@ -697,7 +709,7 @@ std::expected<void, NetError> SetupWebServer::start(
|
||||
|
||||
if (httpd_start(&server_, &config) != ESP_OK) {
|
||||
ESP_LOGE(kTag, "httpd_start failed");
|
||||
routeContext_ = {nullptr, nullptr, nullptr};
|
||||
routeContext_ = {nullptr, nullptr, nullptr, {}};
|
||||
return std::unexpected(NetError::HttpServerStartFailed);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user