I am having a problem with using the setCredentials() function with the Photon. I am trying to add another WIfi network in code while in a SYSTEM_MODE(SEMI_AUTOMATIC) state…
If I have the Photon connected to the cloud, using the setCredentials() function to add another router to the Photon works.
If I disable the WiFi in the Photon using the SYSTEM_MODE(SEMI_AUTOMATIC), using the setCredentials() function later in the code fails.
Also, if I clear all WiFi networks on the Photon by holding the MODE button until the LED flashes “fast blue”, the setCredentials() function later in the code fails.
So other than being connected to the cloud – is there any way to use the setCredentials() function?
Acutally SYSTEM_MODE(SEMI_AUTOMATIC) starts off with WiFi.off()
So yes, WiFi is disabled on startup, but in order to write new credentials to it the module you'd need to switch it on via WiFi.on().
Interesting (and a bit strange) that the WiFi radio needs to be on to use the setCredentials() function…
And to the other point – if I clear all WIFi credentials by holding the MODE button until the fast blue flash and then reboot the Photon to the GREEN LED flashing state – using the setCredentials() function also fails as well.
Is it a requirement that the Photon be connected to the Internet to use setCredentials()?
Not the radio but the hardware module which will store the creds internally - same for clearing the creds.
To actually turn on the radio carrier you'd use WiFi.connect().
The micro controller and the radio module are two separet units under the metal shield on the Photon. The controler will power down the module when it's not needed but needs to be able to communicate with it when data should be sent to it (including for internal use like storing data).