#pragma once #pragma pack(1) #include "kdefine.h" __NAMESPACE_BEGIN__(HJ) typedef enum tagErrorCode : unsigned char { ERR_OK = 0X00, ERR_INVALID_LEN = 0X01, ERR_INVALID_UTF8 = 0X02, ERR_INVALID_BUF_LEN = 0X03, ERR_INVALID_JSON_FMT = 0X04, ERR_INVALID_FSUCODE = 0X05, ERR_UNKOWN = 0XFF }ErrorCode; typedef enum tagFrameType : unsigned char { Frame_Response = 0x00, //返回帧 Frame_Request = 0x01, //请求帧 Frame_DeviceData_Request = 0x02, //来自采集程序的数据请求包,将数据保存到数据库中 }FrameType; typedef struct tagFrameTail { unsigned char frame_delimiter[4] = { 0xEE,0xFF,0xEE,0xFF }; }FrameTail; typedef struct tagFrame { FrameType frame_type; //帧类型 unsigned int frame_len; //帧数据长度 unsigned char frame_content[1]; //帧的内容,实际应为json字符串,由json内容自解释 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; } }MessageFrame; __NAMESPACE_END__(HJ) #pragma pack()