Commit graph

6 commits

Author SHA1 Message Date
Chipster
5aafb6c983
Publish structured link/connectivity status
DAPNETGateway had no MQTT link status at all, and no retain support
in its MQTT layer. Adds a link Kind (linking/unlinked/failed) and
publishes it from the places connectivity already changes state but
was previously only logged: successful login, a rejected auth key
(detected asynchronously from the server's own protocol response, not
the initial TCP connect), a dropped connection triggering the
existing reconnect loop, a failed startup socket open, and clean
shutdown.
2026-08-10 17:37:55 -05:00
Andy Taylor
edac3b873a Add mosquitto_loop_stop before mosquitto_destroy in close()
The background network thread started by mosquitto_loop_start() was not
being stopped before mosquitto_destroy(), which can cause a use-after-free
if the thread is still running when the mosquitto structure is freed.
2026-03-08 14:16:32 +00:00
Andy Taylor
3b99af8afc Fix MQTT client ID collision on ARM 32-bit userland with 64-bit kernel
The MQTT client ID was generated using sprintf with %ld and time(nullptr).
On platforms with 32-bit userland but 64-bit kernel (such as Raspberry Pi OS
and some custom Alpine Linux builds), time_t is a 64-bit long long but %ld
only reads 32 bits. Since the upper 32 bits of the current Unix timestamp
are zero, this always produces a client ID ending in .0, causing collisions
when multiple instances or restarts occur.

Replace time()-based client IDs with PID-based IDs using getpid(), which is
always a portable 32-bit value and unique per process. Platform-guarded for
Windows (_getpid) and POSIX (getpid).
2026-03-08 12:51:35 +00:00
Jonathan Naylor
d1bd0b549a Add MQTT authentication. 2025-03-26 15:11:42 +00:00
Jonathan Naylor
3aee1f0ed8 Merge branch 'master' into mqtt 2025-03-18 15:13:07 +00:00
Jonathan Naylor
e677d6a954 Convert the gateway to log via MQTT. 2023-07-07 17:57:36 +01:00