wangzhibo
2026-08-26 70481429367ca00144b24f118cbfdfb28b02967d
xiaozhi-esp32-2.2.6/main/application.h
@@ -10,6 +10,8 @@
#include <mutex>
#include <deque>
#include <memory>
#include <functional>
#include <atomic>
#include "protocol.h"
#include "ota.h"
@@ -105,8 +107,18 @@
    void Reboot();
    void WakeWordInvoke(const std::string& wake_word);
    bool UpgradeFirmware(const std::string& url, const std::string& version = "");
    bool UpgradeFirmware(const std::string& url, const std::string& version = "",
                         std::function<void(int progress, size_t speed)> progress_callback = nullptr,
                         std::function<void(bool success)> complete_callback = nullptr);
    void EnterStandby();
    void RequestPowerOffStandby();
    void EnterPowerOffStandby();
    void RestoreFromPowerOffStandby(bool network_ready);
    bool IsPowerOffStandby() const { return power_off_standby_active_.load(); }
    void AcquireSleepInhibit();
    void ReleaseSleepInhibit();
    bool CanEnterSleepMode();
    void PrepareProtocolForNetworkStandby();
    void SendMcpMessage(const std::string& payload);
    void SetAecMode(AecMode mode);
    AecMode GetAecMode() const { return aec_mode_; }
@@ -139,7 +151,24 @@
    bool has_server_time_ = false;
    bool aborted_ = false;
    bool assets_version_checked_ = false;
    bool local_assets_applied_ = false;
    bool play_popup_on_listening_ = false;  // Flag to play popup sound after state changes to listening
    bool resume_sdcard_mp3_after_tts_ = false;
    bool resume_sdcard_mp3_after_voice_ = false;
    bool sdcard_mp3_stop_requested_ = false;
    bool opening_audio_channel_ = false;
    bool tts_audio_expected_ = false;
    bool tts_response_started_ = false;
    bool tts_audio_received_ = false;
    bool tts_stop_pending_ = false;
    bool tts_stop_waiting_ = false;
    bool tts_idle_waiting_ = false;
    bool tts_speaking_state_ready_ = false;
    uint32_t tts_activity_generation_ = 0;
    bool standby_requested_ = false;
    bool power_off_requested_ = false;
    std::atomic_bool power_off_standby_active_{false};
    int sleep_inhibit_count_ = 0;
    int clock_ticks_ = 0;
    TaskHandle_t activation_task_handle_ = nullptr;
@@ -160,10 +189,17 @@
    void ActivationTask();
    // Helper methods
    void LoadLocalAssetsForWakeWord();
    void CheckAssetsVersion();
    void CheckNewVersion();
    void InitializeProtocol();
    void ShowActivationCode(const std::string& code, const std::string& message);
    void FinishTtsResponse();
    void FinishTtsResponseAfterPlayback();
    void ScheduleTtsAudio(std::shared_ptr<AudioStreamPacket> packet);
    void ScheduleTtsIdleFallback();
    void PauseSdCardMp3ForVoice();
    void ResumeSdCardMp3AfterVoice();
    void SetListeningMode(ListeningMode mode);
    ListeningMode GetDefaultListeningMode() const;