15#if PC_ENABLE_DASHBOARD
23#if PC_ENABLE_WEBSOCKET
34#if PC_ENABLE_WEBSOCKET
38static DashRoutesCtx s_dashr;
40static void dash_page_handler(uint8_t slot_id,
HttpReq *req)
49static void dash_layout_handler(uint8_t slot_id,
HttpReq *req)
53 pc_dashboard_layout_json(buf,
sizeof(buf));
56 s_dashr.srv->send(slot_id, 200, PC_MIME_JSON, buf);
60static void dash_sse_connect(uint8_t pc_sse_id)
63 if (s_dashr.srv && pc_dashboard_values_json(buf,
sizeof(buf)) > 0)
65 s_dashr.srv->pc_sse_send(pc_sse_id, buf);
69#if PC_ENABLE_WEBSOCKET
70static void dash_ws_connect(uint8_t ws_id)
74static void dash_ws_message(uint8_t ws_id)
79 pc_dashboard_dispatch_control(
ws_payload(ws_id));
82static void dash_ws_close(uint8_t ws_id)
88void pc_dashboard_begin(
PC &server,
const char *path,
const pc_widget *widgets, uint8_t count)
90 s_dashr.srv = &server;
91 pc_dashboard_configure(widgets, count);
93 if (!path || !path[0])
99 pc_sb sb_layout_path = {layout_path,
sizeof(layout_path), 0,
true};
104 layout_path[0] =
'\0';
106 pc_sb sb_stream_path = {s_dashr.stream_path,
sizeof(s_dashr.stream_path), 0,
true};
111 s_dashr.stream_path[0] =
'\0';
116 server.on_sse(s_dashr.stream_path, dash_sse_connect);
117#if PC_ENABLE_WEBSOCKET
118 pc_sb sb_ws_path = {s_dashr.ws_path,
sizeof(s_dashr.ws_path), 0,
true};
123 s_dashr.ws_path[0] =
'\0';
125 server.on_ws(s_dashr.ws_path, dash_ws_connect, dash_ws_message, dash_ws_close);
129void pc_dashboard_publish()
136 if (pc_dashboard_values_json(buf,
sizeof(buf)) > 0)
138 s_dashr.srv->pc_sse_broadcast(s_dashr.stream_path, buf);
Single-port HTTP server with deterministic, zero-allocation execution.
void on(const char *path, HttpMethod method, Handler callback)
Register a route handler.
Real-time SVG telemetry dashboard (PC_ENABLE_DASHBOARD).
Shared HTTP Content-Type ("MIME") string constants (one source of truth).
Layer 7 (Application) - public HTTP routing API.
@ HTTP_GET
Safe, idempotent read.
#define PC_DASHBOARD_JSON_BUF
Stack buffer for the dashboard layout / values JSON (bytes).
#define MAX_PATH_LEN
Maximum URL path length (including leading /).
Bounded no-heap string builder that fails closed on overflow (one shared copy).
size_t pc_sb_finish(pc_sb *b)
NUL-terminate and return the built length, or 0 if the build overflowed.
void pc_sb_put(pc_sb *b, const char *s)
Append NUL-terminated s; leaves the buffer untouched and clears ok if it would not fit.
Fully-parsed HTTP/1.1 request.
Bump-append target; ok latches false once an append would overflow cap.
const char PC_DASHBOARD_PAGE[]
Real-time SVG telemetry dashboard page (PC_ENABLE_DASHBOARD).
Layer 7 (Application) - embedded web assets generated from web_assets/input/.
const char * ws_payload(uint8_t ws_id)
The NUL-terminated reassembled message payload for ws_id, or nullptr if the slot is out of range / in...
Layer 6 (Presentation) – WebSocket frame parser and connection pool.