Add Lua runtime: chip temp -> LED color -> HA, verified live

Sandboxed Lua state (espressif/lua v5.5.0, base/table/string/math only,
no io/os/package/debug) exposes a kvida API table (chip_temperature,
set_led, publish) to a compiled-in default script that reads chip
temperature, maps it to an LED color, and publishes the reading to
Home Assistant. Generalizes transport's publish_chip_temperature()
into publish_value(name, value), the first real use of AGENTS.md's
semantic publish API. Requires -DLUA_32BITS globally since this
toolchain's long long support isn't visible to Lua's default build.

Verified on real ESP32-C6 hardware: no crashes/errors across multiple
serial monitor windows, LED changes color, chip_temperature sensor
appears in Home Assistant via MQTT Discovery.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Ronny Eia
2026-07-12 09:17:06 +02:00
parent 3fee19c60a
commit eae6d3af5a
12 changed files with 328 additions and 122 deletions

View File

@@ -1,7 +1,19 @@
cmake_minimum_required(VERSION 3.16)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(kvida_os)
cmake_minimum_required(VERSION 3.16)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
# The espressif/lua component's luaconf.h defaults to 64-bit
# (long long) Lua integers and errors out at compile time on this
# toolchain ("Compiler does not support 'long long'" -- LLONG_MAX isn't
# visible to it here, even though <limits.h> is included). Lua's own
# suggested fix for constrained/32-bit platforms: build with 32-bit
# integers/floats instead. Set globally (not just in lua_runtime's own
# CMakeLists.txt) so the Lua component's own .c files see the same
# definition -- otherwise its library and our calling code would
# disagree on the size of lua_Integer.
idf_build_set_property(COMPILE_DEFINITIONS "-DLUA_32BITS" APPEND)
project(kvida_os)