fix(multimodal): recover cloud draw pending state
This commit is contained in:
@@ -45,6 +45,7 @@
|
||||
#define CONTROL_PLANE_SERVER_SUCCESS_PROMPT_RETRY_MS 1000U
|
||||
#define CONTROL_PLANE_SERVER_SUCCESS_PROMPT_MAX_ATTEMPTS 3U
|
||||
#define CONTROL_PLANE_CLOUD_CHOUQIAN_PREPARE_TIMEOUT_MS 10000U
|
||||
#define CONTROL_PLANE_CLOUD_CHOUQIAN_RESPONSE_TIMEOUT_MS 60000U
|
||||
|
||||
#ifndef CONFIG_TQ_NETWORK_TASK_CORE
|
||||
#define CONFIG_TQ_NETWORK_TASK_CORE 0
|
||||
@@ -360,6 +361,27 @@ static void control_plane_clear_cloud_chouqian_pending(const char *reason)
|
||||
}
|
||||
}
|
||||
|
||||
static void control_plane_clear_interrupted_cloud_chouqian(void)
|
||||
{
|
||||
bool was_interrupted = false;
|
||||
|
||||
portENTER_CRITICAL(&s_multimodal_runtime_lock);
|
||||
if (s_cloud_chouqian_pending &&
|
||||
s_cloud_chouqian_prompt_sent &&
|
||||
!s_cloud_chouqian_action_in_progress) {
|
||||
was_interrupted = true;
|
||||
s_cloud_chouqian_pending = false;
|
||||
s_cloud_chouqian_action_in_progress = false;
|
||||
s_cloud_chouqian_prompt_sent = false;
|
||||
s_cloud_chouqian_requested_ms = 0U;
|
||||
}
|
||||
portEXIT_CRITICAL(&s_multimodal_runtime_lock);
|
||||
|
||||
if (was_interrupted) {
|
||||
ESP_LOGI(TAG, "Cloud chouqian request completed: response interrupted");
|
||||
}
|
||||
}
|
||||
|
||||
static void control_plane_set_model_command_callback(control_plane_model_command_callback_t cb,
|
||||
void *user_data)
|
||||
{
|
||||
@@ -465,13 +487,21 @@ static void control_plane_try_cloud_chouqian_request(void)
|
||||
requested_ms = s_cloud_chouqian_requested_ms;
|
||||
portEXIT_CRITICAL(&s_multimodal_runtime_lock);
|
||||
|
||||
if (!pending || prompt_sent) {
|
||||
if (!pending) {
|
||||
return;
|
||||
}
|
||||
|
||||
uint32_t now_ms = control_plane_now_ms();
|
||||
if ((now_ms - requested_ms) >= CONTROL_PLANE_CLOUD_CHOUQIAN_PREPARE_TIMEOUT_MS) {
|
||||
control_plane_clear_cloud_chouqian_pending("session prepare timeout");
|
||||
uint32_t timeout_ms = prompt_sent ?
|
||||
CONTROL_PLANE_CLOUD_CHOUQIAN_RESPONSE_TIMEOUT_MS :
|
||||
CONTROL_PLANE_CLOUD_CHOUQIAN_PREPARE_TIMEOUT_MS;
|
||||
if ((now_ms - requested_ms) >= timeout_ms) {
|
||||
control_plane_clear_cloud_chouqian_pending(
|
||||
prompt_sent ? "response timeout" : "session prepare timeout");
|
||||
return;
|
||||
}
|
||||
|
||||
if (prompt_sent) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -500,6 +530,7 @@ static void control_plane_try_cloud_chouqian_request(void)
|
||||
s_cloud_chouqian_action_in_progress = true;
|
||||
if (should_send_prompt) {
|
||||
s_cloud_chouqian_prompt_sent = true;
|
||||
s_cloud_chouqian_requested_ms = now_ms;
|
||||
}
|
||||
portEXIT_CRITICAL(&s_multimodal_runtime_lock);
|
||||
|
||||
@@ -873,6 +904,7 @@ static void control_plane_multimodal_event_bridge(control_plane_multimodal_event
|
||||
break;
|
||||
|
||||
case CONTROL_PLANE_MULTIMODAL_EVENT_SERVER_LISTENING:
|
||||
control_plane_clear_interrupted_cloud_chouqian();
|
||||
control_plane_wake_multimodal_watchdog();
|
||||
break;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user