Only last 2 SSIDs remembered on Photon?

The documentation says that the photon remembers the last 5 WiFi credentials set, yet I am only able to get the last 2. With the following lines, only the last 2 work and the first one seems to be forgotten. This behavior is consistent even as I switch around the order of the SSIDs. Is anyone able to get the photon to jump between 3 or more saved SSIDs with the latest 0.4.5 firmware?

WiFi.setCredentials("SSID1", "pass", WPA2, WLAN_CIPHER_AES);
WiFi.setCredentials("SSID2", "pass", WPA2, WLAN_CIPHER_AES);
WiFi.setCredentials("SSID3", "pass", WPA2, WLAN_CIPHER_AES);

Thanks for the issue report - I’ll look into this.

Just a fyi - adding this code in your application isn’t a good idea since it causes a flash erase on each startup of the application. This could lead to premature flash wear. It’s best to avoid the clearCredentials() call and instead only call setCredentials() for those networks you need. Alternatively, store a flag in EEPROM, which you set after setting up the wifi credentials, so the credentials are set up only once.

I’ve fixed this - the Wi-Fi credentials management code was using memcpy() rather than memmove(). I only learned today while researching this issue that memcpy is not safe to use when the regions are overlapping. (Yet all previous implementations that I’ve used have made it safe to copy overlapping regions.)

The issue is fixed in the develop branch and will be available for 0.4.6. :smile:


Wow thanks for the quick response and fix!