【发布时间】:2015-03-13 07:44:25
【问题描述】:
我正在尝试使用 sim 900 gprs 调制解调器在 pic 微控制器中实现 MQTT 协议,我已经阅读了 mqtt 文档版本 3.1。成功地我可以使用以下命令从 gprs 调制解调器连接到 myserver ip(117.218.81.15) ...
- 在
- 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;在 void main 函数中,代码是
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
标签: tcp pic at-command mqtt gprs