I am facing a weird issue with Wifi.setCredentials method on photon (system firmware 0.6.2) . Following code was working till yesterday. I am using clickbutton library to set wifi credentials on two clicks on the following sample code.
#include <clickButton.h>
const int BUTTON_PIN = A4;
ClickButton resetButton(BUTTON_PIN, LOW, CLICKBTN_PULLUP);
int function = 0;
SYSTEM_THREAD(ENABLED);
void setup() {
Serial.begin(9600);
Serial.println("setup start..");
if(WiFi.hasCredentials())
WiFi.clearCredentials();
delay(300);
WiFi.on();
WiFi.listen();
Serial.println("setup end..");
}
void loop(){
if(WiFi.ready())
{
Serial.println("wifi ready");
if(WiFi.listening())
WiFi.listen(false); //to solve particle still connected to mobile app issue
if(!Particle.connected())
{
Serial.println("cloud connection..");
Particle.connect();
}
}
// Update button state
resetButton.Update();
if (resetButton.clicks != 0) function = resetButton.clicks;
if(resetButton.clicks == 1)
{
Serial.println("Single click..");
}
if(function == 2){
Serial.println("wifi cred set..");
WiFi.setCredentials("test", "test1234");
WiFi.listen(false);
delay(100);
Particle.connect();
delay(100);
Serial.println("wifi set fin..");
}
function = 0;
}
And yesterday Wifi.setCredentials stopped functioning, photon just sits there breathing blue.
Before this issue it went to green and then cyan by connecting to the wifi as expected for the same code.
Yesterday we changed the system mode to semi_automatic just after enabling system thread and the code went back to working. Added following line below SYSTEM_THREAD(ENABLED);
SYSTEM_MODE(SEMI_AUTOMATIC);
But today the same code which was working yesterday started showing same issue.
I created the following code to test the issue in build which stopped working today and was fine yesterday.
SYSTEM_THREAD(ENABLED);
SYSTEM_MODE(SEMI_AUTOMATIC);
void setup() {
if(WiFi.hasCredentials())
WiFi.clearCredentials();
delay(5000);
Serial.println("clearCredentials done");
WiFi.on();
WiFi.setCredentials("test","test1234");
delay(1000);
Particle.connect();
Serial.println("setup complete");
}
void loop() {
}
I have a compiled bin file of the first code block above which is working like expected and I am sure that it was built for version 0.6.2 system firmware.(Even tried selecting 0.6.0 in build.particle for the new code while compiling but it didn’t work),… The working bin file was taken from build.io on Sep 28.
Please help me resolve this… I’m going crazy over this one… …