|
Aquarium Cooling Controller
ESP32 firmware for aquarium cooling fan control, monitoring, telemetry, and fault handling.
|
Maintains Wi-Fi/MQTT connections and publishes controller telemetry. More...
#include <mqtt_telemetry.h>
Public Member Functions | |
| MqttTelemetry () | |
| Creates an uninitialized telemetry publisher. | |
| void | begin (uint32_t nowMs) |
| Starts telemetry connection management. | |
| void | update (uint32_t nowMs) |
| Maintains Wi-Fi and MQTT reconnect attempts. | |
| bool | publishTelemetry (uint32_t nowMs, const ControlSnapshot &controlSnapshot, const ControlConfig &controlConfig, const OtaTelemetrySnapshot &otaSnapshot, const FaultMonitorSnapshot &faultSnapshot, const FaultPolicySnapshot &policySnapshot, const RemoteConfigStatus &remoteConfigStatus, bool force) |
| Publishes a complete telemetry snapshot when connected. | |
| void | setRemoteConfigCallback (RemoteConfigCallback callback, void *context) |
| Registers a callback for validated MQTT /set topic dispatch. | |
| void | printStatus (Stream &out) |
| Prints current Wi-Fi/MQTT status to a stream. | |
| bool | enabled () const |
| Indicates whether network telemetry is configured and enabled. | |
| bool | wifiConnected () const |
| Indicates whether Wi-Fi is currently connected. | |
| bool | mqttConnected () |
| Indicates whether MQTT is currently connected. | |
Maintains Wi-Fi/MQTT connections and publishes controller telemetry.
Connection management is non-blocking from the caller's point of view: update() performs periodic reconnect attempts while publishTelemetry() emits the latest controller state when a broker connection is available. Topic names and credentials come from the network configuration macros.
| void MqttTelemetry::begin | ( | uint32_t | nowMs | ) |
Starts telemetry connection management.
| nowMs | Current monotonic timestamp in milliseconds. |
| bool MqttTelemetry::enabled | ( | ) | const |
Indicates whether network telemetry is configured and enabled.
| bool MqttTelemetry::mqttConnected | ( | ) |
Indicates whether MQTT is currently connected.
| void MqttTelemetry::printStatus | ( | Stream & | out | ) |
Prints current Wi-Fi/MQTT status to a stream.
| out | Destination stream. |
| bool MqttTelemetry::publishTelemetry | ( | uint32_t | nowMs, |
| const ControlSnapshot & | controlSnapshot, | ||
| const ControlConfig & | controlConfig, | ||
| const OtaTelemetrySnapshot & | otaSnapshot, | ||
| const FaultMonitorSnapshot & | faultSnapshot, | ||
| const FaultPolicySnapshot & | policySnapshot, | ||
| const RemoteConfigStatus & | remoteConfigStatus, | ||
| bool | force | ||
| ) |
Publishes a complete telemetry snapshot when connected.
The payload is split across stable topic suffixes so FHEM or other home automation integrations can subscribe to individual state values. When force is false, the method respects the configured publish interval.
| nowMs | Current monotonic timestamp in milliseconds. |
| controlSnapshot | Latest control-engine state. |
| controlConfig | Latest active staged-control configuration. |
| otaSnapshot | Latest OTA maintenance state. |
| faultSnapshot | Latest fan fault-monitor state. |
| policySnapshot | Latest fault-policy state. |
| remoteConfigStatus | Latest remote-configuration apply status. |
| force | True to publish even before the normal interval elapses. |
| void MqttTelemetry::setRemoteConfigCallback | ( | RemoteConfigCallback | callback, |
| void * | context | ||
| ) |
Registers a callback for validated MQTT /set topic dispatch.
The telemetry layer only routes the subscribed topic suffix and raw payload bytes. Validation and persistence remain in the sketch so local control policy is owned by the main firmware orchestration.
| callback | Callback invoked for supported remote configuration topics. |
| context | Opaque caller-owned pointer forwarded to the callback. |
| void MqttTelemetry::update | ( | uint32_t | nowMs | ) |
Maintains Wi-Fi and MQTT reconnect attempts.
| nowMs | Current monotonic timestamp in milliseconds. |
| bool MqttTelemetry::wifiConnected | ( | ) | const |
Indicates whether Wi-Fi is currently connected.