Skip to content

Commit

Permalink
可用状态使用retained
Browse files Browse the repository at this point in the history
  • Loading branch information
qlwz committed Feb 17, 2020
1 parent 6849ddf commit 28480ad
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
12 changes: 6 additions & 6 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
// See http://go.microsoft.com/fwlink/?LinkId=827846
// for the documentation about the extensions.json format
"recommendations": [
"platformio.platformio-ide"
]
}
// See http://go.microsoft.com/fwlink/?LinkId=827846
// for the documentation about the extensions.json format
"recommendations": [
"platformio.platformio-ide"
]
}
6 changes: 3 additions & 3 deletions lib/esp_framework/src/Mqtt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ bool Mqtt::mqttConnect()
Debug::AddInfo(PSTR("client mqtt not connected, trying to connect to %s:%d Broker"), globalConfig.mqtt.server, globalConfig.mqtt.port);
mqttClient.setServer(globalConfig.mqtt.server, globalConfig.mqtt.port);

if (mqttClient.connect(UID, globalConfig.mqtt.user, globalConfig.mqtt.pass, getTeleTopic(F("availability")).c_str(), 0, false, "offline"))
if (mqttClient.connect(UID, globalConfig.mqtt.user, globalConfig.mqtt.pass, getTeleTopic(F("availability")).c_str(), 0, true, "offline"))
{
Debug::AddInfo(PSTR("successful client mqtt connection"));
if (connectedcallback != NULL)
Expand All @@ -58,7 +58,7 @@ void Mqtt::doReportHeartbeat()

void Mqtt::availability()
{
publish(getTeleTopic(F("availability")), "online", false);
publish(getTeleTopic(F("availability")), "online", true);
}

void Mqtt::perSecondDo()
Expand Down Expand Up @@ -99,7 +99,7 @@ void Mqtt::loop()
{
doReportHeartbeat();
}
if (perSecond % 309 == 0)
if (perSecond % 3609 == 0)
{
availability();
}
Expand Down
2 changes: 1 addition & 1 deletion platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ extra_scripts = scripts/strip-floats.py

lib_deps =
PubSubClient
Nanopb@0.3.9.2
Nanopb=https://github.com/nanopb/nanopb.git#nanopb-0.3.9.5

[env:dc1]
lib_deps = ${env.lib_deps}
Expand Down

0 comments on commit 28480ad

Please sign in to comment.