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:
@@ -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
|
||||
|
||||
@@ -18,21 +18,13 @@
|
||||
|
||||
#include "core/HealthStatusJson.hpp"
|
||||
|
||||
#include <optional>
|
||||
#include <string>
|
||||
|
||||
namespace core {
|
||||
|
||||
namespace {
|
||||
|
||||
/**
|
||||
* @brief healthStateToken — map HealthState to the API status string.
|
||||
*
|
||||
* @dname healthStateToken
|
||||
* @param state Health indicator to encode.
|
||||
* @return JSON string token without quotes (e.g. ok).
|
||||
* @pubstate none
|
||||
*
|
||||
* @author Michele Bigi
|
||||
* @date 2026-07-06
|
||||
*/
|
||||
[[nodiscard]] const char* healthStateToken(HealthState state) noexcept
|
||||
{
|
||||
switch (state) {
|
||||
@@ -46,8 +38,16 @@ namespace {
|
||||
|
||||
std::string serializeHealthStatusJson(const HealthStatus& status)
|
||||
{
|
||||
return std::string("{\"status\":\"") + healthStateToken(status.state())
|
||||
+ "\",\"fw\":\"" + std::string(status.firmware().value()) + "\"}";
|
||||
std::string json = std::string("{\"status\":\"") + healthStateToken(status.state())
|
||||
+ "\",\"fw\":\"" + std::string(status.firmware().value()) + "\"";
|
||||
if (const std::optional<CompanionChipStatus>& chips = status.chips(); chips) {
|
||||
json += std::string(",\"chips\":{")
|
||||
+ "\"si4684\":" + (chips->si4684Ready ? "true" : "false")
|
||||
+ ",\"adau1701\":" + (chips->adau1701Ready ? "true" : "false")
|
||||
+ ",\"bt1035\":" + (chips->bt1035Ready ? "true" : "false") + "}";
|
||||
}
|
||||
json += '}';
|
||||
return json;
|
||||
}
|
||||
|
||||
} // namespace core
|
||||
|
||||
Reference in New Issue
Block a user