按键系统待测
This commit is contained in:
@@ -12,42 +12,99 @@
|
||||
#include "esp_log.h"
|
||||
#include "sdkconfig.h"
|
||||
|
||||
#ifndef CONFIG_TQ_BOOT_SEQUENCE_DRY_RUN
|
||||
#define CONFIG_TQ_BOOT_SEQUENCE_DRY_RUN 1
|
||||
#endif
|
||||
|
||||
static const char *TAG = "app_comp_boot";
|
||||
|
||||
#if CONFIG_TQ_BOOT_TURNTABLE_CALIBRATION_ENABLE
|
||||
static void app_composition_run_boot_turntable_calibration(void)
|
||||
typedef enum {
|
||||
APP_COMPOSITION_BOOT_STAGE_POWER_HOLD = 1,
|
||||
APP_COMPOSITION_BOOT_STAGE_AUDIO_INIT,
|
||||
APP_COMPOSITION_BOOT_STAGE_BOOT_SOUND,
|
||||
APP_COMPOSITION_BOOT_STAGE_AUDIO_RELEASE,
|
||||
APP_COMPOSITION_BOOT_STAGE_LCD_DEVICE,
|
||||
APP_COMPOSITION_BOOT_STAGE_LCD_RENDER_LOOP,
|
||||
APP_COMPOSITION_BOOT_STAGE_BOOT_EXPRESSION,
|
||||
APP_COMPOSITION_BOOT_STAGE_PLATFORM_DOMAIN,
|
||||
APP_COMPOSITION_BOOT_STAGE_TURNTABLE_CALIBRATION,
|
||||
APP_COMPOSITION_BOOT_STAGE_STORAGE_PREPARE,
|
||||
APP_COMPOSITION_BOOT_STAGE_WIFI_BOOTSTRAP,
|
||||
APP_COMPOSITION_BOOT_STAGE_RUNTIME_WORKERS,
|
||||
APP_COMPOSITION_BOOT_STAGE_NETWORK_SERVICES,
|
||||
} app_composition_boot_stage_t;
|
||||
|
||||
static void app_composition_log_stage(app_composition_boot_stage_t stage,
|
||||
const char *name,
|
||||
const char *event)
|
||||
{
|
||||
ESP_LOGI(TAG, "Starting boot turntable calibration");
|
||||
|
||||
esp_err_t err = control_plane_calibrate();
|
||||
if (err == ESP_OK) {
|
||||
ESP_LOGI(TAG, "Boot turntable calibration completed");
|
||||
return;
|
||||
}
|
||||
|
||||
ESP_LOGW(TAG, "Boot turntable calibration failed: %s", esp_err_to_name(err));
|
||||
ESP_LOGI(TAG, "boot stage %02d %-24s event=%s", (int)stage, name, event);
|
||||
}
|
||||
#endif
|
||||
|
||||
static void app_composition_connect_wifi_for_boot(void)
|
||||
static void app_composition_log_stage_dry_run(app_composition_boot_stage_t stage,
|
||||
const char *name,
|
||||
const char *event)
|
||||
{
|
||||
esp_err_t err = control_plane_bootstrap_connectivity(CONFIG_MULTIMODAL_WIFI_SSID,
|
||||
CONFIG_MULTIMODAL_WIFI_PASSWORD,
|
||||
CONFIG_MULTIMODAL_CONNECT_TIMEOUT_MS,
|
||||
"TQ-CAT");
|
||||
ESP_LOGI(TAG, "boot stage %02d %-24s would_trigger=%s", (int)stage, name, event);
|
||||
}
|
||||
|
||||
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,
|
||||
"lcd_device",
|
||||
"initialize_lcd_device");
|
||||
app_composition_log_stage_dry_run(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,
|
||||
"boot_expression",
|
||||
"request_boot_default_expression");
|
||||
|
||||
app_composition_log_stage(APP_COMPOSITION_BOOT_STAGE_PLATFORM_DOMAIN,
|
||||
"platform_domain",
|
||||
"control_plane_init");
|
||||
esp_err_t err = control_plane_init();
|
||||
if (err != ESP_OK) {
|
||||
ESP_LOGW(TAG, "Connectivity bootstrap failed: %s", esp_err_to_name(err));
|
||||
ESP_LOGE(TAG, "control_plane_init failed: %s", esp_err_to_name(err));
|
||||
return err;
|
||||
}
|
||||
}
|
||||
|
||||
static void app_composition_run_boot_orchestration(void)
|
||||
{
|
||||
#if CONFIG_TQ_BOOT_TURNTABLE_CALIBRATION_ENABLE
|
||||
app_composition_run_boot_turntable_calibration();
|
||||
#else
|
||||
ESP_LOGI(TAG, "Boot turntable calibration disabled by configuration");
|
||||
#endif
|
||||
app_composition_connect_wifi_for_boot();
|
||||
app_composition_log_stage_dry_run(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");
|
||||
|
||||
app_composition_log_stage(APP_COMPOSITION_BOOT_STAGE_RUNTIME_WORKERS,
|
||||
"runtime_workers",
|
||||
"start_event_observer_runtime");
|
||||
err = control_plane_start_event_observer_runtime();
|
||||
if (err != ESP_OK) {
|
||||
ESP_LOGE(TAG, "event observer runtime 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");
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t app_composition_start_default_runtime(void)
|
||||
@@ -57,42 +114,15 @@ esp_err_t app_composition_start_default_runtime(void)
|
||||
setvbuf(stderr, NULL, _IONBF, 0);
|
||||
|
||||
ESP_LOGI(TAG, "========================================");
|
||||
ESP_LOGI(TAG, " App Composition Boot");
|
||||
ESP_LOGI(TAG, " App Composition Boot Plan A");
|
||||
ESP_LOGI(TAG, " dry_run=%d", CONFIG_TQ_BOOT_SEQUENCE_DRY_RUN);
|
||||
ESP_LOGI(TAG, "========================================");
|
||||
|
||||
#if CONFIG_TQ_SCREEN_ENABLE
|
||||
esp_err_t lcd_err = control_plane_init_lcd_device();
|
||||
if (lcd_err != ESP_OK) {
|
||||
ESP_LOGW(TAG, "LCD init failed: %s", esp_err_to_name(lcd_err));
|
||||
}
|
||||
#if CONFIG_TQ_BOOT_SEQUENCE_DRY_RUN
|
||||
return app_composition_run_plan_a_boot_sequence();
|
||||
#else
|
||||
ESP_LOGI(TAG, "LCD init disabled by configuration");
|
||||
ESP_LOGE(TAG, "Non-dry-run Plan A boot is not enabled in this refactor phase");
|
||||
return ESP_ERR_NOT_SUPPORTED;
|
||||
#endif
|
||||
|
||||
esp_err_t err = control_plane_init();
|
||||
if (err != ESP_OK) {
|
||||
ESP_LOGE(TAG, "Start default runtime failed: %s", esp_err_to_name(err));
|
||||
return err;
|
||||
}
|
||||
|
||||
esp_err_t cli_err = control_plane_factory_cli_start();
|
||||
if (cli_err != ESP_OK) {
|
||||
ESP_LOGW(TAG, "Factory serial CLI start failed: %s", esp_err_to_name(cli_err));
|
||||
}
|
||||
|
||||
err = control_plane_prepare_runtime_storage();
|
||||
if (err != ESP_OK) {
|
||||
ESP_LOGE(TAG, "Start default runtime failed: %s", esp_err_to_name(err));
|
||||
return err;
|
||||
}
|
||||
|
||||
app_composition_run_boot_orchestration();
|
||||
|
||||
err = control_plane_start_runtime_workers();
|
||||
if (err != ESP_OK) {
|
||||
ESP_LOGE(TAG, "Start default runtime failed: %s", esp_err_to_name(err));
|
||||
return err;
|
||||
}
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user