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>
20 lines
956 B
INI
20 lines
956 B
INI
; 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), 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
|
|
|
|
[env:native]
|
|
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> +<AlexaStatusMessage.cpp>
|
|
lib_deps =
|
|
bblanchon/ArduinoJson@^7
|
|
; test/host_arduino holds the Arduino.h of the host: String, Print and Serial
|
|
build_flags = -std=gnu++17 -Wall -Wextra -Itest/host_arduino
|