//
// Created by Ht on 2022/10/23.
//

#ifndef IOT_EDGE_VDALNEW_QGALIGHTJIASERIALREBUFFERENTRY_H
#define IOT_EDGE_VDALNEW_QGALIGHTJIASERIALREBUFFERENTRY_H

#include <src/vdal/SerialHolderInterface.h>
#include <src/plugin/QGaSerialRebufferPluginEntry.h>

namespace jedge {

    class JE_API QGaLightJiaSerialRebufferEntry :
            public QGaSerialRebufferPluginEntry {
    protected:;

        static const int DATA_IDX = 6;
        static const int LEN_IDX = 1;
        static const int CMD_IDX = 3;
        static const int SAR_IDX = 5;
        static const int BUFF_SIZE = 4096;

        QByte result_buff_[BUFF_SIZE]{};
        uint16_t buff_len = 0;
        uint16_t data_len = 0;

        std::mutex op_mutex_;

    public:
        explicit QGaLightJiaSerialRebufferEntry(std::string name, std::string type = "cypher", int ver = 0) :
                QGaSerialRebufferPluginEntry(std::move(name), std::move(type), ver) { }

        shared_ptr<QGaSerialRebufferPluginEntry> duplication(const string &name) override;

        bool rebuildBufferBytes(const QByte *srcbuff, int32_t srclen, QRByte &newbuff, size_t &newlen) override;

    };

}

#endif //IOT_EDGE_VDALNEW_QGALIGHTJIASERIALREBUFFERENTRY_H
