forked from xiaozhi/xiaozhi-esp32
ml307: Add sleep mode (#826)
This commit is contained in:
@@ -65,6 +65,9 @@ void Ml307Board::WaitForNetworkReady() {
|
||||
|
||||
// Close all previous connections
|
||||
modem_.ResetConnections();
|
||||
|
||||
// Enable sleep mode
|
||||
modem_.SetSleepMode(true, 30);
|
||||
}
|
||||
|
||||
Http* Ml307Board::CreateHttp() {
|
||||
|
||||
12
main/ota.cc
12
main/ota.cc
@@ -148,6 +148,10 @@ bool Ota::CheckVersion() {
|
||||
if (settings.GetString(item->string) != item->valuestring) {
|
||||
settings.SetString(item->string, item->valuestring);
|
||||
}
|
||||
} else if (cJSON_IsNumber(item)) {
|
||||
if (settings.GetInt(item->string) != item->valueint) {
|
||||
settings.SetInt(item->string, item->valueint);
|
||||
}
|
||||
}
|
||||
}
|
||||
has_mqtt_config_ = true;
|
||||
@@ -162,9 +166,13 @@ bool Ota::CheckVersion() {
|
||||
cJSON *item = NULL;
|
||||
cJSON_ArrayForEach(item, websocket) {
|
||||
if (cJSON_IsString(item)) {
|
||||
settings.SetString(item->string, item->valuestring);
|
||||
if (settings.GetString(item->string) != item->valuestring) {
|
||||
settings.SetString(item->string, item->valuestring);
|
||||
}
|
||||
} else if (cJSON_IsNumber(item)) {
|
||||
settings.SetInt(item->string, item->valueint);
|
||||
if (settings.GetInt(item->string) != item->valueint) {
|
||||
settings.SetInt(item->string, item->valueint);
|
||||
}
|
||||
}
|
||||
}
|
||||
has_websocket_config_ = true;
|
||||
|
||||
@@ -42,6 +42,7 @@ bool MqttProtocol::StartMqttClient(bool report_error) {
|
||||
auto client_id = settings.GetString("client_id");
|
||||
auto username = settings.GetString("username");
|
||||
auto password = settings.GetString("password");
|
||||
int keepalive_interval = settings.GetInt("keepalive", 120);
|
||||
publish_topic_ = settings.GetString("publish_topic");
|
||||
|
||||
if (endpoint.empty()) {
|
||||
@@ -53,7 +54,7 @@ bool MqttProtocol::StartMqttClient(bool report_error) {
|
||||
}
|
||||
|
||||
mqtt_ = Board::GetInstance().CreateMqtt();
|
||||
mqtt_->SetKeepAlive(90);
|
||||
mqtt_->SetKeepAlive(keepalive_interval);
|
||||
|
||||
mqtt_->OnDisconnected([this]() {
|
||||
ESP_LOGI(TAG, "Disconnected from endpoint");
|
||||
|
||||
Reference in New Issue
Block a user