2024-09-03 16:27:43 +08:00
|
|
|
|
#pragma once
|
|
|
|
|
#pragma pack(1)
|
|
|
|
|
|
|
|
|
|
#include "kdefine.h"
|
|
|
|
|
|
2024-09-05 16:36:20 +08:00
|
|
|
|
__NAMESPACE_BEGIN__(HJ)
|
2024-09-03 16:27:43 +08:00
|
|
|
|
|
2024-09-10 16:12:38 +08:00
|
|
|
|
#define FRAME_HEADER_LENGTH (5)
|
|
|
|
|
#define FRAME_TAILE_LENGTH (4)
|
|
|
|
|
|
2024-09-04 16:24:53 +08:00
|
|
|
|
typedef enum tagErrorCode : unsigned char
|
2024-09-03 16:27:43 +08:00
|
|
|
|
{
|
2024-09-04 16:24:53 +08:00
|
|
|
|
ERR_OK = 0X00,
|
|
|
|
|
ERR_INVALID_LEN = 0X01,
|
|
|
|
|
ERR_INVALID_UTF8 = 0X02,
|
|
|
|
|
ERR_INVALID_BUF_LEN = 0X03,
|
2024-09-06 16:10:01 +08:00
|
|
|
|
ERR_INVALID_JSON_FMT = 0X04,
|
|
|
|
|
ERR_INVALID_FSUCODE = 0X05,
|
2024-09-04 16:24:53 +08:00
|
|
|
|
ERR_UNKOWN = 0XFF
|
|
|
|
|
}ErrorCode;
|
|
|
|
|
|
|
|
|
|
typedef enum tagFrameType : unsigned char
|
|
|
|
|
{
|
2024-09-05 16:36:20 +08:00
|
|
|
|
Frame_Response = 0x00, //<2F><><EFBFBD><EFBFBD>֡
|
|
|
|
|
Frame_Request = 0x01, //<2F><><EFBFBD><EFBFBD>֡
|
2024-09-04 16:24:53 +08:00
|
|
|
|
Frame_DeviceData_Request = 0x02, //<2F><><EFBFBD>Բɼ<D4B2><C9BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݱ<EFBFBD><DDB1>浽<EFBFBD><E6B5BD><EFBFBD>ݿ<EFBFBD><DDBF><EFBFBD>
|
2024-09-03 16:27:43 +08:00
|
|
|
|
}FrameType;
|
|
|
|
|
|
2024-09-04 16:24:53 +08:00
|
|
|
|
typedef struct tagFrameTail
|
|
|
|
|
{
|
|
|
|
|
unsigned char frame_delimiter[4] = { 0xEE,0xFF,0xEE,0xFF };
|
|
|
|
|
}FrameTail;
|
|
|
|
|
|
2024-09-03 16:27:43 +08:00
|
|
|
|
typedef struct tagFrame
|
|
|
|
|
{
|
|
|
|
|
FrameType frame_type; //֡<><D6A1><EFBFBD><EFBFBD>
|
|
|
|
|
unsigned int frame_len; //֡<><D6A1><EFBFBD>ݳ<EFBFBD><DDB3><EFBFBD>
|
2024-09-04 16:24:53 +08:00
|
|
|
|
unsigned char frame_content[1]; //֡<><D6A1><EFBFBD><EFBFBD><EFBFBD>ݣ<EFBFBD>ʵ<EFBFBD><CAB5>ӦΪjson<6F>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>json<6F><6E><EFBFBD><EFBFBD><EFBFBD>Խ<EFBFBD><D4BD><EFBFBD>
|
|
|
|
|
tagFrame()
|
|
|
|
|
{
|
|
|
|
|
frame_type = Frame_Response;
|
|
|
|
|
frame_len = 1;
|
|
|
|
|
frame_content[0] = ERR_OK;
|
|
|
|
|
}
|
|
|
|
|
void setErrorFrame(ErrorCode err = ERR_OK)
|
|
|
|
|
{
|
|
|
|
|
frame_len = 1;
|
|
|
|
|
frame_content[0] = err;
|
|
|
|
|
}
|
2024-09-03 16:27:43 +08:00
|
|
|
|
}MessageFrame;
|
|
|
|
|
|
2024-09-05 16:36:20 +08:00
|
|
|
|
__NAMESPACE_END__(HJ)
|
2024-09-03 16:27:43 +08:00
|
|
|
|
|
|
|
|
|
#pragma pack()
|