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

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

#include "protocore.h"
#include "shared_primitives/frame.h"

Go to the source code of this file.

Typedefs

typedef void(* TermCommandCb) (const char *line, uint8_t client_id)
 

Detailed Description

Browser "web serial" terminal over WebSocket (PC_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.

static const pc_field SAID[] = {{PC_FK_LIT, 0, 10, "you said: "}, PC_STR,
{PC_FK_LIT, 0, 1, "\n"}, PC_END};
static const pc_field UPTIME[] = {{PC_FK_LIT, 0, 7, "uptime "}, PC_U32,
{PC_FK_LIT, 0, 1, "\n"}, PC_END};
void on_cmd(const char *line, uint8_t client) {
pc_web_terminal_frame(SAID, line);
}
void setup() {
// ... wifi + server.on(...) ...
pc_web_terminal_begin(server, "/terminal");
pc_web_terminal_on_command(on_cmd);
server.begin(80);
}
void loop() {
server.handle();
pc_web_terminal_frame(UPTIME, (uint32_t)millis()); // device -> browsers
}
#define PC_END
Definition frame.h:110
#define PC_U32
Definition frame.h:104
@ PC_FK_LIT
literal text from lit; takes no argument
Definition frame.h:56
#define PC_STR
Definition frame.h:103
One field of a frame. Frames are static const pc_field[], so they live in rodata.
Definition frame.h:80

No-op stubs when PC_ENABLE_WEB_TERMINAL is 0.

Definition in file web_terminal.h.

Typedef Documentation

◆ TermCommandCb

typedef void(* TermCommandCb) (const char *line, uint8_t client_id)

Definition at line 86 of file web_terminal.h.