Stored WiFi Credentials get duplicated

I have noticed an issue with the stored WiFi credentials getting duplicated. For example I connect to WAP 1 and use the photon for a while and then move it another location/WAP. During startup it tries to connect to the stored network (WAP 1) but then seems to take an age. I would expect it to timeout and quit trying after trying the one stored network but instead it takes 5 x timeout time and if I then inspect the stored credentials I find the following
Is there a reason why the credentials for WAP 1 are being duplicated.

Have you by any chance used setCredentials() in any of your sketches?
You can always wipe the stored credentials by holding SETUP for 10+ seconds of calling WiFi.clearCredentials().

I’ve never seen a dublication happening by itself.

1 Like

Hi @ScruffR

I have some user admin commands and I only call WiFi.setCredentials() in there. It would be curious (but not impossible) if someone entered the same details many times - the WiFi.setCredentials() does not check if the same details are stored already.

I have commands to list the stored WAPs and clear all stored WAPs with WiFi.clearCredentials().

SETUP button is not accessible in the device - so that is not an option.

I believe this is expected behavior. Imagine if you had two networks with the same SSID but different passwords. If setCredentials overwrote based on SSID it would clobber a valid SSID when used.


If I entered the wrong password for WAP1 several times, the wifi module will store each entry of WiFi.setCredentials() and since it does not know if the password is correct or not this is would then show as:


Correct? I am just trying to understand why I have seen 5 of the same network in the cache. The problem for the performance of the device in the field is that every time a wifi and cloud connect is requested it will cycle through the list of 5 and timeout trying on each one.

Yes. It’s a circular buffer.


The issue I am facing is that if the device has been connected to a WAP and is then taken somewhere else since 0.6.0 it now tries to connect to wifi but is blocking the main loop even though I have SYSTEM_THREAD(ENABLED) and I have timed out of waiting for WiFi.ready().

I am using WiFi.connect(WIFI_CONNECT_SKIP_LISTEN).

I am not using waitFor() - dating back to when waitFor() was blocking.
Are there ways of stopping the system trying to connect to all 5 stored WAPs in sequence?



I have just tried it MANUAL and this does not seem to make any difference.

After a session of tracing down the issue turned out to be a Particle.publish() which took 23 seconds to time out and return a failed send. Mystery solved!

Got to end with a question - is there a way to determine if the credentials set have an incorrect password or security key?

Merry Christmas!