ProtoCore v0.0.1
Deterministic, zero-heap network stack for embedded targets
Loading...
Searching...
No Matches
web_assets.cpp File Reference

Go to the source code of this file.

Variables

const char PC_DASHBOARD_PAGE []
 Real-time SVG telemetry dashboard page (PC_ENABLE_DASHBOARD).
 
const char PC_PROV_FORM []
 Captive-portal form for WiFi credential entry (provisioning service).
 
const char PC_PROV_SAVED_HTML [] = "<html><body> Saved. Rebooting... </body></html>"
 Success page shown after credentials are saved and the device reboots.
 
const char PC_TERMINAL_PAGE []
 Self-contained WebSocket terminal page (green-phosphor CRT theme; auto ws/wss).
 
const char PC_SERVICE_WORKER []
 Service worker: precaches the app shell from the versioned manifest and serves it stale-while-revalidate.
 
const char PC_STATS_JSON []
 Runtime stats JSON (rendered via send_template); add/rename fields to taste.
 
const char PC_METRICS_PROM []
 All available Prometheus metrics; comment a value line out with a leading # to drop it.
 

Variable Documentation

◆ PC_DASHBOARD_PAGE

const char PC_DASHBOARD_PAGE[]

Real-time SVG telemetry dashboard page (PC_ENABLE_DASHBOARD).

Definition at line 10 of file web_assets.cpp.

◆ PC_PROV_FORM

const char PC_PROV_FORM[]
Initial value:
=
"<!doctype html><html><head><meta name=\"viewport\" content=\"width=device-width\" /><title>WiFi setup</title><"
"/head><body><h2>WiFi setup</h2><form method=\"POST\" action=\"/save\"> SSID:<br /><input name=\"ssid\" maxleng"
"th=\"32\" /><br /> Password:<br /><input name=\"psk\" type=\"password\" maxlength=\"63\" /><br /><br /><input "
"type=\"submit\" value=\"Save\" /></form></body></html>"

Captive-portal form for WiFi credential entry (provisioning service).

Definition at line 82 of file web_assets.cpp.

◆ PC_PROV_SAVED_HTML

const char PC_PROV_SAVED_HTML[] = "<html><body> Saved. Rebooting... </body></html>"

Success page shown after credentials are saved and the device reboots.

Definition at line 88 of file web_assets.cpp.

◆ PC_TERMINAL_PAGE

const char PC_TERMINAL_PAGE[]
Initial value:
=
"<!doctype html><html><head><meta charset=\"utf-8\" /><meta name=\"viewport\" content=\"width=device-width,init"
"ial-scale=1\" /><title>PC Terminal</title> <style>:root{--g:#2bb35a;--g2:#00c000;--bg:#080c08;}*{box-sizing:bo"
"rder-box;}html,body{margin:0;height:100%;background:var(--bg);color:var(--g);font:14px/1.45 \"Consolas\",\"Dej"
"aVu Sans Mono\",monospace;}#wrap{display:flex;flex-direction:column;height:100%;position:relative;}#out{flex:1"
";overflow:auto;padding:10px;white-space:pre-wrap;word-break:break-word;text-shadow:0 0 4px rgba(43,179,90,0.55"
");}#bar{display:flex;border-top:1px solid #14401f;background:#0a0f0a;}#ps{padding:8px 4px 8px 10px;color:var(-"
"-g2);}#in{flex:1;background:transparent;border:0;color:var(--g);font:inherit;padding:8px;outline:none;}#st{pad"
"ding:4px 10px;font-size:11px;color:#1c6e38;border-top:1px solid #14401f;}#crt{position:absolute;inset:0;pointe"
"r-events:none;z-index:9;background:repeating-linear-gradient( rgba(0,0,0,0) 0 2px,rgba(0,0,0,0.18) 3px );box-s"
"hadow:inset 0 0 120px rgba(0,0,0,0.6);}.e{color:#d2553a;}</style> </head><body><div id=\"wrap\"><div id=\"out"
"\"></div><div id=\"bar\"><span id=\"ps\">&gt;</span ><input id=\"in\" autocomplete=\"off\" autofocus /></div><"
"div id=\"st\">connecting…</div><div id=\"crt\"></div></div> <script>var out = document.getElementById(\"out\")"
",\ninp = document.getElementById(\"in\"),\nst = document.getElementById(\"st\");\nvar hist = [],\nhi = 0,\nws,"
"\nurl =\n(location.protocol == \"https:\" ? \"wss\" : \"ws\") +\n\"://\" +\nlocation.host +\nlocation.pathname"
".replace(/\\/$/, \"\") +\n\"/ws\";\nfunction add(t, c) {\nvar b =\nout.scrollHeight - out.clientHeight - out.s"
"crollTop < 40;\nvar s = document.createElement(\"span\");\nif (c) s.className = c;\ns.textContent = t;\nout.ap"
"pendChild(s);\nif (b) out.scrollTop = out.scrollHeight;\n}\nfunction conn() {\nws = new WebSocket(url);\nws.on"
"open = function () {\nst.textContent = \"connected\";\n};\nws.onmessage = function (e) {\nadd(e.data);\n};\nws"
".onclose = function () {\nst.textContent = \"disconnected — retrying…\";\nsetTimeout(conn, 1000);\n};\nws.oner"
"ror = function () {\ntry {\nws.close();\n} catch (_) {}\n};\n}\ninp.addEventListener(\"keydown\", function (e)"
" {\nif (e.key == \"Enter\") {\nvar v = inp.value;\nif (v) {\nif (ws && ws.readyState == 1) {\nws.send(v);\nadd"
"(\"> \" + v + \"\\n\");\n} else add(\"> \" + v + \" (offline)\\n\", \"e\");\nhist.push(v);\nhi = hist.length;"
"\n}\ninp.value = \"\";\n} else if (e.key == \"ArrowUp\") {\nif (hi > 0) {\nhi--;\ninp.value = hist[hi] || \"\""
";\n}\n} else if (e.key == \"ArrowDown\") {\nif (hi < hist.length) {\nhi++;\ninp.value = hist[hi] || \"\";\n}\n"
"}\n});\nconn();</script> </body></html>"

