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-11-15 18:22:43 +08:00
|
|
|
|
#define FRAME_MAX_LENGTH (0x100000) //<2F><><EFBFBD><EFBFBD>1Mb <20>ֽ<EFBFBD>
|
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-11-15 18:22:43 +08:00
|
|
|
|
ERR_INVALID_CFG_CONTENT = 0X06, // <20>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD>ݴ<EFBFBD><DDB4><EFBFBD>
|
|
|
|
|
ERR_RETRANS_CONTENT = 0X07, // <20>ش<EFBFBD><D8B4>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
ERR_PERMISSION_DENIED = 0X08, //д<>ļ<EFBFBD>Ȩ<EFBFBD><EFBFBD><DEB2><EFBFBD>
|
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-11-15 18:22:43 +08:00
|
|
|
|
Frame_Echo_Request = 0x02, //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֡
|
|
|
|
|
Frame_DeviceData_Request = 0x03, //<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>
|
|
|
|
|
Frame_Configure_DB_Request = 0x04, //<2F>ϴ<EFBFBD><CFB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<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-11-15 18:22:43 +08:00
|
|
|
|
#define FRAME_HEADER_LENGTH (5) // frame_type(1) + frame_len(4)
|
|
|
|
|
|
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()
|