fix(connectivity): harden BLE reprovisioning under memory pressure

This commit is contained in:
chenjintao
2026-08-25 14:09:44 +08:00
parent 140e90447c
commit 6495f0e107
6 changed files with 323 additions and 58 deletions
@@ -105,22 +105,37 @@ static esp_err_t app_composition_run_plan_a_boot_sequence(void)
esp_err_to_name(battery_guard_err));
}
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));
bool provisioning_recovery_boot =
control_plane_take_mini_program_recovery_boot_request();
if (provisioning_recovery_boot) {
app_composition_log_stage_skipped(APP_COMPOSITION_BOOT_STAGE_AUDIO_INIT,
"audio_init",
"ble_recovery_boot");
app_composition_log_stage_skipped(APP_COMPOSITION_BOOT_STAGE_BOOT_SOUND,
"boot_sound",
"ble_recovery_boot");
app_composition_log_stage_skipped(APP_COMPOSITION_BOOT_STAGE_AUDIO_READY,
"audio_ready",
"ble_recovery_boot");
} else {
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_READY,
"audio_ready",
"boot_sound_policy_end_keep_runtime");
}
app_composition_log_stage(APP_COMPOSITION_BOOT_STAGE_AUDIO_READY,
"audio_ready",
"boot_sound_policy_end_keep_runtime");
#if CONFIG_TQ_SCREEN_ENABLE
app_composition_log_stage(APP_COMPOSITION_BOOT_STAGE_LCD_DEVICE,
@@ -131,7 +146,7 @@ static esp_err_t app_composition_run_plan_a_boot_sequence(void)
"lcd_device",
lcd_err);
bool lcd_ready = (lcd_err == ESP_OK);
if (lcd_ready) {
if (lcd_ready && !provisioning_recovery_boot) {
app_composition_log_stage(APP_COMPOSITION_BOOT_STAGE_LCD_RENDER_LOOP,
"lcd_render_loop",
"control_plane_start_lcd_render_worker");
@@ -142,10 +157,14 @@ static esp_err_t app_composition_run_plan_a_boot_sequence(void)
if (lcd_worker_err != ESP_OK) {
lcd_ready = false;
}
} else {
} else if (!lcd_ready) {
app_composition_log_stage_skipped(APP_COMPOSITION_BOOT_STAGE_LCD_RENDER_LOOP,
"lcd_render_loop",
"lcd_device_unavailable");
} else {
app_composition_log_stage_skipped(APP_COMPOSITION_BOOT_STAGE_LCD_RENDER_LOOP,
"lcd_render_loop",
"ble_recovery_boot");
}
#else
app_composition_log_stage_skipped(APP_COMPOSITION_BOOT_STAGE_LCD_DEVICE,
@@ -173,15 +192,17 @@ static esp_err_t app_composition_run_plan_a_boot_sequence(void)
}
#if CONFIG_TQ_FACTORY_CLI_ENABLE
err = control_plane_factory_cli_start();
if (err != ESP_OK) {
ESP_LOGE(TAG, "Factory CLI start failed: %s", esp_err_to_name(err));
return err;
if (!provisioning_recovery_boot) {
err = control_plane_factory_cli_start();
if (err != ESP_OK) {
ESP_LOGE(TAG, "Factory CLI start failed: %s", esp_err_to_name(err));
return err;
}
}
#endif
#if CONFIG_TQ_SCREEN_ENABLE
if (lcd_ready) {
if (lcd_ready && !provisioning_recovery_boot) {
esp_err_t expression_err = control_plane_request_boot_expression();
if (expression_err != ESP_OK) {
ESP_LOGW(TAG,
@@ -192,14 +213,21 @@ static esp_err_t app_composition_run_plan_a_boot_sequence(void)
#endif
#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));
if (provisioning_recovery_boot) {
app_composition_log_stage_skipped(
APP_COMPOSITION_BOOT_STAGE_TURNTABLE_CALIBRATION,
"turntable_calibration",
"ble_recovery_boot");
} else {
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,