AlexaDevice: capability array, linked list, a directive handler with the device in hand
onDirective(handler) registers void handler(AlexaDirective&): the directive comes with its device, the capability it is for, namespace, name, instance, correlationToken and payload, and response() and stateReport() build the answer, so one function serves several devices. registerEvent() is kept; the five examples compile unchanged and announce the same discovery objects. Devices are a linked list on the bridge and a device holds ALEX2ESP_MAX_CAPABILITIES (8) capability pointers in place of two std::deque; one capability more is refused with an error. A device without a handler, and a handler that sends nothing for a capability the device lacks, are answered with the ErrorResponse INVALID_DIRECTIVE instead of a timeout. A directive whose endpointId is not a device of the sketch is ignored at DEBUG. basicLight on a D1 mini: static RAM 30,672 -> 30,600 B, flash 332,541 -> 333,437 B, 0 warnings in the five examples; 88 host tests (11 new, test/test_dispatch). Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
parent
7afc4346e8
commit
d3e7ee7f2a
10 changed files with 767 additions and 67 deletions
|
|
@ -1,8 +1,9 @@
|
|||
; 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 (src/AlexaBridgeLogic.cpp) and of discovery
|
||||
; (src/AlexaDevice.cpp, src/AlexaCapability.cpp, src/AlexaInterfaces.cpp); no board, no broker
|
||||
; pio test -e native host tests of the bridge logic (src/AlexaBridgeLogic.cpp), of discovery and of dispatch
|
||||
; (src/AlexaDevice.cpp, src/AlexaCapability.cpp, src/AlexaInterfaces.cpp,
|
||||
; src/AlexaStatusMessage.cpp); no board, no broker
|
||||
|
||||
[platformio]
|
||||
default_envs = native
|
||||
|
|
@ -12,7 +13,7 @@ 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> +<AlexaCapability.cpp> +<AlexaDevice.cpp> +<AlexaInterfaces.cpp> +<AlexaLog.cpp>
|
||||
build_src_filter = -<*> +<AlexaBridgeLogic.cpp> +<AlexaCapability.cpp> +<AlexaDevice.cpp> +<AlexaInterfaces.cpp> +<AlexaLog.cpp> +<AlexaStatusMessage.cpp>
|
||||
lib_deps =
|
||||
bblanchon/ArduinoJson@^7
|
||||
; test/host_arduino holds the Arduino.h of the host: String, Print and Serial
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue