feat(control-plane): show listening ui for ptt button

This commit is contained in:
chenjintao
2026-08-20 11:02:38 +08:00
parent 93f346a897
commit 045a803362
4 changed files with 58 additions and 27 deletions
@@ -63,7 +63,6 @@ typedef struct {
bool capture_owned;
bool prompt_pending;
bool prompt_playing;
bool listening_ui_active;
TickType_t prompt_wait_started_tick;
uint32_t detection_generation;
} local_wake_state_t;
@@ -88,21 +87,6 @@ static void local_wake_set_capture_owned(bool owned)
portEXIT_CRITICAL(&s_local_wake_lock);
}
static void local_wake_request_expression(domain_expression_id_t id)
{
const domain_expression_request_t request = {
.id = id,
.trigger = DOMAIN_EXPRESSION_TRIGGER_LOCAL_WAKE,
};
esp_err_t err = domain_runtime_request_expression(&request);
if (err != ESP_OK && err != ESP_ERR_INVALID_STATE) {
ESP_LOGW(TAG,
"Local wake expression request failed: id=%d err=%s",
(int)id,
esp_err_to_name(err));
}
}
bool control_plane_local_wake_prompt_gate_active(void)
{
#if CONFIG_TQ_LOCAL_WAKE_ENABLE && CONFIG_TQ_LOCAL_WAKE_RESPONSE_PROMPT_ENABLE
@@ -315,7 +299,6 @@ static void local_wake_handle_detection(
return;
}
s_local_wake.paused_for_foreground = true;
s_local_wake.listening_ui_active = true;
s_local_wake.detection_generation = event->detection_generation;
#if CONFIG_TQ_LOCAL_WAKE_RESPONSE_PROMPT_ENABLE
s_local_wake.prompt_pending = CONFIG_TQ_LOCAL_WAKE_RESPONSE_PROMPT_FILE[0] != '\0';
@@ -324,7 +307,6 @@ static void local_wake_handle_detection(
#endif
portEXIT_CRITICAL(&s_local_wake_lock);
local_wake_request_expression(DOMAIN_EXPRESSION_LISTENING);
ESP_LOGI(TAG,
"Local wake foreground entered: generation=%u listening_ui=1 prompt_gate=%d ready_timeout_ms=%u",
(unsigned)event->detection_generation,
@@ -340,7 +322,7 @@ static void local_wake_handle_detection(
(unsigned)event->confidence_x10000,
(unsigned)event->detection_generation);
control_plane_set_ptt_active(true);
control_plane_set_ptt_active_from_local_wake();
}
static void local_wake_task(void *arg)
@@ -437,7 +419,6 @@ esp_err_t control_plane_local_wake_start(void)
s_local_wake.capture_owned = false;
s_local_wake.prompt_pending = false;
s_local_wake.prompt_playing = false;
s_local_wake.listening_ui_active = false;
s_local_wake.prompt_wait_started_tick = 0U;
s_local_wake.detection_generation = 0U;
s_local_wake.started = true;
@@ -532,19 +513,13 @@ void control_plane_local_wake_pause_for_foreground(void)
void control_plane_local_wake_resume_after_foreground(void)
{
#if CONFIG_TQ_LOCAL_WAKE_ENABLE
bool restore_idle_ui = false;
portENTER_CRITICAL(&s_local_wake_lock);
s_local_wake.paused_for_foreground = false;
s_local_wake.prompt_pending = false;
s_local_wake.prompt_playing = false;
s_local_wake.prompt_wait_started_tick = 0U;
restore_idle_ui = s_local_wake.listening_ui_active;
s_local_wake.listening_ui_active = false;
TaskHandle_t task = s_local_wake.task;
portEXIT_CRITICAL(&s_local_wake_lock);
if (restore_idle_ui) {
local_wake_request_expression(DOMAIN_EXPRESSION_IDLE);
}
if (task != NULL) {
xTaskNotifyGive(task);
}