Say it ain’t so…
How do I exit listen mode on a photon?
The following is an edit… I tried a bunch of stuff posted by @mdma and @ScruffR (thanks guys) But basically SYSTEM_THREAD(ENABLED) causes WiFi.listen(false) not to work. I have found this to always be true.
I tried a lot of different tests, but I think this is the most telling.
This works fine (as expected) example posted by mdma
isn’t it SYSTEM_THREAD(ENABLED)? that’s what the docs say. It appears to be threading… because I can see the D3 continuing to toggle. without threading it doesn’t toggle.
yeah that was a typoi. Threading is still a beta feature - we are rounding off the edges. To be absolutely certain your code is called regularly to interrupt listening mode, please use the system events as linked above.
I guess you'd need to change this.
Once your loop count exceeds 240 you will be triggering both statements in short succession.
I guess this is not what you want, is it?
Maybe something like this would be better
// only between 120 and 240 start listening
if((120 < loop_cnt && loop_cnt < 240) && !WiFi.listening()) WiFi.listen();
// beyond 240 stop listening
if((loop_cnt > 240) && WiFi.listening()) WiFi.listen(false);
I tried a bunch of stuff posted by @mdma and @ScruffR (thanks guys) But basically SYSTEM_THREAD(ENABLED) causes WiFi.listen(false) not to work. I have found this to always be true.
I tried a lot of different tests, but I think this is the most telling.
This works fine (as expected) example posted by mdma
I noticed this… If I load the following code and configure the device using the serial terminal (once the device is in listen mode) this connects fine. Whatever the system does at the end of Serial configuration needs to be done with WiFi.listen(false).
But it gives compilation error. I am building against the latest particle release. (using particle cli to compile). My platform is P1. I need to shut off WiFi.listen(). Please suggest how.
EDIT:
changing uint32_t to int solved the compilation issue. It got compiled but still the access point won't shut off.