#ifndef TACTILEIPC3D_SERIAL_QT_TRANSPORT_H
#define TACTILEIPC3D_SERIAL_QT_TRANSPORT_H

#include "serial_transport.h"

class QSerialPort;

class QtSerialTransport : public ISerialTransport {
    Q_OBJECT
public:
    explicit QtSerialTransport(QObject* parent = nullptr);
    ~QtSerialTransport() override;

    bool open(const SerialConfig& config, QString* error) override;
    void close() override;
    bool writeBytes(const QByteArray& data, QString* error) override;

private:
    void ensurePort_();
    void applyConfig_(const SerialConfig& config);

    QSerialPort* m_port = nullptr;
};

#endif // TACTILEIPC3D_SERIAL_QT_TRANSPORT_H
