You are reading a single comment by @rj and its replies. Click here to read the full conversation.
  • Hey 🙂,

    I'm working with the ESP32 in an application where I have to switch between being in AP mode, and connect to my home WiFi.

    Problem:
    I need to send a list of available access points created using the wifi.scan()-function, but sometimes an old scan seems to "hang" and I get the error: A scan is already in progress. forever.

    I found the place in the source code, that generates the error: jswrap_wifi_scan.

    Something strikes me as odd though;
    the variable for the callback function g_jsScanCallback is assigned in the beginning of that function, and released again in the end of a function called scanCB. But I see multiple return statements in jswrap_wifi_scan in case of different errors, so couldn't it be that the variable is assigned, but the scan never kicked off 🤔. It would never get cleared again.
    I'll admit, I can't figure out how the event that calls scanCB is finally kicked off, but g_jsScanCallback is assigned in line 894, and jswrap_wifi_scan could be exited only a few lines below at line 906, and I don't see the scan getting started anywhere in between.

    Observations:
    ... in any case, the problem is a bit hard to re-produce, but this is roughly what I observe:

    1. If I completely shut power off the board, and re-connect it, I'm allowed to scan. And successsfully perform scans after that. Starting an AP, and still perform scans after that.
    2. However, if I've had a failed attempt on connecting to wifi using bad credentials with the wifi.connect-function, I get the scan error the next time I try to scan, and now it seems to hang forever
    3. If I flash my code onto the board again, and wait for onInit to run, the scan still fails
    4. I have always gotten these two errors when I connect the board, but haven't given them much thought until now:

      WARNING: Scan stop failed
      WARNING: set rssi scan not implemeted yet
      Running onInit()...
      

    Thoughts?

About

Avatar for rj @rj started