esp8266-std/include/protocol.h

120 lines
2.4 KiB
C

#ifndef PROTOCOL_H
#define PROTOCOL_H
#define CLOUND_API_CMD_RSP_BASE (10000)
#define PROTOCOL_VERSION (1)
typedef enum
{
MSG_TYPE_BYPASS = 0,
MSG_TYPE_SHADOW = 1,
MSG_TYPE_BIGDATA = 2,
} MCU_MSG_TYPE;
typedef enum
{
GET_DEV_ID = 1,
CONFIG_AP = 2,
EXIT_SOFTAP_MODE = 3,
MSG_BYPASS = 1000,
} CLOUND_API_CMD;
typedef enum
{
CRYPTO_NONE = 0,
CRYPTO_MD5 = 1,
CRYPTO_AES = 2,
} CRYPTO_TYPE;
typedef enum
{
CRYPTO_ENCODE = 0,
CRYPTO_DECODE = 1
} CRYPTO_OPT;
typedef struct
{
char* cpuId;
char* macAddr;
char* productSign;
} RSP_GET_DEVID_PRO, *PRSP_GET_DEVID_PRO;
typedef struct
{
char* mcuCmd;
} BYPASS_INFO, *PBYPASS_INFO;
typedef struct
{
char* bssid;
char* ssid;
char* passwd;
char* gbkssid;
char* gbkpasswd;
} CFG_AP_INFO, *PCFG_AP_INFO;
typedef struct
{
int cmdId;
int ver;
int cryptoType;
int timeStamp;
char* msgContent;
} CLOUND_API, *PCLOUND_API;
typedef struct
{
BYPASS_INFO reported;
} SHADOW_STATE, *PSHADOW_STATE;
typedef struct
{
char* method;
int version;
SHADOW_STATE state;
} SHADOW_UPDATE, *PSHADOW_UPDATE;
typedef struct
{
int errNo;
char* errMsg;
} CLOUND_API_RSP_ERR, *PCLOUND_API_RSP_ERR;
#if 0
typedef struct
{
unsigned char msgTag;
unsigned char msgLen;
unsigned char msgDev;
unsigned char msgSync;
unsigned char msgResrved[2];
unsigned char msgSeq;
unsigned char msgVer;
unsigned char proVer;
unsigned char msgId;
unsigned char* pData;
} MCU_MSG, *PMCU_MSG;
#endif
typedef struct MCU_MSG_INFO
{
char* pMessage;
int msgType;
struct MCU_MSG_INFO *next, *prev;
} *PMCU_MSG_INFO;
typedef struct
{
unsigned char* pMessage;
int msgSize;
} MQTT_MSG, *PMQTT_MSG;
int ProtocolInitEnv(void);
int ProtocolProcess(char* pStrJson);
int ProCacheMCUMsg(unsigned char* pData, int msgSize, int msgType);
char* ProGetMCUMsg(int* pMsgType);
int ProCacheMQTTMsg(char* pData);
#endif