feat: end-to-end app controller integration and tests
Add app_controller wiring UART, integration, status monitor and Zigbee ZCL layers together with command/feedback flows and reset/recovery. Add main.c entry point (guarded for test builds), app_controller_test integration tests (full command cycle, timing under load, recovery), Makefile target, and Readme updates. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
33
Readme.md
33
Readme.md
@@ -13,6 +13,7 @@ This project implements a bridge between Zigbee (Home Assistant) and UART-based
|
||||
- Bidirectional communication between Zigbee and UART layers
|
||||
- Status monitoring with periodic AC polling, fault detection, and a communication watchdog
|
||||
- Configurable timing controls (50ms command spacing)
|
||||
- End-to-end application controller wiring all layers together with reset/recovery
|
||||
|
||||
## Directory Structure
|
||||
|
||||
@@ -23,6 +24,7 @@ src/
|
||||
zigbee_zcl.c/h - Zigbee ZCL Thermostat cluster
|
||||
integration_layer.c/h- Integration between Zigbee and UART layers
|
||||
status_monitor.c/h - AC status polling, fault detection, and comms watchdog
|
||||
app_controller.c/h - End-to-end controller wiring all layers + reset/recovery
|
||||
main.c - Application entry point
|
||||
|
||||
test/
|
||||
@@ -31,6 +33,7 @@ test/
|
||||
zigbee_zcl_test.c - Unit tests for Zigbee ZCL
|
||||
integration_layer_test.c - Unit tests for integration layer
|
||||
status_monitor_test.c - Unit tests for status monitoring
|
||||
app_controller_test.c - End-to-end integration tests (full command cycles)
|
||||
|
||||
docs/
|
||||
protocol.md - MideaUART protocol details
|
||||
@@ -81,6 +84,36 @@ The `status_monitor` module (see `src/status_monitor.c/h`) provides:
|
||||
Configuration (`status_monitor_config_t`) exposes `poll_interval_ms` (default
|
||||
5000ms), `timeout_ms` (default 1000ms), and `max_retries` (default 3).
|
||||
|
||||
## End-to-End Integration
|
||||
|
||||
The `app_controller` module (see `src/app_controller.c/h`) ties every layer
|
||||
together and drives the two full data flows:
|
||||
|
||||
- Command path (HA → Zigbee → Integration → UART → AC):
|
||||
`app_controller_process_zigbee_command()` forwards an incoming Zigbee command
|
||||
through the integration layer, which encodes and transmits the corresponding
|
||||
MideaUART frame with 50ms rate limiting.
|
||||
- Feedback path (AC → UART → Status → Integration → Zigbee → HA):
|
||||
`app_controller_process_ac_status()` decodes a MideaUART status frame, runs
|
||||
fault detection / watchdog bookkeeping, and publishes the result to the ZCL
|
||||
Thermostat cluster for Home Assistant to read.
|
||||
|
||||
Reset and recovery:
|
||||
|
||||
- `app_controller_reset()` re-initializes UART and integration state and clears
|
||||
status-monitor error counters without dropping configuration.
|
||||
- `app_controller_recover_if_needed()` performs a reset automatically when the
|
||||
communication watchdog trips (retries exhausted or poll window exceeded).
|
||||
- `app_controller_is_healthy()` reports comms liveness plus fault state.
|
||||
|
||||
`src/main.c` provides the firmware entry point and service loop. Its `main()` is
|
||||
compiled only for the firmware build; unit-test binaries define `UNIT_TEST` and
|
||||
supply their own `main()`.
|
||||
|
||||
Integration tests in `test/app_controller_test.c` exercise full command cycles,
|
||||
including a HA→…→AC→…→HA round trip, timing under a 100-command burst, and the
|
||||
reset/recovery paths.
|
||||
|
||||
## Implementation Progress
|
||||
|
||||
See `docs/plans/2026-07-05-ballu-ac-esp32c6-controller-implementation.md` for detailed implementation plan and progress tracking.
|
||||
|
||||
Reference in New Issue
Block a user