基本按键功能测试完成

This commit is contained in:
CSBOOK\44744
2026-06-25 13:37:12 +08:00
parent 84ecf892b5
commit ec2ad4dfc9
6 changed files with 207 additions and 232 deletions
@@ -10,10 +10,16 @@
#include "control_plane.h"
#include "esp_log.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "sdkconfig.h"
#ifndef CONFIG_TQ_BOOT_SEQUENCE_DRY_RUN
#define CONFIG_TQ_BOOT_SEQUENCE_DRY_RUN 1
#define CONFIG_TQ_BOOT_SEQUENCE_DRY_RUN 0
#endif
#ifndef CONFIG_TQ_BOOT_SOUND_TIMEOUT_MS
#define CONFIG_TQ_BOOT_SOUND_TIMEOUT_MS 3000
#endif
static const char *TAG = "app_comp_boot";
@@ -41,36 +47,82 @@ static void app_composition_log_stage(app_composition_boot_stage_t stage,
ESP_LOGI(TAG, "boot stage %02d %-24s event=%s", (int)stage, name, event);
}
static void app_composition_log_stage_dry_run(app_composition_boot_stage_t stage,
const char *name,
const char *event)
static void app_composition_log_stage_result(app_composition_boot_stage_t stage,
const char *name,
esp_err_t result)
{
ESP_LOGI(TAG, "boot stage %02d %-24s would_trigger=%s", (int)stage, name, event);
ESP_LOGI(TAG,
"boot stage %02d %-24s result=%s",
(int)stage,
name,
esp_err_to_name(result));
}
static void app_composition_log_stage_skipped(app_composition_boot_stage_t stage,
const char *name,
const char *reason)
{
ESP_LOGI(TAG, "boot stage %02d %-24s skipped=%s", (int)stage, name, reason);
}
static esp_err_t app_composition_run_plan_a_boot_sequence(void)
{
app_composition_log_stage_dry_run(APP_COMPOSITION_BOOT_STAGE_POWER_HOLD,
"power_hold",
"assert_power_hold_gpio");
app_composition_log_stage_dry_run(APP_COMPOSITION_BOOT_STAGE_AUDIO_INIT,
"audio_init",
"initialize_audio_path_with_timeout");
app_composition_log_stage_dry_run(APP_COMPOSITION_BOOT_STAGE_BOOT_SOUND,
"boot_sound",
"play_boot_sound_with_timeout");
app_composition_log_stage_dry_run(APP_COMPOSITION_BOOT_STAGE_AUDIO_RELEASE,
"audio_release",
"release_idle_audio_resources");
app_composition_log_stage_dry_run(APP_COMPOSITION_BOOT_STAGE_LCD_DEVICE,
app_composition_log_stage(APP_COMPOSITION_BOOT_STAGE_POWER_HOLD,
"power_hold",
"already_asserted_by_platform_core");
app_composition_log_stage(APP_COMPOSITION_BOOT_STAGE_AUDIO_INIT,
"audio_init",
"boot_sound_policy_begin");
app_composition_log_stage(APP_COMPOSITION_BOOT_STAGE_BOOT_SOUND,
"boot_sound",
"play_boot_sound_with_timeout");
esp_err_t boot_sound_err =
control_plane_play_boot_sound(CONFIG_TQ_BOOT_SOUND_TIMEOUT_MS);
if (boot_sound_err != ESP_OK) {
ESP_LOGW(TAG,
"Boot sound unavailable, continue boot: %s",
esp_err_to_name(boot_sound_err));
}
app_composition_log_stage(APP_COMPOSITION_BOOT_STAGE_AUDIO_RELEASE,
"audio_release",
"boot_sound_policy_end");
#if CONFIG_TQ_SCREEN_ENABLE
app_composition_log_stage(APP_COMPOSITION_BOOT_STAGE_LCD_DEVICE,
"lcd_device",
"control_plane_init_lcd_device");
esp_err_t lcd_err = control_plane_init_lcd_device();
app_composition_log_stage_result(APP_COMPOSITION_BOOT_STAGE_LCD_DEVICE,
"lcd_device",
lcd_err);
bool lcd_ready = (lcd_err == ESP_OK);
if (lcd_ready) {
app_composition_log_stage(APP_COMPOSITION_BOOT_STAGE_LCD_RENDER_LOOP,
"lcd_render_loop",
"deferred_to_runtime_worker_task");
app_composition_log_stage(APP_COMPOSITION_BOOT_STAGE_BOOT_EXPRESSION,
"boot_expression",
"deferred_until_runtime_worker_started");
} else {
app_composition_log_stage_skipped(APP_COMPOSITION_BOOT_STAGE_LCD_RENDER_LOOP,
"lcd_render_loop",
"lcd_device_unavailable");
app_composition_log_stage_skipped(APP_COMPOSITION_BOOT_STAGE_BOOT_EXPRESSION,
"boot_expression",
"lcd_device_unavailable");
}
#else
app_composition_log_stage_skipped(APP_COMPOSITION_BOOT_STAGE_LCD_DEVICE,
"lcd_device",
"initialize_lcd_device");
app_composition_log_stage_dry_run(APP_COMPOSITION_BOOT_STAGE_LCD_RENDER_LOOP,
"disabled_by_config");
app_composition_log_stage_skipped(APP_COMPOSITION_BOOT_STAGE_LCD_RENDER_LOOP,
"lcd_render_loop",
"start_lcd_render_loop");
app_composition_log_stage_dry_run(APP_COMPOSITION_BOOT_STAGE_BOOT_EXPRESSION,
"disabled_by_config");
app_composition_log_stage_skipped(APP_COMPOSITION_BOOT_STAGE_BOOT_EXPRESSION,
"boot_expression",
"request_boot_default_expression");
"disabled_by_config");
#endif
app_composition_log_stage(APP_COMPOSITION_BOOT_STAGE_PLATFORM_DOMAIN,
"platform_domain",
@@ -81,28 +133,67 @@ static esp_err_t app_composition_run_plan_a_boot_sequence(void)
return err;
}
app_composition_log_stage_dry_run(APP_COMPOSITION_BOOT_STAGE_TURNTABLE_CALIBRATION,
#if CONFIG_TQ_BOOT_TURNTABLE_CALIBRATION_ENABLE
app_composition_log_stage(APP_COMPOSITION_BOOT_STAGE_TURNTABLE_CALIBRATION,
"turntable_calibration",
"control_plane_calibrate");
esp_err_t calibration_err = control_plane_calibrate();
if (calibration_err != ESP_OK) {
ESP_LOGW(TAG,
"Boot turntable calibration failed, continue degraded: %s",
esp_err_to_name(calibration_err));
}
#else
app_composition_log_stage_skipped(APP_COMPOSITION_BOOT_STAGE_TURNTABLE_CALIBRATION,
"turntable_calibration",
"run_turntable_calibration_with_timeout");
app_composition_log_stage_dry_run(APP_COMPOSITION_BOOT_STAGE_STORAGE_PREPARE,
"storage_prepare",
"prepare_runtime_storage");
app_composition_log_stage_dry_run(APP_COMPOSITION_BOOT_STAGE_WIFI_BOOTSTRAP,
"wifi_bootstrap",
"start_wifi_sta_or_config_ap");
"disabled_by_config");
#endif
app_composition_log_stage(APP_COMPOSITION_BOOT_STAGE_RUNTIME_WORKERS,
"runtime_workers",
"start_event_observer_runtime");
err = control_plane_start_event_observer_runtime();
app_composition_log_stage(APP_COMPOSITION_BOOT_STAGE_STORAGE_PREPARE,
"storage_prepare",
"control_plane_prepare_runtime_storage");
err = control_plane_prepare_runtime_storage();
if (err != ESP_OK) {
ESP_LOGE(TAG, "event observer runtime failed: %s", esp_err_to_name(err));
ESP_LOGE(TAG, "Runtime storage prepare failed: %s", esp_err_to_name(err));
return err;
}
app_composition_log_stage_dry_run(APP_COMPOSITION_BOOT_STAGE_NETWORK_SERVICES,
"network_services",
"start_websocket_fortune_lan_http_after_network_ready");
app_composition_log_stage(APP_COMPOSITION_BOOT_STAGE_WIFI_BOOTSTRAP,
"wifi_bootstrap",
"control_plane_bootstrap_connectivity");
esp_err_t wifi_err = control_plane_bootstrap_connectivity(CONFIG_MULTIMODAL_WIFI_SSID,
CONFIG_MULTIMODAL_WIFI_PASSWORD,
CONFIG_MULTIMODAL_CONNECT_TIMEOUT_MS,
"TQ-CAT");
if (wifi_err != ESP_OK) {
ESP_LOGW(TAG, "Connectivity bootstrap failed: %s", esp_err_to_name(wifi_err));
}
app_composition_log_stage(APP_COMPOSITION_BOOT_STAGE_RUNTIME_WORKERS,
"runtime_workers",
"control_plane_start_runtime_workers");
err = control_plane_start_runtime_workers();
if (err != ESP_OK) {
ESP_LOGE(TAG, "Runtime worker start failed: %s", esp_err_to_name(err));
return err;
}
#if CONFIG_TQ_SCREEN_ENABLE
if (lcd_ready) {
vTaskDelay(pdMS_TO_TICKS(200));
app_composition_log_stage(APP_COMPOSITION_BOOT_STAGE_BOOT_EXPRESSION,
"boot_expression",
"control_plane_request_boot_expression");
esp_err_t expression_err = control_plane_request_boot_expression();
if (expression_err != ESP_OK) {
ESP_LOGW(TAG, "Boot expression request failed: %s", esp_err_to_name(expression_err));
}
}
#endif
app_composition_log_stage(APP_COMPOSITION_BOOT_STAGE_NETWORK_SERVICES,
"network_services",
"started_by_runtime_workers_after_readiness");
return ESP_OK;
}
@@ -119,10 +210,9 @@ esp_err_t app_composition_start_default_runtime(void)
ESP_LOGI(TAG, "========================================");
#if CONFIG_TQ_BOOT_SEQUENCE_DRY_RUN
return app_composition_run_plan_a_boot_sequence();
#else
ESP_LOGE(TAG, "Non-dry-run Plan A boot is not enabled in this refactor phase");
ESP_LOGE(TAG, "Plan A dry-run is enabled; disable CONFIG_TQ_BOOT_SEQUENCE_DRY_RUN");
return ESP_ERR_NOT_SUPPORTED;
#else
return app_composition_run_plan_a_boot_sequence();
#endif
}