#ifndef HOMEKIT_LIB_MQTT_MODULE_DIAGNOSTICS_H #define HOMEKIT_LIB_MQTT_MODULE_DIAGNOSTICS_H #include #include namespace homekit::mqtt { struct DiagnosticsFlags { uint8_t state: 1; uint8_t config_changed_value_present: 1; uint8_t config_changed: 1; uint8_t reserved: 5; } __attribute__((packed)); struct MqttInitialDiagnosticsPayload { uint32_t ip; uint8_t fw_version; int8_t rssi; uint32_t free_heap; DiagnosticsFlags flags; } __attribute__((packed)); struct MqttDiagnosticsPayload { int8_t rssi; uint32_t free_heap; DiagnosticsFlags flags; } __attribute__((packed)); class MqttDiagnosticsModule: public MqttModule { private: bool initialSent; void sendDiagnostics(Mqtt& mqtt); public: MqttDiagnosticsModule() : MqttModule(30) , initialSent(false) {} void onConnect(Mqtt& mqtt) override; void onDisconnect(Mqtt& mqtt, espMqttClientTypes::DisconnectReason reason) override; void tick(Mqtt& mqtt) override; }; } #endif //HOMEKIT_LIB_MQTT_MODULE_DIAGNOSTICS_H