Self-contained WebSocket terminal page (green-phosphor CRT theme; auto ws/wss).

Definition at line 90 of file web_assets.cpp.

◆ PC_SERVICE_WORKER

const char PC_SERVICE_WORKER[]

Service worker: precaches the app shell from the versioned manifest and serves it stale-while-revalidate.

Definition at line 118 of file web_assets.cpp.

◆ PC_STATS_JSON

const char PC_STATS_JSON[]
Initial value:
=
"{\"uptime_ms\":{{uptime_ms}},\"requests\":{{requests}},\"http_2xx\":{{http_2xx}},\"http_4xx\":{{http_4xx}},\"h"
"ttp_5xx\":{{http_5xx}},\"active_conns\":{{active_conns}},\"free_heap\":{{free_heap}}}"

Runtime stats JSON (rendered via send_template); add/rename fields to taste.

Definition at line 153 of file web_assets.cpp.

◆ PC_METRICS_PROM

const char PC_METRICS_PROM[]
Initial value:
=
"# HELP pc_uptime_seconds Device uptime in seconds.\n# TYPE pc_uptime_seconds gauge\npc_uptime_seconds {{uptime"
"_seconds}}\n# HELP pc_http_requests_total Total HTTP responses sent.\n# TYPE pc_http_requests_total counter\np"
"c_http_requests_total {{requests_total}}\n# HELP pc_http_responses_total HTTP responses by status class.\n# TY"
"PE pc_http_responses_total counter\npc_http_responses_total{class=\"2xx\"} {{resp_2xx}}\npc_http_responses_tot"
"al{class=\"4xx\"} {{resp_4xx}}\npc_http_responses_total{class=\"5xx\"} {{resp_5xx}}\n# HELP pc_active_connecti"
"ons Currently active connection slots.\n# TYPE pc_active_connections gauge\npc_active_connections {{active_con"
"ns}}\n# HELP pc_max_connections Connection slot capacity.\n# TYPE pc_max_connections gauge\npc_max_connections"
" {{max_conns}}\n# HELP pc_free_heap_bytes Free heap in bytes.\n# TYPE pc_free_heap_bytes gauge\npc_free_heap_b"
"ytes {{free_heap}}\n# HELP pc_min_free_heap_bytes Lowest free heap observed since boot, in bytes.\n# TYPE pc_m"
"in_free_heap_bytes gauge\npc_min_free_heap_bytes {{min_free_heap}}\n# HELP pc_heap_size_bytes Total heap size,"
" in bytes.\n# TYPE pc_heap_size_bytes gauge\npc_heap_size_bytes {{heap_size}}\n# HELP pc_max_alloc_heap_bytes "
"Largest contiguous allocatable heap block, in bytes.\n# TYPE pc_max_alloc_heap_bytes gauge\npc_max_alloc_heap_"
"bytes {{max_alloc_heap}}\n"

All available Prometheus metrics; comment a value line out with a leading # to drop it.

Definition at line 158 of file web_assets.cpp.