实验三 麒麟座V3.0综合应用代码-MQTT
一.连接方式
修改4个参数 devID(设备ID) apiKey(APIKey) proID(产品ID) auif(鉴权信息)
ONETNET_INFO oneNetInfo = {"24333720", "=q05iRiQ8gtIuhfhEguSQvPmr64=",
"112899", "q321",
"183.230.40.39", "6002",
7,
NULL, 0, 0, 0, 1};
结构体信息如下:
typedef struct
{
char devID[15];
char apiKey[35];
char proID[10];
char auif[50];
char ip[16];
char port[8];
const unsigned char protocol; //协议类型号1-edp 2-nwx 3-jtext4-Hiscmd
//5-jt808 6-modbus 7-mqtt
//8-gr20 9-reg 10-HTTP(自定义)
unsigned char *cmd_ptr; //平台下发的命令
unsigned char netWork : 1; //1-OneNET接入成功0-OneNET接入失败
unsigned char sendData : 3;
unsigned char errCount : 3; //错误计数
unsigned char heartBeat : 1; //心跳
} ONETNET_INFO;
下图中的4各参数修改成你自己的4个后,下载进去就行了
二.现象
2.1串口
Running...[2018-01-02 02:51:27.252]
ESP8266 Got IP[2018-01-02 02:51:29.639]
NET Device :Ok[2018-01-02 02:51:29.639]
Tips:CLOSE[2018-01-02 02:51:29.975]
AT+CIPSTART="UDP","edu.ntp.org.cn",123[2018-01-02 02:51:32.018]
Tips:CLOSE[2018-01-02 02:51:32.215]
UTC Time: 2018-1-2 14:51:33[2018-01-02 02:51:32.297]
Tips:CLOSE[2018-01-02 02:51:33.177]
AT+CIPSTART="TCP","183.230.40.33",80[2018-01-02 02:51:35.222]
can't find a available IP[2018-01-02 02:51:35.438]
Tips:CLOSE[2018-01-02 02:51:35.441]
STA Tips:AT+CIPSTART="TCP","183.230.40.39",6002[2018-01-02 02:51:35.858]
Tips:ESP8266 STA_Mode OK[2018-01-02 02:51:35.993]
OneNet_DevLink[2018-01-02 02:51:35.996]
PROID: 112899,AUIF: q321,DEVID:24333720[2018-01-02 02:51:35.999]
Tips:HeartBeat OK[2018-01-02 02:51:36.065]
Tips:HeartBeat OK[2018-01-02 02:51:36.076]
Tips:HeartBeat OK[2018-01-02 02:51:36.085]
Tips:HeartBeat OK[2018-01-02 02:51:36.095]
Tips:HeartBeat OK[2018-01-02 02:51:36.105]
Tips:连接成功[2018-01-02 02:51:36.115]
Tips:连接成功[2018-01-02 02:51:36.325]
Subscribe Topic: kylinV24Test[2018-01-02 02:51:36.334]
Subscribe Topic: pcTopic[2018-01-02 02:51:36.334]
Tips:MQTT Subscribe OK[2018-01-02 02:51:36.789]
Tips:OneNet_SendData-MQTT_TYPE3[2018-01-02 02:51:42.543]
Send 234 Bytes[2018-01-02 02:51:42.543]
Tips:MQTT Publish Send OK[2018-01-02 02:51:42.673]
Tips:HeartBeat OK[2018-01-02 02:51:47.654]
Tips:OneNet_SendData-MQTT_TYPE3[2018-01-02 02:51:57.576]
Send 233 Bytes[2018-01-02 02:51:57.576]
Tips:MQTT Publish Send OK[2018-01-02 02:51:57.889]
Tips:HeartBeat OK[2018-01-02 02:52:07.664]
Tips:OneNet_SendData-MQTT_TYPE3[2018-01-02 02:52:12.606]
Send 234 Bytes[2018-01-02 02:52:12.606]
Tips:MQTT Publish Send OK[2018-01-02 02:52:12.724]
2.2 网页上
DATA_STREAM-MQTT "在线"
网页设备数据(数据流展示)
同上,13种数据一样.