#pragma once

#include <Arduino.h>
#include "data_model.h"
#include "wifi_manager.h"

void mqtt_init(const WifiMqttConfig &config, const char *device_id);
void mqtt_loop();
bool mqtt_is_connected();
bool mqtt_publish_state(const MeterData &data);
bool mqtt_publish_faults(const char *device_id, const FaultCounters &counters, FaultType last_error, uint32_t last_error_age_sec);
bool mqtt_publish_discovery(const char *device_id);
#ifdef ENABLE_TEST_MODE
bool mqtt_publish_test(const char *device_id, const String &payload);
#endif
