11#if DETWS_ENABLE_WEB_TERMINAL
35static WebTerminalCtx s_term;
39static void term_page_handler(uint8_t slot_id,
HttpReq *req)
46static void term_ws_connect(uint8_t ws_id)
49 s_term.is_client[ws_id] =
true;
51 s_term.srv->ws_send_text(ws_id,
"DeterministicESPAsyncWebServer terminal ready\n");
54static void term_ws_message(uint8_t ws_id)
60static void term_ws_close(uint8_t ws_id)
63 s_term.is_client[ws_id] =
false;
68void detws_web_terminal_begin(
DetWebServer &server,
const char *path)
72 s_term.is_client[i] =
false;
74 if (!path || !path[0])
76 snprintf(s_term.ws_path,
sizeof(s_term.ws_path),
"%s/ws", path);
79 server.on_ws(s_term.ws_path, term_ws_connect, term_ws_message, term_ws_close);
87void detws_web_terminal_print(
const char *s)
89 if (!s_term.srv || !s)
94 s_term.srv->ws_send_text(i, s);
98void detws_web_terminal_println(
const char *s)
101 snprintf(buf,
sizeof(buf),
"%s\n", s ? s :
"");
102 detws_web_terminal_print(buf);
105void detws_web_terminal_printf(
const char *fmt, ...)
110 vsnprintf(buf,
sizeof(buf), fmt, ap);
112 detws_web_terminal_print(buf);
115uint8_t detws_web_terminal_client_count()
#define TERM_TX_BUF_SIZE
Stack scratch for detws_web_terminal_printf()/println() formatting.
#define MAX_PATH_LEN
Maximum URL path length (including leading /).
#define MAX_WS_CONNS
Maximum simultaneous WebSocket connections.
Single-port HTTP server with deterministic, zero-allocation execution.
void on(const char *path, HttpMethod method, Handler callback)
Register a route handler.
@ HTTP_GET
Safe, idempotent read.
Shared HTTP Content-Type ("MIME") string constants (one source of truth).
Fully-parsed HTTP/1.1 request.
const char DETWS_TERMINAL_PAGE[]
Self-contained WebSocket terminal page (green-phosphor CRT theme; auto ws/wss).
Layer 7 (Application) - embedded web assets generated from src/web/input/.
Browser "web serial" terminal over WebSocket (DETWS_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]....