#ifndef HYPERIONCLIENT_H
#define HYPERIONCLIENT_H

#include <QObject>
#include <QTcpSocket>
#include <QByteArray>
#include <QTimer> // Added for QTimer::singleShot

class HyperionClient : public QObject
{
    Q_OBJECT

public:
    explicit HyperionClient(QString host, ushort port, QString priority);
    ~HyperionClient();

    void clearLeds();
    void setLedColor(quint8 R, quint8 G, quint8 B);
    void ledAdjustments(QString red, QString green, QString blue, QString temp, QString thres, QString trans);
    void sendImage(const uchar *data, int size);
    void setImgSize(int width, int height);

signals:
    void clientConnected();

private slots:
    void _connected();
    void _disconnected();
    void _readyRead();
    void _socketError(QAbstractSocket::SocketError socketError);

private:
    QTcpSocket* _sock_p;
    QString _host_m;
    ushort _port_m;
    QString _priority_m;
    QByteArray _cmd_m;
    QByteArray imgCmdBuf;

    void _connectHost();
    void _sendCommand();
    void _ledAdjustments();
    void _colorAdjustment();
    void _thresholdAdjustment();
    void _transformdAdjustment();
    void _temperatureAdjustment();

    enum ColorAdjustmentType {
        REDADJUST = 1,
        GREENADJUST = 2,
        BLUEADJUST = 4
    };
    quint8 _colorAdjustmentType_m;
    QString _redAdjust_m;
    QString _greenAdjust_m;
    QString _blueAdjust_m;
    QString _temperature_m;
    QString _threshold_m;

    static int _idCounter;
};

#endif // HYPERIONCLIENT_H