我想在PIC单片机中使用SIM 900 gprs调制解调器实现MQTT协议,已经阅读过mqtt文档版本3.1。成功,我可以能够使从GPRS调制解调器连接到MYSERVER使用以下命令IP(117.218.81.15)...在PIC单片机中实现MQTT
- AT
- AT + CPIN?
- AT + CREG?
- AT + CGATT?
- AT + CIPSHUT
- AT + CIPSTATUS
- AT + CIPMUX = 0
- AT + CSTT = \ “INTERNET \” \ “\” \ “\”
- AT + CIICR
- AT + CIFSR
AT + CIPSTART = \ “TCP \”,\ “117.218.81.15 \” \ “1883 \”
作为每MQTT协议我写连接数据包功能的文档。 建立一个tcp连接后,我试图发送connect_packet()函数,我没有得到任何经纪人的确认..请帮我解决这个问题 我检查了wireshark网络分析工具我的数据到达1883 tcp端口,但我不明白为什么我没有得到任何确认?该connect_packet代码为
unsigned char topiclen = 0,time_out1=0,time_out2=0; unsigned char connectdatalen,packetlen; memset(buffer,0,sizeof(buffer)); time_out1 = (time_out >>8) & 0XFF; time_out2 = (time_out & 0XFF); topiclen = strlen(sacketid); connectdatalen = 2 + 6 + 1 + 1 + 2 + 2 + topiclen;
在无效的主要函数的代码是
packetlen = 2 + connectdatalen;
buffer[0] = 0X10; buffer[1] = connectdatalen; buffer[2] = 0x00; buffer[3] = 0X06; buffer[4] = 'M'; buffer[5] = 'Q'; buffer[6] = 'I'; buffer[7] = 's'; buffer[8] = 'd'; buffer[9] = 'p'; buffer[10] = 0x03; buffer[11] = 0x02; buffer[12] = time_out1; buffer[13] = time_out2; buffer[14] = (topiclen >> 8); buffer[15] = topiclen & 0XFF; for(i=0;i<packetlen;i++) { buffer[(i+16)] = sacketid[i]; } uart_puts(buffer); uart_puts("\x1A");uart_init(9600,16); DelayMs(100); gprs_init(); gprs_tcpconnect(); DelayMs(200); connect_packet("MQTT",180); memset(buffer,0,sizeof(buffer));
您使用哪个经纪商?您是否曾尝试在代理上启用详细日志记录? – hardillb 2015-03-13 09:02:09
蚊子经纪人....亚我已打开详细日志@ hardillb – 2015-03-13 10:07:28