BW16 不停出現[INFO] [ard_socket.c][send_data] err = 268870584

你好,我在建立一個稍微複雜的程式,其中使用了

  • ap+sat模式的wifi
  • MQTT連線傳訊息
  • 檢查一個GPIO的訊號
  • RTOS分別處理wifi、MQTT、ap web server、GPIO的任務

我現在遇到不斷出現[INFO] [ard_socket.c][send_data] err = 268870584 的問題,而且在出現這訊息時,我的GPIO就算使用中斷也不會有反應,這個訊息出現頻率非常規律地約為7秒,請問怎麼辦?

以下是log

04:46:21.351 -> 
#calibration_ok:[2:19:11] 
04:46:21.397 -> 
0
04:46:21.397 -> 1
04:46:21.397 -> 2
04:46:21.397 -> saved SSID:willyNet
04:46:21.397 -> saved PASS:willy1510
04:46:21.397 -> 3
04:46:21.397 -> interface 0 is initialized
04:46:21.397 -> 
interface 1 is initialized
04:46:21.397 -> 
04:46:21.397 -> 

Initializing WIFI ...
04:46:21.569 -> 

WIFI initialized
04:46:21.569 -> 
IPv4 enabled
04:46:21.569 -> 

04:46:21.569 -> 

Starting AP ...
04:46:22.317 -> 

safebox_ap started
04:46:22.317 -> 
4
04:46:28.317 -> 
04:46:28.317 -> 
 [INFO] server_drv.cpp: WiFi server is set to non-blocking mode
04:46:28.317 -> 

04:46:28.317 -> 
 [INFO] Listen socket successfully
04:46:28.317 -> 
04:46:28.317 -> [INFO] Socket connect successfully 
04:46:28.317 -> 5
04:46:28.317 -> 6
04:46:28.317 -> 7
04:46:28.317 -> 8
04:46:28.317 -> 
04:46:28.317 -> 

RTL8721D[Driver]: set ssid [willyNet] 
04:46:28.317 -> 
MQTT waitin9
04:46:28.360 -> setup dong for wifi e
04:46:28.360 -> 
04:46:28.360 -> 
[Iconnection
04:46:28.360 -> NFO] [ard_socket.c][send_data] err = 268870584
04:46:28.360 -> 
04:46:28.360 -> 
[INFO] [ard_socket.c][send_data] err = 268870584
04:46:28.360 -> 
MQTT waiting for wifi connection
04:46:32.431 -> 
04:46:32.431 -> 

RTL8721D[Driver]: rtw_set_wpa_ie[1160]: AuthKeyMgmt = 0x2 
04:46:32.469 -> 
04:46:33.057 -> 

RTL8721D[Driver]: rtw_restruct_sec_ie[4279]: no pmksa cached 
04:46:33.090 -> 
04:46:33.212 -> 

RTL8721D[Driver]: start auth to 04:95:e6:19:df:08
04:46:33.212 -> 
04:46:33.212 -> 

RTL8721D[Driver]: auth alg = 2
04:46:33.212 -> 
04:46:33.212 -> 

RTL8721D[Driver]: 
04:46:33.212 -> 
OnAuthClient:algthm = 0, seq = 2, status = 0, sae_msg_len = 0
04:46:33.246 -> 
04:46:33.246 -> 

RTL8721D[Driver]: auth success, start assoc
04:46:33.246 -> 
04:46:33.246 -> 

RTL8721D[Driver]: association success(res=2)
04:46:33.246 -> 
04:46:33.293 -> 

RTL8721D[Driver]: ClientSendEAPOL[1650]: no use cache pmksa 
04:46:33.293 -> 
04:46:33.293 -> 

RTL8721D[Driver]: set pairwise key to hw: alg:4(WEP40-1 WEP104-5 TKIP-2 AES-4)
04:46:33.293 -> 
04:46:33.293 -> 

RTL8721D[Driver]: set group key to hw: alg:4(WEP40-1 WEP104-5 TKIP-2 AES-4) keyid:1
04:46:33.293 -> 
no MQTT connection.... reconnect MQTT
04:46:34.352 -> 
04:46:34.352 -> 

[INFO]server_drv.cpp:  start_client
04:46:34.352 -> 
 [INFO] Create socket successfully
