#pragma once #pragma pack(1) typedef enum tagTopic : char { GateWayPublicTopic_Server = 0, ServerPublicTopic_GateWay = 1, }MQTT_Topic; typedef enum tagDataType : char { DT_GATEWAY_DATA = 0, DT_GATEWAY_ALARMDATA = 1, DT_GATEWAY_READDATA = 2, DT_GATEWAY_WRITEDATA = 3, DT_GATEWAY_CTRLDATA = 4, DT_WEB_CTRL = 5, DT_WEB_WRITE = 6, DT_GATEWAY_WRITE = 7 }MQTT_DataType; /* { "FsuCode": "31012010005", "type": "gateway-data", "IdCodeContent": [ { "OID": ".1.3.6.1.4.1.41475.4.98.1.1.1", "Value": "31012010005", "Factor": "" }, { "OID": ".1.3.6.1.4.1.41475.4.98.1.2.1", "Value": "10005", "Factor": "" } ], "TimeStamp": "2024-04-17 13:11:37" } */ typedef struct tagMsgData { MQTT_Topic mqtt_topic; // MQTT里的Topic MQTT_DataType mqtt_data_type; // MQTT里的type,使用MQTT_DataType枚举类型 unsigned short device_id; //OID里的98 unsigned int content_len; //整个MQTT包字符串的字节长度,4个字节 char content_data[1]; //MQTT包字符串的内容 }MessageData; #pragma pack()