mirror of
https://github.com/lumapu/ahoy.git
synced 2025-05-21 12:56:11 +02:00
cleanup index.html
add mqtt tx counter
This commit is contained in:
parent
2a3c267906
commit
0f0bbd4b7f
4 changed files with 23 additions and 10 deletions
|
@ -171,6 +171,7 @@ class app {
|
||||||
inline bool mqttIsConnected(void) { return mMqtt.isConnected(); }
|
inline bool mqttIsConnected(void) { return mMqtt.isConnected(); }
|
||||||
inline bool getSettingsValid(void) { return mSettingsValid; }
|
inline bool getSettingsValid(void) { return mSettingsValid; }
|
||||||
inline bool getRebootRequestState(void) { return mShowRebootRequest; }
|
inline bool getRebootRequestState(void) { return mShowRebootRequest; }
|
||||||
|
inline uint32_t getMqttTxCnt(void) { return mMqtt.getTxCnt(); }
|
||||||
|
|
||||||
HmSystemType *mSys;
|
HmSystemType *mSys;
|
||||||
bool mShouldReboot;
|
bool mShouldReboot;
|
||||||
|
|
|
@ -46,15 +46,18 @@
|
||||||
<p>Every <span id="refresh"></span> seconds the values are updated</p>
|
<p>Every <span id="refresh"></span> seconds the values are updated</p>
|
||||||
|
|
||||||
<div id="note">
|
<div id="note">
|
||||||
New updates can be found on Github: <a href="https://github.com/lumapu/ahoy" target="_blank">https://github.com/lumapu/ahoy</a><br/>
|
|
||||||
<br/>
|
|
||||||
Please report issues in <a href="https://github.com/lumapu/ahoy/issues">Github</a><br/>
|
|
||||||
Discuss with us on <a href="https://discord.gg/WzhxEY62mB">Discord</a><br/>
|
Discuss with us on <a href="https://discord.gg/WzhxEY62mB">Discord</a><br/>
|
||||||
Support this project: <a href="https://paypal.me/lupusch">Donate</a><br/>
|
<h2>Support this project:</h2>
|
||||||
|
<ul>
|
||||||
|
<li>Report <a href="https://github.com/lumapu/ahoy/issues" target="_blank">issues</a></li>
|
||||||
|
<li>Contribute to <a href="https://github.com/lumapu/ahoy/blob/main/tools/esp8266/User_Manual.md" target="_blank">documentation</a></li>
|
||||||
|
<li>Test <a href="https://github.com/lumapu/ahoy/actions/workflows/compile_development.yml" target="_blank">development firmware</a></li>
|
||||||
|
<li>make a <a href="https://paypal.me/lupusch" target="_blank">donation</a></li>
|
||||||
|
</ul>
|
||||||
<p class="lic"><a href="https://creativecommons.org/licenses/by-nc-sa/3.0/de">Creative Commons - https://creativecommons.org/licenses/by-nc-sa/3.0/de/</a><br/>
|
<p class="lic"><a href="https://creativecommons.org/licenses/by-nc-sa/3.0/de">Creative Commons - https://creativecommons.org/licenses/by-nc-sa/3.0/de/</a><br/>
|
||||||
Check the licenses which are published on <a href="https://github.com/lumapu/ahoy">https://github.com/lumapu/ahoy</a> as well</p><br/>
|
Check the licenses which are published on <a href="https://github.com/lumapu/ahoy" target="_blank">https://github.com/lumapu/ahoy</a> as well<br/>
|
||||||
|
|
||||||
This project was started from <a href="https://www.mikrocontroller.net/topic/525778" target="_blank">this discussion. (Mikrocontroller.net)</a>
|
This project was started from <a href="https://www.mikrocontroller.net/topic/525778" target="_blank">this discussion. (Mikrocontroller.net)</a></p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id="footer">
|
<div id="footer">
|
||||||
|
|
|
@ -25,6 +25,9 @@ class mqtt {
|
||||||
mClient = new PubSubClient(mEspClient);
|
mClient = new PubSubClient(mEspClient);
|
||||||
mAddressSet = false;
|
mAddressSet = false;
|
||||||
|
|
||||||
|
mLastReconnect = 0;
|
||||||
|
mTxCnt = 0;
|
||||||
|
|
||||||
memset(mDevName, 0, DEVNAME_LEN);
|
memset(mDevName, 0, DEVNAME_LEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,6 +53,7 @@ class mqtt {
|
||||||
char top[64];
|
char top[64];
|
||||||
snprintf(top, 64, "%s/%s", mCfg->topic, topic);
|
snprintf(top, 64, "%s/%s", mCfg->topic, topic);
|
||||||
sendMsg2(top, msg, false);
|
sendMsg2(top, msg, false);
|
||||||
|
mTxCnt++;
|
||||||
}
|
}
|
||||||
|
|
||||||
void sendMsg2(const char *topic, const char *msg, boolean retained) {
|
void sendMsg2(const char *topic, const char *msg, boolean retained) {
|
||||||
|
@ -75,6 +79,10 @@ class mqtt {
|
||||||
mClient->loop();
|
mClient->loop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint32_t getTxCnt(void) {
|
||||||
|
return mTxCnt;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void reconnect(void) {
|
void reconnect(void) {
|
||||||
DPRINTLN(DBG_DEBUG, F("mqtt.h:reconnect"));
|
DPRINTLN(DBG_DEBUG, F("mqtt.h:reconnect"));
|
||||||
|
@ -85,8 +93,8 @@ class mqtt {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
boolean resub = false;
|
boolean resub = false;
|
||||||
if(!mClient->connected() && (millis() - lastReconnect) > MQTT_RECONNECT_DELAY ) {
|
if(!mClient->connected() && (millis() - mLastReconnect) > MQTT_RECONNECT_DELAY ) {
|
||||||
lastReconnect = millis();
|
mLastReconnect = millis();
|
||||||
if(strlen(mDevName) > 0) {
|
if(strlen(mDevName) > 0) {
|
||||||
// der Server und der Port müssen neu gesetzt werden,
|
// der Server und der Port müssen neu gesetzt werden,
|
||||||
// da ein MQTT_CONNECTION_LOST -3 die Werte zerstört hat.
|
// da ein MQTT_CONNECTION_LOST -3 die Werte zerstört hat.
|
||||||
|
@ -118,7 +126,8 @@ class mqtt {
|
||||||
bool mAddressSet;
|
bool mAddressSet;
|
||||||
mqttConfig_t *mCfg;
|
mqttConfig_t *mCfg;
|
||||||
char mDevName[DEVNAME_LEN];
|
char mDevName[DEVNAME_LEN];
|
||||||
unsigned long lastReconnect = 0;
|
uint32_t mLastReconnect;
|
||||||
|
uint32_t mTxCnt;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /*__MQTT_H_*/
|
#endif /*__MQTT_H_*/
|
||||||
|
|
|
@ -275,7 +275,7 @@ void webApi::getIndex(JsonObject obj) {
|
||||||
if(!mApp->getSettingsValid())
|
if(!mApp->getSettingsValid())
|
||||||
info.add(F("your settings are invalid"));
|
info.add(F("your settings are invalid"));
|
||||||
if(mApp->mqttIsConnected())
|
if(mApp->mqttIsConnected())
|
||||||
info.add(F("MQTT is connected"));
|
info.add(F("MQTT is connected, ") + String(mApp->getMqttTxCnt()) + F(" packets sent"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue