ProtoCore v1.0.16
Deterministic, zero-heap network stack for embedded targets
Loading...
Searching...
No Matches
web_terminal.h File Reference

Browser "web serial" terminal over WebSocket (PROTOCORE_ENABLE_WEB_TERMINAL). More...

#include "protocore_config.h"

Go to the source code of this file.

Detailed Description

Browser "web serial" terminal over WebSocket (PROTOCORE_ENABLE_WEB_TERMINAL).

A zero-heap equivalent of the WebSerial-style remote serial monitor: it serves a self-contained terminal web page and a WebSocket endpoint on the same path. Device output is broadcast to every connected browser; each line a browser sends is delivered to a command callback. Rides the library's existing WebSocket layer (no extra connection state), so it is TLS-agnostic - the page auto-selects ws:// or wss:// from the page's own scheme.

A line is built with the frame engine and handed over as text, so the shape is a static const mmgr_field[] in rodata rather than a format string parsed per call.

static const mmgr_field SAID[] = {{MMGR_FK_LIT, 0, 10, "you said: "}, MMGR_STR,
{MMGR_FK_LIT, 0, 1, "\n"}, MMGR_END};
void on_cmd(const char *line, uint8_t client) {
char out[64];
EMBED_CALL(numer.build, NumerosCfg, .out = out, .cap = sizeof(out), .spec = SAID, .vals = (const
mmgr_fval[]){MMGR_VSTR(line)}, .nvals = 1); protocore_web_terminal_print(out);
}
void setup() {
// ... wifi + on_http(...) ...
protocore_web_terminal_begin("/terminal");
protocore_web_terminal_on_command(on_cmd);
begin_http(80);
}

No-op stubs when PROTOCORE_ENABLE_WEB_TERMINAL is 0.

Definition in file web_terminal.h.