code wiki / (root) / nx_iot_hub_serve.nx

nx_iot_hub_serve.nx

buildroot/runtime/nx_iot_hub_serve.nx

5032 B118 linesdepth 4pulls 7 transitivereach 1 importersview sourcekind servicetopic iot
docsdependenciesstructsconstsfunctions

about

nx_iot_hub_serve.nx -- the sovereign IoT HUB HTTP server (killer-feature rung 3). Operator vision: manage the house's IoT entirely from the FIRST-PARTY NISHI BROWSER, LAN-only, available even with the internet out. This is the always-on hub surface: it renders the zero-JS dashboard (nx_iot_dashboard) on GET / and accepts the control POSTs on /home/cmd -- all over the LAN, no cloud. Composes the proven nx_http_server (bind/listen/accept + parse + respond) so there is NO new protocol code. Like nx_vizsla_serve: a bare run prints usage; `serve <port>` runs the accept loop; `handle <reqfile>` processes one captured request (GATEABLE without sockets). Rung 2 will wire /home/cmd to the Nishi Tuya-LAN client (TCP/6668 + AES + local_key). For now the command is parsed + acknowledged (303-style 200) so the full browser->hub loop is provable today. license_tier: ORIGINAL

dependencies 2 imports · 1 importers

nx_http_server.nx nx_iot_dashboard.nx nx_iot_hub_serve.nx nx_iot_hub_serve_gate.nx

imports: nx_http_server.nxnx_iot_dashboard.nx

imported by: nx_iot_hub_serve_gate.nx

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main hub_puts db_render cp_head cp_cat db_card nx_iot_cap_for_class cp_cat ↻ db_badge cp_cat ↻ cp_catn sys_mmap cp_widgets nx_iot_cap_has cp_cmd_open cp_cat ↻ cp_cat ↻ cp_catn ↻ cp_foot cp_cat ↻ nx_http_server_addr_any nx_http_server_make_sockad nx_http_server_listen sys_ignore_sigpipe sys_mmap ↻ sys_socket sys_mmap ↻ sys_setsockopt sys_bind sys_close sys_listen nxs_verdict_name

structs

none

consts

15const HUB_MAGIC_18099: i64 = 18099
17const HUB_REQ_CAP: i64 = 8192
18const HUB_PAGE_CAP: i64 = 262144

functions

20func hub_puts(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } sys_write(1, s, n); return 0 }
23func hub_match(req: *u8, off: i64, len: i64, lit: *u8) -> i64
34func hub_ct_html(box: *u8) -> i64
42func hub_serve_client(cfd: i64, page: *u8, page_n: i64) -> i64
71func main(argc: i64, argv: *i64) -> i64