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:
2026-07-11 19:27:26 +03:00
parent 0c0883480d
commit b3e09d991d
12 changed files with 792 additions and 14 deletions

View File

@@ -1,6 +1,6 @@
# Makefile for Ballu AC ESP32-C6 Controller
.PHONY: all build test clean test-uart test-midea-protocol test-zigbee-zcl test-integration-layer test-status-monitor help
.PHONY: all build test clean test-uart test-midea-protocol test-zigbee-zcl test-integration-layer test-status-monitor test-app-controller help
# Directories
SRC_DIR := src
@@ -15,6 +15,9 @@ TEST_FILES := $(wildcard $(TEST_DIR)/*_test.c)
# Compiler settings
CC := gcc
CFLAGS := -Wall -Wextra -std=c99 -I$(SRC_DIR) -I$(UNITY_DIR)/src
# Test builds link every src/*.c together, so main()'s entry point must be
# excluded to avoid clashing with each test's own main().
TEST_CFLAGS := $(CFLAGS) -DUNIT_TEST
LDFLAGS :=
# Unity test framework
@@ -31,29 +34,33 @@ $(BUILD_DIR)/app: $(SRC_FILES)
$(CC) $(CFLAGS) $^ -o $@ $(LDFLAGS)
# Build and run tests
test: test-uart test-midea-protocol test-zigbee-zcl test-integration-layer test-status-monitor
test: test-uart test-midea-protocol test-zigbee-zcl test-integration-layer test-status-monitor test-app-controller
@echo "All tests passed!"
# Build individual test executables
$(TEST_DIR)/uart_driver_test: $(TEST_DIR)/uart_driver_test.c $(SRC_FILES) $(UNITY_SRC)
@mkdir -p $(BUILD_DIR)
$(CC) $(CFLAGS) $< $(SRC_FILES) $(UNITY_SRC) -o $@ $(LDFLAGS)
$(CC) $(TEST_CFLAGS) $< $(SRC_FILES) $(UNITY_SRC) -o $@ $(LDFLAGS)
$(TEST_DIR)/midea_protocol_test: $(TEST_DIR)/midea_protocol_test.c $(SRC_FILES) $(UNITY_SRC)
@mkdir -p $(BUILD_DIR)
$(CC) $(CFLAGS) $< $(SRC_FILES) $(UNITY_SRC) -o $@ $(LDFLAGS)
$(CC) $(TEST_CFLAGS) $< $(SRC_FILES) $(UNITY_SRC) -o $@ $(LDFLAGS)
$(TEST_DIR)/zigbee_zcl_test: $(TEST_DIR)/zigbee_zcl_test.c $(SRC_FILES) $(UNITY_SRC)
@mkdir -p $(BUILD_DIR)
$(CC) $(CFLAGS) $< $(SRC_FILES) $(UNITY_SRC) -o $@ $(LDFLAGS)
$(CC) $(TEST_CFLAGS) $< $(SRC_FILES) $(UNITY_SRC) -o $@ $(LDFLAGS)
$(TEST_DIR)/integration_layer_test: $(TEST_DIR)/integration_layer_test.c $(SRC_FILES) $(UNITY_SRC)
@mkdir -p $(BUILD_DIR)
$(CC) $(CFLAGS) $< $(SRC_FILES) $(UNITY_SRC) -o $@ $(LDFLAGS)
$(CC) $(TEST_CFLAGS) $< $(SRC_FILES) $(UNITY_SRC) -o $@ $(LDFLAGS)
$(TEST_DIR)/status_monitor_test: $(TEST_DIR)/status_monitor_test.c $(SRC_FILES) $(UNITY_SRC)
@mkdir -p $(BUILD_DIR)
$(CC) $(CFLAGS) $< $(SRC_FILES) $(UNITY_SRC) -o $@ $(LDFLAGS)
$(CC) $(TEST_CFLAGS) $< $(SRC_FILES) $(UNITY_SRC) -o $@ $(LDFLAGS)
$(TEST_DIR)/app_controller_test: $(TEST_DIR)/app_controller_test.c $(SRC_FILES) $(UNITY_SRC)
@mkdir -p $(BUILD_DIR)
$(CC) $(TEST_CFLAGS) $< $(SRC_FILES) $(UNITY_SRC) -o $@ $(LDFLAGS)
# Run individual tests
test-uart: $(TEST_DIR)/uart_driver_test
@@ -76,6 +83,10 @@ test-status-monitor: $(TEST_DIR)/status_monitor_test
@echo "Running status monitor tests..."
@./$(TEST_DIR)/status_monitor_test
test-app-controller: $(TEST_DIR)/app_controller_test
@echo "Running app controller (end-to-end) tests..."
@./$(TEST_DIR)/app_controller_test
# Clean build artifacts
clean:
rm -rf $(BUILD_DIR)
@@ -91,5 +102,7 @@ help:
@echo " test-midea-protocol - Run Midea protocol tests"
@echo " test-zigbee-zcl - Run Zigbee ZCL tests"
@echo " test-integration-layer - Run integration layer tests"
@echo " test-status-monitor - Run status monitor tests"
@echo " test-app-controller - Run end-to-end app controller tests"
@echo " clean - Clean build artifacts"
@echo " help - Show this help"