Update on Overleaf.
This commit is contained in:
@@ -18,6 +18,9 @@
|
||||
#pragma once
|
||||
|
||||
#include "core/FirmwareVersion.hpp"
|
||||
#include "core/CompanionChipStatus.hpp"
|
||||
|
||||
#include <optional>
|
||||
|
||||
namespace core {
|
||||
|
||||
@@ -64,6 +67,21 @@ public:
|
||||
*/
|
||||
[[nodiscard]] static HealthStatus ok(FirmwareVersion firmware);
|
||||
|
||||
/**
|
||||
* @brief ok — build health response including companion-chip flags.
|
||||
*
|
||||
* @dname ok
|
||||
* @param firmware Active firmware version to report.
|
||||
* @param chips Si4684 / ADAU1701 / BT1035 boot snapshot.
|
||||
* @return HealthStatus with HealthState::Ok and chips populated.
|
||||
* @pubstate none
|
||||
*
|
||||
* @author Michele Bigi
|
||||
* @date 2026-07-06
|
||||
*/
|
||||
[[nodiscard]] static HealthStatus ok(FirmwareVersion firmware,
|
||||
CompanionChipStatus chips);
|
||||
|
||||
/**
|
||||
* @brief state — read the health indicator.
|
||||
*
|
||||
@@ -88,11 +106,28 @@ public:
|
||||
*/
|
||||
[[nodiscard]] const FirmwareVersion& firmware() const noexcept;
|
||||
|
||||
/**
|
||||
* @brief chips — optional companion-chip boot flags.
|
||||
*
|
||||
* @dname chips
|
||||
* @return Chip status when set by ok(..., chips); otherwise nullopt.
|
||||
* @pubstate reads chips_.
|
||||
*
|
||||
* @author Michele Bigi
|
||||
* @date 2026-07-06
|
||||
*/
|
||||
[[nodiscard]] const std::optional<CompanionChipStatus>& chips() const
|
||||
noexcept;
|
||||
|
||||
private:
|
||||
explicit HealthStatus(HealthState state, FirmwareVersion firmware);
|
||||
|
||||
explicit HealthStatus(HealthState state, FirmwareVersion firmware,
|
||||
CompanionChipStatus chips);
|
||||
|
||||
HealthState state_;
|
||||
FirmwareVersion firmware_;
|
||||
std::optional<CompanionChipStatus> chips_;
|
||||
};
|
||||
|
||||
} // namespace core
|
||||
|
||||
@@ -7,11 +7,6 @@
|
||||
* Copyright 2026 Michele Bigi
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* @author Michele Bigi
|
||||
* @date 2026-07-06
|
||||
*/
|
||||
@@ -25,9 +20,24 @@ HealthStatus HealthStatus::ok(FirmwareVersion firmware)
|
||||
return HealthStatus(HealthState::Ok, std::move(firmware));
|
||||
}
|
||||
|
||||
HealthStatus HealthStatus::ok(FirmwareVersion firmware,
|
||||
CompanionChipStatus chips)
|
||||
{
|
||||
return HealthStatus(HealthState::Ok, std::move(firmware), chips);
|
||||
}
|
||||
|
||||
HealthStatus::HealthStatus(HealthState state, FirmwareVersion firmware)
|
||||
: state_(state)
|
||||
, firmware_(std::move(firmware))
|
||||
, chips_(std::nullopt)
|
||||
{
|
||||
}
|
||||
|
||||
HealthStatus::HealthStatus(HealthState state, FirmwareVersion firmware,
|
||||
CompanionChipStatus chips)
|
||||
: state_(state)
|
||||
, firmware_(std::move(firmware))
|
||||
, chips_(chips)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -41,4 +51,9 @@ const FirmwareVersion& HealthStatus::firmware() const noexcept
|
||||
return firmware_;
|
||||
}
|
||||
|
||||
const std::optional<CompanionChipStatus>& HealthStatus::chips() const noexcept
|
||||
{
|
||||
return chips_;
|
||||
}
|
||||
|
||||
} // namespace core
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
*/
|
||||
|
||||
#include "core/FirmwareVersion.hpp"
|
||||
#include "core/CompanionChipStatus.hpp"
|
||||
#include "core/HealthStatus.hpp"
|
||||
#include "core/HealthStatusJson.hpp"
|
||||
|
||||
@@ -85,5 +86,22 @@ namespace {
|
||||
*/
|
||||
int main()
|
||||
{
|
||||
return runHealthStatusJsonTest();
|
||||
if (runHealthStatusJsonTest() != EXIT_SUCCESS) {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
const core::HealthStatus withChips = core::HealthStatus::ok(
|
||||
core::FirmwareVersion("0.6.0"),
|
||||
core::CompanionChipStatus{
|
||||
.si4684Ready = true,
|
||||
.adau1701Ready = true,
|
||||
.bt1035Ready = true,
|
||||
});
|
||||
const std::string chipsJson = core::serializeHealthStatusJson(withChips);
|
||||
if (!expectEqual(
|
||||
chipsJson,
|
||||
R"({"status":"ok","fw":"0.6.0","chips":{"si4684":true,"adau1701":true,"bt1035":true}})")) {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
return EXIT_SUCCESS;
|
||||
}
|
||||
|
||||
@@ -36,13 +36,16 @@ Returns a health-check DTO serialised by
|
||||
|
||||
\begin{drnote}[Response schema]
|
||||
\begin{drcode}[JSON]
|
||||
{"status":"ok","fw":"0.5.0"}
|
||||
{"status":"ok","fw":"0.6.0",
|
||||
"chips":{"si4684":true,"adau1701":true,"bt1035":true}}
|
||||
\end{drcode}
|
||||
\begin{itemize}
|
||||
\item \texttt{status} --- coarse indicator; \texttt{ok} when the
|
||||
firmware is running normally.
|
||||
\item \texttt{fw} --- firmware release string
|
||||
(\texttt{core::FirmwareVersion}).
|
||||
\item \texttt{chips} --- companion-chip boot flags after
|
||||
\texttt{HardwareBootstrap::boot()} (Slice~8 integration).
|
||||
\end{itemize}
|
||||
\end{drnote}
|
||||
|
||||
|
||||
@@ -115,4 +115,13 @@ audio::AudioService& HardwareBootstrap::audioService()
|
||||
return gAudioService;
|
||||
}
|
||||
|
||||
core::CompanionChipStatus HardwareBootstrap::companionChipStatus() noexcept
|
||||
{
|
||||
return core::CompanionChipStatus{
|
||||
.si4684Ready = gSi4684.isBooted(),
|
||||
.adau1701Ready = gAdau1701.isBooted(),
|
||||
.bt1035Ready = gBt1035.isBooted(),
|
||||
};
|
||||
}
|
||||
|
||||
} // namespace hardware
|
||||
|
||||
@@ -61,7 +61,8 @@ extern "C" void app_main()
|
||||
static secure_store::NvsSecureStore store;
|
||||
|
||||
auto netResult = net::NetBootstrap::start(
|
||||
store, tunerService, hardware::HardwareBootstrap::audioService());
|
||||
store, tunerService, hardware::HardwareBootstrap::audioService(),
|
||||
hardware::HardwareBootstrap::companionChipStatus());
|
||||
if (!netResult) {
|
||||
ESP_LOGE(kTag, "network bootstrap failed");
|
||||
return;
|
||||
|
||||
Executable → Regular
Executable → Regular
Executable → Regular
Reference in New Issue
Block a user