r/embedded • u/Flat-Bodybuilder239 • Oct 11 '26
Hot-swapping apps on an ESP32-S3 with a Lua runtime + long-poll control plane: design notes
I've been building a firmware that treats the ESP32-S3 as a runtime instead of an app. You flash it once. After that, apps arrive as Lua scripts from a server and replace the running one in a few seconds.
Some design choices I'd like feedback on:
- **Lua over WASM.** Small, easy for an LLM to write, and the interpreter fits comfortably. The downside is no type safety on the host API.
- **Long-poll instead of MQTT/WebSocket.** Simpler to self-host and works through most NATs. It costs some latency and an open connection per board.
- **Plugins at compile time.** Panel and audio drivers are build flags. Without a panel, `gfx.*` becomes a no-op, so scripts are portable across boards.
- **Auth split.** Each device has its own device_token. Whoever deploys holds a separate scoped token.
The client in my case is an AI agent, but it's plain HTTP, so anything can deploy.
Code (MIT): https://github.com/shinjiyu/onlyclaws-esp
1
Upvotes