Files
wadamesh/scripts/lua-harness/cyberspace/host.cpp
T
Michael A. CojocariandClaude Opus 5.5 d1571d91ca lua: Cyberspace app, wada.net.request over verified https, wada.json, label:on_press
A client for cyberspace.online (cIRC rooms, C-Mail, the Feed) as a store app,
and the SDK pieces it needed:

- wada.net.request{url, method, headers, body, max}: any method, request
  headers, the real status code. https:// runs in a one-shot TLS task with the
  chain verified against the ISRG roots (CAP_LUA_HTTPS: off on the P4 boards,
  where TLS runs on the C6 unverified, and on the 2 MB Heltec V4).
- wada.json.decode/encode in C; 64-bit integers come back as exact text.
- label:on_press(fn): a label becomes a tap / long-press / cursor target.
- wada.store: get(key) with no default returned the store table for a missing
  key; flush wrote past its 192-byte line buffer; changes now reach the card
  within 2 s instead of only on close.

Host tests: test/test_lua_json.cpp and scripts/lua-harness/cyberspace/run.sh.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01He9DHEuLWYQHXVBnNzzD6E
2026-10-30 20:36:57 -04:00

26 lines
993 B
C++

// SPDX-License-Identifier: GPL-3.0-or-later
// Host runner for the Cyberspace app test: the vendored Lua (LUA_32BITS, as on
// the device) with the firmware's own wada.json codec (src/ui-touch/LuaJson.h)
// registered as the global JSON, then test.lua with its arguments.
#include "ui-touch/LuaJson.h"
extern "C" {
#include "lualib.h"
}
#include <stdio.h>
int main(int argc, char** argv) {
if (argc < 2) { fprintf(stderr, "usage: host test.lua app.lua [w h]\n"); return 2; }
lua_State* L = luaL_newstate();
luaL_openlibs(L);
lua_newtable(L);
lua_pushcfunction(L, luajson::decode); lua_setfield(L, -2, "decode");
lua_pushcfunction(L, luajson::encode); lua_setfield(L, -2, "encode");
lua_setglobal(L, "JSON");
lua_newtable(L);
for (int i = 2; i < argc; i++) { lua_pushstring(L, argv[i]); lua_rawseti(L, -2, i - 1); }
lua_setglobal(L, "arg");
if (luaL_dofile(L, argv[1]) != LUA_OK) { fprintf(stderr, "%s\n", lua_tostring(L, -1)); return 1; }
lua_close(L);
return 0;
}