0
Lion Wang

MQTT在發送訊息一陣子後就會送不出去,Error 訊息如下:

[107424]mqtt:Wi-Fi connected.
[107427]mqtt:Connect Network "192.168.17.181"
[107432]mqtt:addr = 192.168.17.181
[107562]mqtt:"192.168.17.181" Connected
[107566]mqtt:Start MQTT connection
[107570]mqtt:MQTT Connected
[107573]mqtt:Publish Topics: LASS/Test/Innocomm/Pm25Ameba/CM05
[107581]mqtt:Read packet type: 2
[107696]mqtt:Read packet type: 4
[108579]mqtt:Return code from yield is -1

[MEM] After do cmd, available heap 57992

#
[118074]mqtt:Wi-Fi connected.
[118077]mqtt:Connect Network "192.168.17.181"
[118081]mqtt:addr = 192.168.17.181
[118085]mqtt:Return code from network connect is -1
[119090]mqtt:addr = 192.168.17.181
[119093]mqtt:Return code from network connect is -1

看了一下source code是卡在NetworkConnect

mqtt_printf(MQTT_INFO, "Wi-Fi connected.");
mqtt_printf(MQTT_INFO, "Connect Network \"%s\"", address);
while ((rc = NetworkConnect(&network, address, 1883)) != 0){
mqtt_printf(MQTT_INFO, "Return code from network connect is %d\n", rc);
vTaskDelay(1000 / portTICK_PERIOD_MS);
}
mqtt_printf(MQTT_INFO, "\"%s\" Connected", address);

但PC可以ping到device,請問可能是哪裡出錯嗎?

lion@lion -ThinkCentre-M72e:~/samba_share$ ifconfig
enp2s0 Link encap:Ethernet HWaddr d4:3d:7e:a1:d0:b0
inet addr:192.168.17.181 Bcast:192.168.23.255 Mask:255.255.248.0
inet6 addr: fe80::dfe4:8131:838e:8bcc/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:136263795 errors:0 dropped:0 overruns:0 frame:0
TX packets:49021040 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:118898168275 (118.8 GB) TX bytes:5588584939 (5.5 GB)

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:56594 errors:0 dropped:0 overruns:0 frame:0
TX packets:56594 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:87218040 (87.2 MB) TX bytes:87218040 (87.2 MB)

lion@lion -ThinkCentre-M72e:~/samba_share$ ping 192.168.24.50
PING 192.168.24.50 (192.168.24.50) 56(84) bytes of data.
64 bytes from 192.168.24.50: icmp_seq=1 ttl=254 time=68.4 ms
64 bytes from 192.168.24.50: icmp_seq=2 ttl=254 time=100 ms
64 bytes from 192.168.24.50: icmp_seq=3 ttl=254 time=215 ms
64 bytes from 192.168.24.50: icmp_seq=4 ttl=254 time=36.2 ms
64 bytes from 192.168.24.50: icmp_seq=5 ttl=254 time=57.9 ms

Lion Wang 回答了