Describe interfaces with PROGMEM descriptor rows; drop the switch tables

AlexaInterfaces.h/.cpp hold one row per interface in program memory (28: namespace,
version, property names, flags, type), each row and string an object of its own, so
the linker keeps only the rows a sketch names. addCapability(AlexaInterfaceType) is
an always-inline switch that folds to one row; a type without a row is refused with
an error. The Event handler gets its type from the capabilities of the device.
Versions follow the interface pages (EndpointHealth 3.1, ThermostatController 3.2),
HumiditySensor is new, the two withdrawn interfaces and AlexaInterfaceUtils are gone.
Display category names are in flash. The discovery objects of the five examples are
unchanged: 14 new host tests compare them with what the previous commit announced.
basicLight on a D1 mini: static RAM 34,508 -> 30,788, flash 338,533 -> 330,509;
it links two rows, EndpointHealth and PowerController. Host tests: 47 -> 61.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
David 2026-09-28 19:04:14 +00:00
parent d534f23f27
commit 8b11cc2394
13 changed files with 909 additions and 777 deletions

View file

@ -1,7 +1,8 @@
; Development project of the library itself. A sketch does not need this file: it gets the library through
; lib_deps (readme.md, Quick Start).
;
; pio test -e native host tests of the bridge logic in src/AlexaBridgeLogic.cpp; no board, no broker
; pio test -e native host tests of the bridge logic (src/AlexaBridgeLogic.cpp) and of discovery
; (src/AlexaDevice.cpp, src/AlexaInterfaces.cpp); no board, no broker
[platformio]
default_envs = native
@ -11,7 +12,8 @@ platform = native
test_framework = unity
; Only the sources without a hardware dependency are compiled with the tests
test_build_src = yes
build_src_filter = -<*> +<AlexaBridgeLogic.cpp>
build_src_filter = -<*> +<AlexaBridgeLogic.cpp> +<AlexaDevice.cpp> +<AlexaInterfaces.cpp> +<AlexaLog.cpp>
lib_deps =
bblanchon/ArduinoJson@^7
build_flags = -std=gnu++17 -Wall -Wextra
; test/host_arduino holds the Arduino.h of the host: String, Print and Serial
build_flags = -std=gnu++17 -Wall -Wextra -Itest/host_arduino