forked from xiaozhi/xiaozhi-esp32
set power safe mode
This commit is contained in:
@@ -4,7 +4,7 @@
|
|||||||
# CMakeLists in this exact order for cmake to work correctly
|
# CMakeLists in this exact order for cmake to work correctly
|
||||||
cmake_minimum_required(VERSION 3.16)
|
cmake_minimum_required(VERSION 3.16)
|
||||||
|
|
||||||
set(PROJECT_VER "0.8.1")
|
set(PROJECT_VER "0.8.2")
|
||||||
|
|
||||||
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||||
project(xiaozhi)
|
project(xiaozhi)
|
||||||
|
|||||||
@@ -275,17 +275,19 @@ void Application::Start() {
|
|||||||
audio_decode_queue_.emplace_back(std::move(data));
|
audio_decode_queue_.emplace_back(std::move(data));
|
||||||
cv_.notify_all();
|
cv_.notify_all();
|
||||||
});
|
});
|
||||||
protocol_->OnAudioChannelOpened([this, codec]() {
|
protocol_->OnAudioChannelOpened([this, codec, &board]() {
|
||||||
if (protocol_->GetServerSampleRate() != codec->output_sample_rate()) {
|
if (protocol_->GetServerSampleRate() != codec->output_sample_rate()) {
|
||||||
ESP_LOGW(TAG, "服务器的音频采样率 %d 与设备输出的采样率 %d 不一致,重采样后可能会失真",
|
ESP_LOGW(TAG, "服务器的音频采样率 %d 与设备输出的采样率 %d 不一致,重采样后可能会失真",
|
||||||
protocol_->GetServerSampleRate(), codec->output_sample_rate());
|
protocol_->GetServerSampleRate(), codec->output_sample_rate());
|
||||||
}
|
}
|
||||||
SetDecodeSampleRate(protocol_->GetServerSampleRate());
|
SetDecodeSampleRate(protocol_->GetServerSampleRate());
|
||||||
|
board.SetPowerSaveMode(false);
|
||||||
});
|
});
|
||||||
protocol_->OnAudioChannelClosed([this]() {
|
protocol_->OnAudioChannelClosed([this, &board]() {
|
||||||
Schedule([this]() {
|
Schedule([this]() {
|
||||||
SetChatState(kChatStateIdle);
|
SetChatState(kChatStateIdle);
|
||||||
});
|
});
|
||||||
|
board.SetPowerSaveMode(true);
|
||||||
});
|
});
|
||||||
protocol_->OnIncomingJson([this](const cJSON* root) {
|
protocol_->OnIncomingJson([this](const cJSON* root) {
|
||||||
// Parse JSON data
|
// Parse JSON data
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ public:
|
|||||||
virtual bool GetNetworkState(std::string& network_name, int& signal_quality, std::string& signal_quality_text) = 0;
|
virtual bool GetNetworkState(std::string& network_name, int& signal_quality, std::string& signal_quality_text) = 0;
|
||||||
virtual bool GetBatteryLevel(int &level, bool& charging);
|
virtual bool GetBatteryLevel(int &level, bool& charging);
|
||||||
virtual std::string GetJson();
|
virtual std::string GetJson();
|
||||||
|
virtual void SetPowerSaveMode(bool enabled) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define DECLARE_BOARD(BOARD_CLASS_NAME) \
|
#define DECLARE_BOARD(BOARD_CLASS_NAME) \
|
||||||
|
|||||||
@@ -114,3 +114,7 @@ std::string Ml307Board::GetBoardJson() {
|
|||||||
board_json += "\"iccid\":\"" + modem_.GetIccid() + "\"}";
|
board_json += "\"iccid\":\"" + modem_.GetIccid() + "\"}";
|
||||||
return board_json;
|
return board_json;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Ml307Board::SetPowerSaveMode(bool enabled) {
|
||||||
|
// TODO: Implement power save mode for ML307
|
||||||
|
}
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ public:
|
|||||||
virtual Mqtt* CreateMqtt() override;
|
virtual Mqtt* CreateMqtt() override;
|
||||||
virtual Udp* CreateUdp() override;
|
virtual Udp* CreateUdp() override;
|
||||||
virtual bool GetNetworkState(std::string& network_name, int& signal_quality, std::string& signal_quality_text) override;
|
virtual bool GetNetworkState(std::string& network_name, int& signal_quality, std::string& signal_quality_text) override;
|
||||||
|
virtual void SetPowerSaveMode(bool enabled) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // ML307_BOARD_H
|
#endif // ML307_BOARD_H
|
||||||
|
|||||||
@@ -114,3 +114,8 @@ std::string WifiBoard::GetBoardJson() {
|
|||||||
board_json += "\"mac\":\"" + SystemInfo::GetMacAddress() + "\"}";
|
board_json += "\"mac\":\"" + SystemInfo::GetMacAddress() + "\"}";
|
||||||
return board_json;
|
return board_json;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WifiBoard::SetPowerSaveMode(bool enabled) {
|
||||||
|
auto& wifi_station = WifiStation::GetInstance();
|
||||||
|
wifi_station.SetPowerSaveMode(enabled);
|
||||||
|
}
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ public:
|
|||||||
virtual Mqtt* CreateMqtt() override;
|
virtual Mqtt* CreateMqtt() override;
|
||||||
virtual Udp* CreateUdp() override;
|
virtual Udp* CreateUdp() override;
|
||||||
virtual bool GetNetworkState(std::string& network_name, int& signal_quality, std::string& signal_quality_text) override;
|
virtual bool GetNetworkState(std::string& network_name, int& signal_quality, std::string& signal_quality_text) override;
|
||||||
|
virtual void SetPowerSaveMode(bool enabled) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // WIFI_BOARD_H
|
#endif // WIFI_BOARD_H
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
## IDF Component Manager Manifest File
|
## IDF Component Manager Manifest File
|
||||||
dependencies:
|
dependencies:
|
||||||
78/esp-wifi-connect: "~1.3.0"
|
78/esp-wifi-connect: "~1.4.0"
|
||||||
78/esp-opus-encoder: "~1.1.0"
|
78/esp-opus-encoder: "~1.1.0"
|
||||||
78/esp-ml307: "~1.6.0"
|
78/esp-ml307: "~1.6.0"
|
||||||
espressif/led_strip: "^2.4.1"
|
espressif/led_strip: "^2.4.1"
|
||||||
|
|||||||
@@ -169,7 +169,6 @@ void Ota::Upgrade(const std::string& firmware_url) {
|
|||||||
size_t total_read = 0, recent_read = 0;
|
size_t total_read = 0, recent_read = 0;
|
||||||
auto last_calc_time = esp_timer_get_time();
|
auto last_calc_time = esp_timer_get_time();
|
||||||
while (true) {
|
while (true) {
|
||||||
taskYIELD(); // Avoid watchdog timeout
|
|
||||||
int ret = http->Read(buffer.data(), buffer.size());
|
int ret = http->Read(buffer.data(), buffer.size());
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
ESP_LOGE(TAG, "Failed to read HTTP data: %s", esp_err_to_name(ret));
|
ESP_LOGE(TAG, "Failed to read HTTP data: %s", esp_err_to_name(ret));
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ CONFIG_USE_WAKENET=y
|
|||||||
CONFIG_SR_WN_WN9_NIHAOXIAOZHI_TTS=y
|
CONFIG_SR_WN_WN9_NIHAOXIAOZHI_TTS=y
|
||||||
CONFIG_USE_MULTINET=n
|
CONFIG_USE_MULTINET=n
|
||||||
|
|
||||||
|
ESP_TASK_WDT_TIMEOUT_S=10
|
||||||
CONFIG_FREERTOS_GENERATE_RUN_TIME_STATS=y
|
CONFIG_FREERTOS_GENERATE_RUN_TIME_STATS=y
|
||||||
CONFIG_FREERTOS_USE_STATS_FORMATTING_FUNCTIONS=y
|
CONFIG_FREERTOS_USE_STATS_FORMATTING_FUNCTIONS=y
|
||||||
|
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ def get_board_name(folder):
|
|||||||
return "bread-compact-wifi"
|
return "bread-compact-wifi"
|
||||||
elif "KevinBox1" in basename:
|
elif "KevinBox1" in basename:
|
||||||
return "kevin-box-1"
|
return "kevin-box-1"
|
||||||
if basename.startswith("v0.7"):
|
if basename.startswith("v0.7") or basename.startswith("v0.8"):
|
||||||
return basename.split("_")[1]
|
return basename.split("_")[1]
|
||||||
raise Exception(f"Unknown board name: {basename}")
|
raise Exception(f"Unknown board name: {basename}")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user