Hello Blynk community.
An update on my progress with regard to this issue. After a few more hours of research i came across a post on the Blynk forum which worked like a charm to sort out the issue of the compile error. Thank you at @BTT . For anyone else experiencing the same problem, here is the link:
I played around with these lines of code, added a small segment of code I read in another post, to achieve automatic WiFi network selection and the resulting code segment that I have developed thus far looks like this:
void SetupBlynkConnection(){
wifi.setDHCP(1, 1, 1); //Enable dhcp in station mode and save in flash of esp8266
Blynk.config(wifi, auth, server, port);
Blynk.connectWiFi(ssid0, pass0);
//Check if the first network is avaiable and connect
if (Blynk.connectWiFi(ssid0, pass0)) {
Serial.println("Attempting to connect to Wifi network 1");
Blynk.connect(5000);
Blynk.run();
}
//Check if second network is available and connect
else if(!Blynk.connectWiFi(ssid0, pass0)){
Serial.println("Wifi network 1 is not available so establishing connection to Wifi network 2");
wifi.setDHCP(1, 1, 1); //Enable dhcp in station mode and save in flash of esp8266
Blynk.config(wifi, auth, server, port);
Blynk.connectWiFi(ssid1, pass1);
Blynk.connect(5000);
//Blynk.run();
if(Blynk.connectWiFi(ssid1, pass1)){
Serial.println("Connected to Blynk via Wifi network 2");
}
//if no networks are available then continue with rest of program
else{
Serial.println("No Wifi networks are avaialable for connection");
}
}
}
void CheckBlynkConnection(){
Connected2Blynk = Blynk.connected();
if(!Connected2Blynk){
Serial.println("Blynk connection status: Disconnected\nAttempting to re-establish connection to Blynk...");
SetupBlynkConnection();
Blynk.connect(5000);
Blynk.run();
}
else{
Serial.println("Blynk connection status: Connected");
}
}
This segment of code is able to successfully detect and select the network to connect to. All this works great when the second network is available only this is not the case when the first network is available: the new challenge that i am facing is that when the first network is available the SetupBlynkConnection() subroutine executes as expected but when the CheckBlynkConnection() subroutines executes it achieves a disconnected status continuously. I am playing around with the lines of code still but can’t seem to definitively determine why this is happening. Any advice from the community would be greatly appreciated.