just save
This commit is contained in:
54
main/MessageHelper.h
Normal file
54
main/MessageHelper.h
Normal file
@@ -0,0 +1,54 @@
|
||||
#ifndef MESSAGE_HELPER_H_INCLUDED
|
||||
#define MESSAGE_HELPER_H_INCLUDED
|
||||
|
||||
#include <cinttypes>
|
||||
#include <QByteArray>
|
||||
#include <QByteArrayList>
|
||||
#include <QString>
|
||||
|
||||
|
||||
class MessageHelper {
|
||||
public:
|
||||
enum PacketType : std::uint8_t {
|
||||
POS_ECR = 0,
|
||||
// POS_EXT = 1,
|
||||
MESSAGE_RECEIVED_POSITIVE_ACK = 0x0A,
|
||||
MESSAGE_RECEIVED_NEGATIVE_ACK = 0x0F
|
||||
// POS_HOST_FORMAT_1_ENCRYPTED = 0x11,
|
||||
// POS_HOST_FORMAT_1_UNENCRYPTED = 0x21
|
||||
};
|
||||
|
||||
explicit MessageHelper(QString const &posID = "T-TPS-SELF2002in",
|
||||
QString const &apak = "8AC304380E0E476BA2558B75DB9E2516");
|
||||
explicit MessageHelper(QByteArray const &posID, QString const &apak);
|
||||
~MessageHelper();
|
||||
|
||||
|
||||
void createRawPacket(PacketType PacketType,
|
||||
QByteArray const &encryptedPacketId,
|
||||
QByteArray const &message);
|
||||
|
||||
bool insertEncryptedPacketID(QByteArray const &encryptedPacketID);
|
||||
|
||||
QByteArrayList const &getMessageChunksToSend();
|
||||
QByteArrayList const &createLoginMessageChunksToSend(char ext);
|
||||
|
||||
// private:
|
||||
|
||||
QByteArray m_posID;
|
||||
QString m_apak;
|
||||
uint8_t m_posIDLength;
|
||||
QByteArray m_messageHeaderPrefix;
|
||||
QByteArray m_rawPacket; // without leading STX and trailing [ETX(1/2), LRC]
|
||||
QByteArray m_loginMessage;
|
||||
QByteArrayList m_messageChunkList;
|
||||
|
||||
bool setMessageHeaderPacketType(PacketType packetType);
|
||||
bool createMessageHeaderPrefix(PacketType packetType, QByteArray const &encryptedPacketID);
|
||||
void createLoginMessage();
|
||||
|
||||
static QByteArray const &mask(QByteArray &messageChunk);
|
||||
static QByteArray const &unMask(QByteArray &messageChunk);
|
||||
};
|
||||
|
||||
#endif // MESSAGE_HELPER_H_INCLUDED
|
||||
Reference in New Issue
Block a user