12#if PC_ENABLE_WEB_TERMINAL
35static WebTerminalCtx s_term;
39static void term_page_handler(uint8_t slot_id,
HttpReq *req)
50static void term_ws_connect(uint8_t ws_id)
57 s_term.is_client[ws_id] =
true;
62 s_term.srv->ws_send_text(ws_id,
"ProtoCore terminal ready\n");
66static void term_ws_message(uint8_t ws_id)
76static void term_ws_close(uint8_t ws_id)
80 s_term.is_client[ws_id] =
false;
86void pc_web_terminal_begin(
PC &server,
const char *path)
91 s_term.is_client[i] =
false;
94 if (!path || !path[0])
98 pc_sb sb_ws_path = {s_term.ws_path,
sizeof(s_term.ws_path), 0,
true};
103 s_term.ws_path[0] =
'\0';
107 server.on_ws(s_term.ws_path, term_ws_connect, term_ws_message, term_ws_close);
115void pc_web_terminal_print(
const char *s)
117 if (!s_term.srv || !s)
125 s_term.srv->ws_send_text(i, s);
130void pc_web_terminal_println(
const char *s)
133 pc_sb sb_buf = {buf,
sizeof(buf), 0,
true};
140 pc_web_terminal_print(buf);
143void pc_web_terminal_frame(
const pc_field *spec, ...)
152 pc_web_terminal_print(buf);
155uint8_t pc_web_terminal_client_count()
Single-port HTTP server with deterministic, zero-allocation execution.
void on(const char *path, HttpMethod method, Handler callback)
Register a route handler.
PC_OPTIMIZE_O2 size_t pc_frame_vbuild(char *out, size_t cap, const pc_field *spec, va_list ap)
va_list form, for a caller that already has one.
Shared HTTP Content-Type ("MIME") string constants (one source of truth).
@ HTTP_GET
Safe, idempotent read.
#define TERM_TX_BUF_SIZE
Stack scratch for pc_web_terminal_frame()/println() line building.
#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.
One field of a frame. Frames are static const pc_field[], so they live in rodata.
Bump-append target; ok latches false once an append would overflow cap.
const char PC_TERMINAL_PAGE[]
Self-contained WebSocket terminal page (green-phosphor CRT theme; auto ws/wss).
Layer 7 (Application) - embedded web assets generated from web_assets/input/.
Browser "web serial" terminal over WebSocket (PC_ENABLE_WEB_TERMINAL).
void(* TermCommandCb)(const char *line, uint8_t client_id)
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...
bool ws_active(uint8_t ws_id)
True if ws_id is a valid, in-use WebSocket slot. Use this instead of reaching into ws_pool[ws_id]....