ml307: Add sleep mode (#826)

This commit is contained in:
Xiaoxia
2025-06-16 19:05:31 +08:00
committed by GitHub
parent f98ffdbb5c
commit f29c1a11d9
3 changed files with 15 additions and 3 deletions

View File

@@ -65,6 +65,9 @@ void Ml307Board::WaitForNetworkReady() {
// Close all previous connections
modem_.ResetConnections();
// Enable sleep mode
modem_.SetSleepMode(true, 30);
}
Http* Ml307Board::CreateHttp() {

View File

@@ -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;

View File

@@ -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");