mariolukas / Watterott-CO2-Ampel-Plus-Firmware

Firmware for Watterott CO2 Ampel (Plus Version)
GNU General Public License v3.0
15 stars 13 forks source link

Ensure mqtt client is sending keepalive pings to mqtt broker #24

Closed KernelPanicAUS closed 3 years ago

KernelPanicAUS commented 3 years ago

I observed that the Ampel kept dropping metrics due to the mqtt client timing out. This was also visible in the mosquitto logs, the Ampel kept timing out every 10 seconds, which matches the configuration of the mqtt client.

It is advised to call client.loop() in the controller void loop() function, so that pings are sent to the broker every few seconds to keep the tcp connection open.

This PR addressed this issue by having the mqtt client call its loop() function in the main controller loop() function.