04:46:34.398 -> 

04:46:34.398 -> 
 [ERROR] Connect to server failed
04:46:34.398 -> 

04:46:34.398 -> 
[INFO] [ard_socket.c][send_data] err = 268678275
04:46:34.398 -> 
04:46:35.390 -> 

Interface 0 IP address : 192.168.0.104
04:46:36.111 -> 
[INFO] [ard_socket.c][send_data] err = 268870584
04:46:36.111 -> 

04:46:36.111 -> 
[INFO] [ard_socket.c][send_data] err = 268870584
04:46:36.111 -> 
=========  reconnect MQTT fail  ==============
04:46:36.111 -> 
=========  reconnect MQTT fail  ==============
04:46:39.403 -> fail reason code=-4
04:46:43.183 -> 
04:46:43.183 -> 
[INFO] [ard_socket.c][send_data] err = 268870584
04:46:43.227 -> 

04:46:43.227 -> 
[INFO] [ard_socket.c][send_data] err = 268870584
04:46:43.227 -> 
no MQTT connection.... reconnect MQTT
04:46:44.425 -> 
04:46:44.425 -> 

[INFO]server_drv.cpp:  start_client
04:46:44.425 -> 
 [INFO] Create socket successfully
04:46:44.425 -> 

04:46:44.471 -> 
[INFO] Connect to Server successfully!
04:46:44.471 -> 
=========  reconnect MQTT success  ==============
04:46:50.295 -> 
04:46:50.295 -> 
[INFO] [ard_socket.c][send_data] err = 268870584
04:46:50.295 -> 

04:46:50.295 -> 
[INFO] [ard_socket.c][send_data] err = 268870584
04:46:50.339 -> 

04:46:57.441 -> 
[INFO] [ard_socket.c][send_data] err = 268870584
04:46:57.441 -> 

04:46:57.441 -> 
[INFO] [ard_socket.c][send_data] err = 268870584
04:46:57.441 -> 

04:47:04.540 -> 
[INFO] [ard_socket.c][send_data] err = 268870584
04:47:04.540 -> 

04:47:04.540 -> 
[INFO] [ard_socket.c][send_data] err = 268870584
04:47:04.540 -> 

04:47:11.625 -> 
[INFO] [ard_socket.c][send_data] err = 268870584
04:47:11.625 -> 

04:47:11.625 -> 
[INFO] [ard_socket.c][send_data] err = 268870584
04:47:11.670 -> 

04:47:18.756 -> 
[INFO] [ard_socket.c][send_data] err = 268870584
04:47:18.756 -> 

04:47:18.756 -> 
[INFO] [ard_socket.c][send_data] err = 268870584
04:47:18.756 -> 

04:47:25.874 -> 
[INFO] [ard_socket.c][send_data] err = 268870584
04:47:25.874 -> 

04:47:25.874 -> 
[INFO] [ard_socket.c][send_data] err = 268870584
04:47:25.874 -> 

Hi @liulk3

您提供的log當中顯示non-blocking mode, 您試著換成blocking mode且把ap 關掉來查看有沒有問題。然後, 在試著把sta 關掉且把ap開來查看有沒有問題。
謝謝。

我這裡有發現問題,你們提供的arduino API中,wifiClient的部分有一個operator bool()的功能,實作如下

#WiFiClient.cpp
WiFiClient::operator bool() {
    return _sock >= 0;
}
#WiFiClient.h
uint8_t _sock;

但_sock的定義卻會讓這功能永遠為true,初步退測試在這裡出現了問題。

我會使用operator bool()原本是按照現在範例程式寫的,我另外使用了aWOT這個http server處理liberary,他應該會替我處理原本範例中while迴圈讀取的工作,才遇到這個問題。

我有看出你們在WiFiClient::connected() 這個功能做了unit8和int8的兼容,所以我目前先改用這個函式確認是否有連接,現在基本沒問題了。

現在官方github上提供的程式目前還是有這個問題,在arduino IDE的編譯過程也可以看到編譯器跳出很多因此而生的warning,原廠的開發團隊應該注意此事。

Hi @liulk3
您説的在arduino IDE的編譯過程也可以看到編譯器跳出很多因此而生的warning是跑哪個範例和什麽warning log。
謝謝。