Is there a CLI method for:
- Getting to see the saved APs and cipher modes, similar to the Wifi.getCredentials() in code?
- Clearing Credential Cache
- A way to see which AP the device is connected to without anything in code to help with this (such as Serial.println() etc.)
Do credentials get saved even if connection was not successful?
When I try Wifi.getCredentials() in code it seems to hang at this method, or blocks for a really long time, so long that I haven’t waited long enough to see.
- No (would pose some security risk)
- Not that I know of - but holding SETUP for 10+ sec will do that
Credentials do get saved even for non-present networks if the enc cipher could be obtained.
What status was your device in when you called
I had the getCredentials() code being called in the setup() function, with a Serial.println() in a loop for all saved credentials. The loop never executed.
No (would pose some security risk)
Not if one required to be logged in, no?
Not that I know of - but holding SETUP for 10+ sec will do that
Aah, thanks, I should try that?
What is going on is that I set up an AP, which it can’t connect to so it connects to another AP (from cache) and I assume it connected to the new one. That got me in a fix because I assumed I was using the new AP
I am hopping on this thread to save opening a new one! It is related I promise!
Is there any circumstance where WiFi.clearCredentials() can return true yet not have cleared all credentials? I.e. the wifi network currently connected to is not cleared.Should the wifi module be off before issuing a wifi.clearCredentials?
Is there a way to clear only certain credentials from the cache/store? A bit like - 'Forget this network" on an iPhone.
I’d say you at least should
WiFi.disconnect() - but I’m rather positive that even the currently connected WiFi would be cleared, but I don’t think you’d get disconnected.
Have you tried a reset after you called
WiFi.clearCredentials() and did it still reconnect?
And no, there is no way to only remove a single set of credentials.
You’re correct. From my experience with clearCredentials(), all credentials are cleared including the current one.
Thanks for getting back on these points - I don’t want to throw a reset as the clear credentials is in an admin menu to manage wifi connections! I will include the wifi.disconnect() before the wifi.clearcredentials() just to be safe.
Without being able to selectively forget networks it is a bit clumsy for an end-user to move a device from one network to another, especially if the device is in an area with many WAPs available but you only want to connect to one specific one - I guess I could setCredentials for a stored WAP with the password blank - unless you know otherwise? (Or you don’t understand what I am getting at!)
Thanks - I would be interested if you could share your experience in getting devices to wifi connect for the first time and thereafter after a reset. I am finding that some devices take a lot of tries to connect and in the same location/circuit others are very fast or instant.
I have the same experience. That is the amount of time a device takes to connect changes (sometimes a long time and sometimes almost instant). This doesn’t seem to have any bearing on:
- The number of cached credentials
- Resetting credentials
- Which network the device was connected to the last time
If I am connected to a WAP, then check if those credentials are stored, clear all the credentials (and get wifi disconnected automatically) and then scan for available networks and select and enter the credentials for the same same WAP (or any other available) followed by
WiFi.connect(WIFI_CONNECT_SKIP_LISTEN); it stays listening / flashing blue. Any idea why this is the happening and what should I do to get it back connected. Turning the photon off /hard reset works - but I don’t want to this.
SYSTEM_MODE() are you using?
Are you using
If you are in
AUTOMATIC mode, I’d guess that you’ll directly fall into Listening Mode and don’t even get to your
To avoid this, either use a non-AUTOMATIC mode or explicitly/“manually” disconnect before clearing credentials.
Something else you could/should do is to add a delay (or a
WiFi.connect() - and maybe also a
I always the following, I should have said:
As you said WiFi.clearCredentials() does not clear the currently connected WAP unless I put WiFi.disconnect() before it.
I haven’t had a chance to check out the whether toggling wifi.off/wifi.on then wifi.connect solves the always listening problem.
Small update: I have another command to allow a user to disconnect from the current connected WAP. I have a dynamic indicator on the device screen and to my surprise when I call WiFi.disconnect() it briefly goes off and then within a couple of seconds reconnects to wifi and particle cloud. Should I be turning off the radio module WiFi.off()? Or is this happening because I am not doing Particle.disconnect() before the WiFi.disconnect()?