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.
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:
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.
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
If I flash my code onto the board again, and wait for onInit to run, the scan still fails
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()...
Don't worry about formatting, just type in the text and we'll take care of making sense of it. We will auto-convert links, and if you put asterisks around words we will make them bold.
Tips:
Create headers by underlining text with ==== or ----
To *italicise* text put one asterisk each side of the word
To **bold** text put two asterisks each side of the word
Embed images by entering: ![](https://www.google.co.uk/images/srpr/logo4w.png) That's the hard one: exclamation, square brackets and then the URL to the image in brackets.
* Create lists by starting lines with asterisks
1. Create numbered lists by starting lines with a number and a dot
> Quote text by starting lines with >
Mention another user by @username
For syntax highlighting, surround the code block with three backticks:
```
Your code goes here
```
Just like Github, a blank line must precede a code block.
If you upload more than 5 files we will display all attachments as thumbnails.
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
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 calledscanCB
. But I see multiplereturn
statements injswrap_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, butg_jsScanCallback
is assigned in line 894, andjswrap_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:
wifi.connect
-function, I get the scan error the next time I try to scan, and now it seems to hang foreverI have always gotten these two errors when I connect the board, but haven't given them much thought until now:
Thoughts?