我想在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