#ifndef TACTILEIPC3D_PIEZORESISTIVE_A_PROTOCOL_H
#define TACTILEIPC3D_PIEZORESISTIVE_A_PROTOCOL_H

#include "serial_codec.h"
#include "serial_decoder.h"
#include "serial_format.h"

class PiezoresistiveAFormat : public ISerialFormat {
public:
    ParseResult tryParse(QByteArray* buffer, QByteArray* packet, QString* error) override;

    static quint8 crc8ITU(const QByteArray& data, int length);
};

class PiezoresistiveACodec : public ISerialCodec {
public:
    QString name() const override { return QStringLiteral("piezoresistive_a"); }

    QByteArray buildRequest(const SerialConfig& config, const SensorRequest& request) override;
    QByteArray buildGetVersionRequest(const SerialConfig& config) override;
    QByteArray buildGetSpecRequest(const SerialConfig& config) override;
};

class PiezoresistiveADecoder : public ISerialDecoder {
public:
    QString name() const override { return QStringLiteral("piezoresistive_a"); }

    bool decodeFrame(const QByteArray& packet, DataFrame* frame, QString* error) override;
    bool decodeSpec(const QByteArray& packet, SensorSpec* spec, QString* error) override;
};

#endif // TACTILEIPC3D_PIEZORESISTIVE_A_PROTOCOL_H
