//技小新 www.jixin.pro 学电子,找小新。技小新有最新的模块,有最新的教程!
//MQTT单片机编程 小工具由 <零妖> 精心打造,BUG反馈问题探讨在技新瓜棚。或者QQ:1827702167
//连接报文:
unsigned char MQTT_Connect[]={ 0x10,0x95,0x01,0x00,0x04,0x4d,0x51,0x54,0x54,0x04,
0xc2,0x00,0x64,0x00,0x3d,0x46,0x45,0x53,0x41,0x32,
0x33,0x34,0x46,0x42,0x44,0x53,0x32,0x34,0x7c,0x73,
0x65,0x63,0x75,0x72,0x65,0x6d,0x6f,0x64,0x65,0x3d,
0x33,0x2c,0x73,0x69,0x67,0x6e,0x6d,0x65,0x74,0x68,
0x6f,0x64,0x3d,0x68,0x6d,0x61,0x63,0x73,0x68,0x61,
0x31,0x2c,0x74,0x69,0x6d,0x65,0x73,0x74,0x61,0x6d,
0x70,0x3d,0x37,0x38,0x39,0x7c,0x00,0x20,0x47,0x35,
0x59,0x43,0x70,0x31,0x47,0x6e,0x34,0x70,0x67,0x45,
0x6f,0x76,0x48,0x4a,0x4d,0x37,0x62,0x79,0x26,0x61,
0x31,0x44,0x44,0x54,0x74,0x57,0x6e,0x68,0x6c,0x46,
0x00,0x28,0x30,0x39,0x62,0x66,0x31,0x37,0x61,0x32,
0x65,0x61,0x32,0x34,0x62,0x37,0x30,0x62,0x38,0x36,
0x65,0x35,0x31,0x64,0x36,0x63,0x65,0x66,0x66,0x31,
0x37,0x63,0x65,0x64,0x39,0x39,0x39,0x33,0x64,0x38,
0x32,0x36,};
//连接成功服务器返回报文:
unsigned char MQTT_Connect_Reply[]={0x20,0x02,0x00,0x00,};
//设备发送心跳包:
unsigned char MQTT_Heart[]={0xc0,0x00};
//服务器回复心跳:
unsigned char MQTT_Heart_Reply[]={0xd0,0x00};
//断开连接报文:
unsigned char MQTT_DisConnect[]={ 0xe0,0x00,};
//属性上报TOPIC报文:
unsigned char MQTT_Post_Property[]={ 0x30,0xce,0x01,0x00,0x3f,0x2f,0x73,0x79,0x73,0x2f,
0x61,0x31,0x44,0x44,0x54,0x74,0x57,0x6e,0x68,0x6c,
0x46,0x2f,0x47,0x35,0x59,0x43,0x70,0x31,0x47,0x6e,
0x34,0x70,0x67,0x45,0x6f,0x76,0x48,0x4a,0x4d,0x37,
0x62,0x79,0x2f,0x74,0x68,0x69,0x6e,0x67,0x2f,0x65,
0x76,0x65,0x6e,0x74,0x2f,0x70,0x72,0x6f,0x70,0x65,
0x72,0x74,0x79,0x2f,0x70,0x6f,0x73,0x74,0x7b,0x0a,
0x20,0x20,0x20,0x20,0x22,0x69,0x64,0x22,0x20,0x3a,
0x20,0x22,0x37,0x38,0x39,0x22,0x2c,0x0a,0x20,0x20,
0x20,0x20,0x22,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,
0x22,0x3a,0x22,0x31,0x2e,0x30,0x22,0x2c,0x0a,0x20,
0x20,0x20,0x20,0x22,0x70,0x61,0x72,0x61,0x6d,0x73,
0x22,0x20,0x3a,0x20,0x7b,0x0a,0x20,0x20,0x20,0x20,
0x20,0x20,0x20,0x20,0x22,0x49,0x6e,0x64,0x6f,0x6f,
0x72,0x54,0x65,0x6d,0x70,0x65,0x72,0x61,0x74,0x75,
0x72,0x65,0x22,0x3a,0x2b,0x31,0x35,0x2e,0x35,0x0a,
0x20,0x20,0x20,0x20,0x7d,0x2c,0x0a,0x20,0x20,0x20,
0x20,0x22,0x6d,0x65,0x74,0x68,0x6f,0x64,0x22,0x3a,
0x22,0x74,0x68,0x69,0x6e,0x67,0x2e,0x65,0x76,0x65,
0x6e,0x74,0x2e,0x70,0x72,0x6f,0x70,0x65,0x72,0x74,
0x79,0x2e,0x70,0x6f,0x73,0x74,0x22,0x0a,0x7d,};
//订阅服务器TOPIC报文(响应设备上报属性用TOPIC):
unsigned char MQTT_Sub_Property[]={ 0x82,0x4a,0x00,0x7b,0x00,0x45,0x2f,0x73,0x79,0x73,
0x2f,0x61,0x31,0x44,0x44,0x54,0x74,0x57,0x6e,0x68,
0x6c,0x46,0x2f,0x47,0x35,0x59,0x43,0x70,0x31,0x47,
0x6e,0x34,0x70,0x67,0x45,0x6f,0x76,0x48,0x4a,0x4d,
0x37,0x62,0x79,0x2f,0x74,0x68,0x69,0x6e,0x67,0x2f,
0x65,0x76,0x65,0x6e,0x74,0x2f,0x70,0x72,0x6f,0x70,
0x65,0x72,0x74,0x79,0x2f,0x70,0x6f,0x73,0x74,0x5f,
0x72,0x65,0x70,0x6c,0x79,0x00,};
//订阅成功服务器返回报文:
unsigned char MQTT_Sub_Property_Success[]={0x90,0x03,0x00,0x7B,0x01,};
//取消订阅服务器TOPIC报文(响应设备上报属性用TOPIC):
unsigned char MQTT_UnSub_Property[]={ 0xa2,0x49,0x01,0xc8,0x00,0x45,0x2f,0x73,0x79,0x73,
0x2f,0x61,0x31,0x44,0x44,0x54,0x74,0x57,0x6e,0x68,
0x6c,0x46,0x2f,0x47,0x35,0x59,0x43,0x70,0x31,0x47,
0x6e,0x34,0x70,0x67,0x45,0x6f,0x76,0x48,0x4a,0x4d,
0x37,0x62,0x79,0x2f,0x74,0x68,0x69,0x6e,0x67,0x2f,
0x65,0x76,0x65,0x6e,0x74,0x2f,0x70,0x72,0x6f,0x70,
0x65,0x72,0x74,0x79,0x2f,0x70,0x6f,0x73,0x74,0x5f,
0x72,0x65,0x70,0x6c,0x79,};
//取消成功服务器返回报文:
unsigned char MQTT_UnSub_Property_Success[]={0xB0,0x02,0x01,0xC8,};
//服务器回复报文(响应设备上报属性):
unsigned char MQTT_Post_Property_Reply[]={ 0x30,0x9c,0x01,0x00,0x45,0x2f,0x73,0x79,0x73,0x2f,
0x61,0x31,0x44,0x44,0x54,0x74,0x57,0x6e,0x68,0x6c,
0x46,0x2f,0x47,0x35,0x59,0x43,0x70,0x31,0x47,0x6e,
0x34,0x70,0x67,0x45,0x6f,0x76,0x48,0x4a,0x4d,0x37,
0x62,0x79,0x2f,0x74,0x68,0x69,0x6e,0x67,0x2f,0x65,
0x76,0x65,0x6e,0x74,0x2f,0x70,0x72,0x6f,0x70,0x65,
0x72,0x74,0x79,0x2f,0x70,0x6f,0x73,0x74,0x5f,0x72,
0x65,0x70,0x6c,0x79,0x7b,0x0a,0x22,0x6d,0x65,0x74,
0x68,0x6f,0x64,0x22,0x3a,0x22,0x74,0x68,0x69,0x6e,
0x67,0x2e,0x73,0x65,0x72,0x76,0x69,0x63,0x65,0x2e,
0x70,0x72,0x6f,0x70,0x65,0x72,0x74,0x79,0x2e,0x73,
0x65,0x74,0x22,0x2c,0x0a,0x22,0x69,0x64,0x22,0x3a,
0x22,0x39,0x32,0x37,0x32,0x35,0x30,0x22,0x2c,0x0a,
0x22,0x70,0x61,0x72,0x61,0x6d,0x73,0x22,0x3a,0x20,
0x7b,0x22,0x4c,0x69,0x67,0x68,0x74,0x53,0x77,0x69,
0x74,0x63,0x68,0x22,0x3a,0x31,0x7d,0x0a,0x7d,};
//事件上报TOPIC报文:
unsigned char MQTT_Post_Matter[]={ 0x30,0xdb,0x01,0x00,0x4c,0x2f,0x73,0x79,0x73,0x2f,
0x61,0x31,0x44,0x44,0x54,0x74,0x57,0x6e,0x68,0x6c,
0x46,0x2f,0x47,0x35,0x59,0x43,0x70,0x31,0x47,0x6e,
0x34,0x70,0x67,0x45,0x6f,0x76,0x48,0x4a,0x4d,0x37,
0x62,0x79,0x2f,0x74,0x68,0x69,0x6e,0x67,0x2f,0x65,
0x76,0x65,0x6e,0x74,0x2f,0x7b,0x74,0x73,0x6c,0x2e,
0x65,0x76,0x65,0x6e,0x74,0x2e,0x69,0x64,0x65,0x6e,
0x74,0x69,0x66,0x65,0x72,0x7d,0x2f,0x70,0x6f,0x73,
0x74,0x7b,0x0a,0x20,0x20,0x20,0x20,0x22,0x69,0x64,
0x22,0x20,0x3a,0x20,0x22,0x37,0x38,0x39,0x22,0x2c,
0x0a,0x20,0x20,0x20,0x20,0x22,0x76,0x65,0x72,0x73,
0x69,0x6f,0x6e,0x22,0x3a,0x22,0x31,0x2e,0x30,0x22,
0x2c,0x0a,0x20,0x20,0x20,0x20,0x22,0x70,0x61,0x72,
0x61,0x6d,0x73,0x22,0x20,0x3a,0x20,0x7b,0x0a,0x20,
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x22,0x49,0x6e,
0x64,0x6f,0x6f,0x72,0x54,0x65,0x6d,0x70,0x65,0x72,
0x61,0x74,0x75,0x72,0x65,0x22,0x3a,0x2b,0x31,0x35,
0x2e,0x35,0x0a,0x20,0x20,0x20,0x20,0x7d,0x2c,0x0a,
0x20,0x20,0x20,0x20,0x22,0x6d,0x65,0x74,0x68,0x6f,
0x64,0x22,0x3a,0x22,0x74,0x68,0x69,0x6e,0x67,0x2e,
0x65,0x76,0x65,0x6e,0x74,0x2e,0x70,0x72,0x6f,0x70,
0x65,0x72,0x74,0x79,0x2e,0x70,0x6f,0x73,0x74,0x22,
0x0a,0x7d,};
//订阅服务器TOPIC报文(响应设备上报事件用TOPIC):
unsigned char MQTT_Sub_Matter[]={ 0x82,0x57,0x00,0x7b,0x00,0x52,0x2f,0x73,0x79,0x73,
0x2f,0x61,0x31,0x44,0x44,0x54,0x74,0x57,0x6e,0x68,
0x6c,0x46,0x2f,0x47,0x35,0x59,0x43,0x70,0x31,0x47,
0x6e,0x34,0x70,0x67,0x45,0x6f,0x76,0x48,0x4a,0x4d,
0x37,0x62,0x79,0x2f,0x74,0x68,0x69,0x6e,0x67,0x2f,
0x65,0x76,0x65,0x6e,0x74,0x2f,0x7b,0x74,0x73,0x6c,
0x2e,0x65,0x76,0x65,0x6e,0x74,0x2e,0x69,0x64,0x65,
0x6e,0x74,0x69,0x66,0x65,0x72,0x7d,0x2f,0x70,0x6f,
0x73,0x74,0x5f,0x72,0x65,0x70,0x6c,0x79,0x00,};
//订阅成功服务器返回报文:
unsigned char MQTT_Sub_Matter_Success[]={0x90,0x03,0x00,0x7B,0x01,};
//取消订阅服务器TOPIC报文(响应设备上报事件用TOPIC):
unsigned char MQTT_UnSub_Matter[]={ 0xa2,0x56,0x01,0xc8,0x00,0x52,0x2f,0x73,0x79,0x73,
0x2f,0x61,0x31,0x44,0x44,0x54,0x74,0x57,0x6e,0x68,
0x6c,0x46,0x2f,0x47,0x35,0x59,0x43,0x70,0x31,0x47,
0x6e,0x34,0x70,0x67,0x45,0x6f,0x76,0x48,0x4a,0x4d,
0x37,0x62,0x79,0x2f,0x74,0x68,0x69,0x6e,0x67,0x2f,
0x65,0x76,0x65,0x6e,0x74,0x2f,0x7b,0x74,0x73,0x6c,
0x2e,0x65,0x76,0x65,0x6e,0x74,0x2e,0x69,0x64,0x65,
0x6e,0x74,0x69,0x66,0x65,0x72,0x7d,0x2f,0x70,0x6f,
0x73,0x74,0x5f,0x72,0x65,0x70,0x6c,0x79,};
//取消成功服务器返回报文:
unsigned char MQTT_UnSub_Matter_Success[]={0xB0,0x02,0x01,0xC8,};
//服务器回复报文(响应设备上报事件):
unsigned char MQTT_Post_Matter_Reply[]={ 0x30,0xa9,0x01,0x00,0x52,0x2f,0x73,0x79,0x73,0x2f,
0x61,0x31,0x44,0x44,0x54,0x74,0x57,0x6e,0x68,0x6c,
0x46,0x2f,0x47,0x35,0x59,0x43,0x70,0x31,0x47,0x6e,
0x34,0x70,0x67,0x45,0x6f,0x76,0x48,0x4a,0x4d,0x37,
0x62,0x79,0x2f,0x74,0x68,0x69,0x6e,0x67,0x2f,0x65,
0x76,0x65,0x6e,0x74,0x2f,0x7b,0x74,0x73,0x6c,0x2e,
0x65,0x76,0x65,0x6e,0x74,0x2e,0x69,0x64,0x65,0x6e,
0x74,0x69,0x66,0x65,0x72,0x7d,0x2f,0x70,0x6f,0x73,
0x74,0x5f,0x72,0x65,0x70,0x6c,0x79,0x7b,0x0a,0x22,
0x6d,0x65,0x74,0x68,0x6f,0x64,0x22,0x3a,0x22,0x74,
0x68,0x69,0x6e,0x67,0x2e,0x73,0x65,0x72,0x76,0x69,
0x63,0x65,0x2e,0x70,0x72,0x6f,0x70,0x65,0x72,0x74,
0x79,0x2e,0x73,0x65,0x74,0x22,0x2c,0x0a,0x22,0x69,
0x64,0x22,0x3a,0x22,0x39,0x32,0x37,0x32,0x35,0x30,
0x22,0x2c,0x0a,0x22,0x70,0x61,0x72,0x61,0x6d,0x73,
0x22,0x3a,0x20,0x7b,0x22,0x4c,0x69,0x67,0x68,0x74,
0x53,0x77,0x69,0x74,0x63,0x68,0x22,0x3a,0x31,0x7d,
0x0a,0x7d,};
//订阅服务器TOPIC报文(响应“服务器设置设备属性”):
unsigned char MQTT_Sub_SetProperty[]={ 0x82,0x45,0x00,0x7b,0x00,0x40
评论0