DeterministicESPAsyncWebServer v6.28.0
Zero-allocation, bounded-execution async HTTP server for ESP32
Loading...
Searching...
No Matches
partition_monitor.h
Go to the documentation of this file.
1// Copyright (C) 2026 Douglas Quigg (dstroy0) <dquigg123@gmail.com>
2// SPDX-License-Identifier: AGPL-3.0-or-later
3
4/**
5 * @file partition_monitor.h
6 * @brief Flash partition-map monitor (DETWS_ENABLE_PARTITION_MONITOR).
7 *
8 * Reports the device's flash partition table as JSON for diagnostics / OTA
9 * dashboards: each entry's label, a human "kind" (factory / ota / nvs / spiffs /
10 * littlefs / coredump / ...), the raw type/subtype, flash offset, size, and which
11 * app slot is currently running. The partition walk uses esp_partition /
12 * esp_ota_ops (ESP32-only); the kind classifier and the JSON serializer are pure
13 * and host-tested.
14 *
15 * @author Douglas Quigg (dstroy0)
16 * @date 2026
17 */
18
19#ifndef DETERMINISTICESPASYNCWEBSERVER_PARTITION_MONITOR_H
20#define DETERMINISTICESPASYNCWEBSERVER_PARTITION_MONITOR_H
21
22#include "ServerConfig.h"
23#include <stddef.h>
24#include <stdint.h>
25
26#if DETWS_ENABLE_PARTITION_MONITOR
27
28class DetWebServer;
29
30/** @brief One flash partition entry. */
31struct DetwsPartitionInfo
32{
33 char label[17]; ///< partition label (null-terminated).
34 uint8_t type; ///< esp_partition type (0 = app, 1 = data).
35 uint8_t subtype; ///< esp_partition subtype.
36 uint32_t address; ///< flash offset (bytes).
37 uint32_t size; ///< partition size (bytes).
38 bool running; ///< true for the currently-running app partition.
39};
40
41// ---------------------------------------------------------------------------
42// Host-testable core
43// ---------------------------------------------------------------------------
44
45/** @brief Human name for a partition type/subtype (e.g. "factory", "ota", "nvs", "littlefs"). */
46const char *detws_partition_kind(uint8_t type, uint8_t subtype);
47
48/**
49 * @brief Serialize a partition array as JSON `{"partitions":[...]}` into @p out.
50 * @return characters written, or 0 if @p cap is too small.
51 */
52int detws_partition_json(const DetwsPartitionInfo *parts, uint8_t count, char *out, size_t cap);
53
54/**
55 * @brief Walk the flash partition table into @p out (ESP32; 0 on host builds).
56 * @return number of partitions written (<= @p max).
57 */
58uint8_t detws_partition_collect(DetwsPartitionInfo *out, uint8_t max);
59
60// ---------------------------------------------------------------------------
61// Server integration
62// ---------------------------------------------------------------------------
63
64/** @brief Serve the partition map as JSON at @p path (GET). Default "/partitions". */
65void detws_partition_monitor_begin(DetWebServer &server, const char *path);
66
67#endif // DETWS_ENABLE_PARTITION_MONITOR
68#endif // DETERMINISTICESPASYNCWEBSERVER_PARTITION_MONITOR_H
User-facing configuration for DeterministicESPAsyncWebServer.
Single-port HTTP server with deterministic, zero-allocation execution.
Definition dwserver.h:348