Browse Source

cleanup index.html

add mqtt tx counter
pull/372/head
lumapu 2 years ago
parent
commit
0f0bbd4b7f
  1. 1
      tools/esp8266/app.h
  2. 15
      tools/esp8266/html/index.html
  3. 15
      tools/esp8266/mqtt.h
  4. 2
      tools/esp8266/webApi.cpp

1
tools/esp8266/app.h

@ -171,6 +171,7 @@ class app {
inline bool mqttIsConnected(void) { return mMqtt.isConnected(); }
inline bool getSettingsValid(void) { return mSettingsValid; }
inline bool getRebootRequestState(void) { return mShowRebootRequest; }
inline uint32_t getMqttTxCnt(void) { return mMqtt.getTxCnt(); }
HmSystemType *mSys;
bool mShouldReboot;

15
tools/esp8266/html/index.html

@ -46,15 +46,18 @@
<p>Every <span id="refresh"></span> seconds the values are updated</p>
<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/>
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/>
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 id="footer">

15
tools/esp8266/mqtt.h

@ -25,6 +25,9 @@ class mqtt {
mClient = new PubSubClient(mEspClient);
mAddressSet = false;
mLastReconnect = 0;
mTxCnt = 0;
memset(mDevName, 0, DEVNAME_LEN);
}
@ -50,6 +53,7 @@ class mqtt {
char top[64];
snprintf(top, 64, "%s/%s", mCfg->topic, topic);
sendMsg2(top, msg, false);
mTxCnt++;
}
void sendMsg2(const char *topic, const char *msg, boolean retained) {
@ -75,6 +79,10 @@ class mqtt {
mClient->loop();
}
uint32_t getTxCnt(void) {
return mTxCnt;
}
private:
void reconnect(void) {
DPRINTLN(DBG_DEBUG, F("mqtt.h:reconnect"));
@ -85,8 +93,8 @@ class mqtt {
#endif
boolean resub = false;
if(!mClient->connected() && (millis() - lastReconnect) > MQTT_RECONNECT_DELAY ) {
lastReconnect = millis();
if(!mClient->connected() && (millis() - mLastReconnect) > MQTT_RECONNECT_DELAY ) {
mLastReconnect = millis();
if(strlen(mDevName) > 0) {
// der Server und der Port müssen neu gesetzt werden,
// da ein MQTT_CONNECTION_LOST -3 die Werte zerstört hat.
@ -118,7 +126,8 @@ class mqtt {
bool mAddressSet;
mqttConfig_t *mCfg;
char mDevName[DEVNAME_LEN];
unsigned long lastReconnect = 0;
uint32_t mLastReconnect;
uint32_t mTxCnt;
};
#endif /*__MQTT_H_*/

2
tools/esp8266/webApi.cpp

@ -275,7 +275,7 @@ void webApi::getIndex(JsonObject obj) {
if(!mApp->getSettingsValid())
info.add(F("your settings are invalid"));
if(mApp->mqttIsConnected())
info.add(F("MQTT is connected"));
info.add(F("MQTT is connected, ") + String(mApp->getMqttTxCnt()) + F(" packets sent"));
}

Loading…
Cancel
Save