#pragma once

#include <string>

namespace fgc {

// Remote control input (was struct mqtt_sub_data). The *_available flags mark
// whether a fresh value arrived since the last poll().
struct ControlCommand {
    bool        control_code_available = false;
    int         control_code = 0;   // 0 = automatic sweep, 1 = directed to target heading
    bool        heading_available = false;
    std::string target_heading;     // kept as string; the yaw target in degrees
};

// Notification published after an image is captured and saved.
struct CamEvent {
    std::string tower;          // tower / FWT name
    std::string camera;         // "RGB" / "ACR" / "NIR"
    int         heading_decideg = 0;  // yaw heading * 10 (one decimal as integer)
    int         pitch_decideg = 0;    // pitch elevation * 10 (one decimal as integer)
    long long   timestamp_ms = 0;     // Unix epoch ms; matches the image filename
};

// Abstraction over the remote control/telemetry channel. Implemented by
// MqttControlChannel (Eclipse Paho) and NullControlChannel (no broker; used
// for development - publishes are dropped and poll() yields a default).
class IControlChannel {
public:
    virtual ~IControlChannel() = default;

    // Returns true once usable. NullControlChannel always succeeds.
    virtual bool connect()    = 0;
    virtual void disconnect() = 0;
    virtual bool connected() const = 0;

    virtual void publishStatus(int code)               = 0;
    virtual void publishCamEvent(const CamEvent& event) = 0;

    // Latest control input; clears the *_available flags so each update is
    // acted on once.
    virtual ControlCommand poll() = 0;
};

}  // namespace fgc
