I’m using:
SYSTEM_MODE(AUTOMATIC)
SYSTEM_THREAD(ENABLED)
and setting credentials on an unsecured network (my Macbook pro) like this
void setup()
{
Serial.begin(9600);
WiFiAccessPoint ap[5];
int found = WiFi.getCredentials(ap, 5);
bool gotMyMacCreds = false;
for (int i = 0; i < found; i++) {
if(strstr(ap[i].ssid, "KonektedMac"))
gotMyMacCreds = true;
}
if(!gotMyMacCreds)
WiFi.setCredentials("KonektedMac");
waitUntil(Particle.connected);
// yada yada
network is set up like this:
I can connect other devices to the unsecured network, but my Photons will not connect…
I am trying to set up a product demo, anyone see my issue?
It probably won’t do so well if I have to futz with networking for a half hour before I demo the products!!
You may want to tell the WiFi module to give up trying to connect by calling WiFi.disconnect()
before WiFi.setCredentials()
- just to be on the safe side 
And then just call Particle.connect()
again
So I kept attempting to do this but could not get the unsecured network to stick. Wanting to see what was going on, I added a small wait for a pass of serial data so that I could see if the credentials were indeed set.
void setup()
{
Serial.begin(9600);
while(!Serial.available());
WiFiAccessPoint ap[5];
int found = WiFi.getCredentials(ap, 5);
bool gotMyMacCreds = false;
for (int i = 0; i < found; i++) {
if(strstr(ap[i].ssid, "KonektedMac"))
{
gotMyMacCreds = true;
Serial.println("had creds");
}
}
if(!gotMyMacCreds)
{
WiFi.setCredentials("KonektedMac");
Serial.println("set creds");
}
waitUntil(Particle.connected);
After attempting to get this set of credentials stored many times without the wait, the first run of the above code showed “set creds.” the 2nd time,: “had creds.”
Well it all worked out but I’m curious to know why the credentials didn’t seem to “stick” on the first (many) attempts.[quote=“ScruffR, post:2, topic:30973”]
You may want to tell the WiFi module to give up trying to connect by calling WiFi.disconnect() before WiFi.setCredentials() - just to be on the safe side
And then just call Particle.connect() again
[/quote]
Perhaps that has something to do with it but, I am onto other things t get this product finished!!!