Boot reason via watchdog scratch register, reboot/picoboot CLI commands, enum msgpack support

This commit is contained in:
Ian Gulliver
2026-04-12 08:17:22 +09:00
parent 9b7362c460
commit 6c3e0757f9
8 changed files with 110 additions and 6 deletions

View File

@@ -6,6 +6,7 @@
extern std::string_view firmware_name;
void handlers_init();
std::optional<ResponsePICOBOOT> handle_picoboot(const responder& resp, const RequestPICOBOOT&);
std::optional<ResponseInfo> handle_info(const responder& resp, const RequestInfo&);
std::optional<ResponseLog> handle_log(const responder& resp, const RequestLog&);

View File

@@ -373,6 +373,10 @@ public:
requires std::is_integral_v<T> && (!std::is_same_v<T, bool>)
pack_result pack(T n) { return pack_integer(n); }
template <typename T>
requires std::is_enum_v<T>
pack_result pack(T v) { return pack_integer(static_cast<std::underlying_type_t<T>>(v)); }
pack_result pack(bool v) { return pack_bool(v); }
pack_result pack(float v) { return pack_float(v); }
pack_result pack(double v) { return pack_double(v); }
@@ -727,6 +731,16 @@ public:
}
};
template <typename T>
requires std::is_enum_v<T>
result<parser> unpack(const parser &p, T &out) {
std::underlying_type_t<T> v;
auto r = unpack(p, v);
if (!r) return r;
out = static_cast<T>(v);
return r;
}
template <typename T>
requires std::is_integral_v<T> && (!std::is_same_v<T, bool>)
result<parser> unpack(const parser &p, T &out) {

View File

@@ -44,14 +44,20 @@ struct RequestInfo {
auto as_tuple() { return std::tie(); }
};
enum class boot_reason : uint8_t {
cold_boot = 0,
request_reboot = 1,
};
struct ResponseInfo {
static constexpr int8_t ext_id = 5;
std::array<uint8_t, 8> board_id;
std::array<uint8_t, 6> mac;
std::array<uint8_t, 4> ip;
std::string firmware_name;
auto as_tuple() const { return std::tie(board_id, mac, ip, firmware_name); }
auto as_tuple() { return std::tie(board_id, mac, ip, firmware_name); }
boot_reason boot;
auto as_tuple() const { return std::tie(board_id, mac, ip, firmware_name, boot); }
auto as_tuple() { return std::tie(board_id, mac, ip, firmware_name, boot); }
};
struct RequestLog {