Xinyuan-LilyGO / LilyGo-Cam-ESP32S3

46 stars 17 forks source link

AllFunction assert failed: tcpip_send_msg_wait_sem IDF/components/lwip/lwip/src/api/tcpip.c:455 (Invalid mbox) #5

Closed GaryInSanDiego closed 1 month ago

GaryInSanDiego commented 1 year ago

I setup the AllFunction example to connect to my WIFI router.

In utilities.h, I changed this setting to false // Set this to true if using AP mode

define USING_AP_MODE false

In networks.cpp, I added my SSID and Password

} else { // If using station mode, please fill in the wifi ssid and password here wifiMulti.addAP("mySSID","myPassword"); wifiMulti.addAP("ssid_from_AP_2", "your_password_for_AP_2"); wifiMulti.addAP("ssid_from_AP_3", "your_password_for_AP_3"); }

When uploaded to the LilyGo T-Camera-S3 board, I received the following assert error every 5 seconds: assert failed: tcpip_send_msg_wait_sem IDF/components/lwip/lwip/src/api/tcpip.c:455 (Invalid mbox) rebooting...

I added print statements to debug: Started OLED setupServer: server.on() setupServer: server.onNotFound() setupServer: server.begin() In WebServer::begin() Webserver::begin close() Webserver::begin _server(aka WifiServer).begin() In sockets.h socket() return lwip_socket(domain=2, type=1, protocol=0) assert failed: tcpip_send_msg_wait_sem IDF/components/lwip/lwip/src/api/tcpip.c:455 (Invalid mbox)

The problem was a socket() in tcpip.c was being created (from server.begin->WebServer.begin->WifiServer.begin), however the WIFI had not been started yet, so the socket creation failed.

I SOLVED the problem by adding wifiMulti.run() to the end of the else statement in networks.cpp (to start the WIFI):

} else {
    // If using station mode, please fill in the wifi ssid and password here
    wifiMulti.addAP("mySSID","myPassword");
    wifiMulti.addAP("ssid_from_AP_2", "your_password_for_AP_2");
    wifiMulti.addAP("ssid_from_AP_3", "your_password_for_AP_3");

    Serial.println("Connecting Wifi...");
    if (wifiMulti.run() == WL_CONNECTED) {
        Serial.println("");
        Serial.println("WiFi connected");
        Serial.println("IP address: ");
        Serial.println(WiFi.localIP());
    }
}

Note: loopNetwork(), (just below the else statement), also executes wifiMulti.run(). It is called repeatedly by the loopPeripherals() in main.cpp. If the WIFI is still connected when wifiMult.run() is executed, it simply returns.

void loopNetwork() { if (!isAP) { wifiMulti.run(); } }

I also moved voiceWakeup.cpp out of the AllFunction folder as it had about 11 errors, and it appears it was not being used by AllFunction.

AllFunction WORKS SUCCESSFULLY. Both the USING_AP_MODE set to false and USING_AP_MODE set to true are successful.

It took me awhile to understand that when I set USING_AP_MODE to true (in AllFunction), the LilyGo T-Camera-S3 board sets up a WIFI hotspot that I can connect to in the WIFI screen on my Android phone, and after doing that, I can view the camera stream in the Chrome browser on my Android phone.

lewisxhe commented 1 year ago

I remember I verified the problem connecting to the hotspot, I'm on vacation now, I'll retest once my vacation is done, thanks for the feedback