I’m trying to pass a String for blynk server when calling Blynk.config or Blynk.begin but getting compiler errors. Not sure why this is occurring as I define my variables as String before passing to function (screen shots below for both Blynk.config and Blynk.begin examples):
The code all works if I replace local_server String with text “mylocal.com” within the Blynk.config function call, it only breaks (or compile error as shown) if I actually use the String local_server in the function call as per screen shot. I can’t work out why Blyn.config or Blynk.begin won’t take a string ?
For example below will not compile:
/* Comment this out to disable prints and save space */
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "YourAuthToken";
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "YourNetworkName";
char pass[] = "YourPassword";
String cloud_server = "blynk-cloud.com";
void setup()
{
// Debug console
Serial.begin(9600);
// Blynk.begin(auth, ssid, pass);
// You can also specify server:
// Blynk.begin(auth, ssid, pass, "blynk-cloud.com", 8442);
Blynk.begin(auth, ssid, pass, cloud_server, 8442);
//Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8442);
}
void loop()
{
Blynk.run();
// You can inject your own code or combine it with other sketches.
// Check other examples on how to communicate with Blynk. Remember
// to avoid delay() function!
}
But if you switch to Blynk.config() (for sketch operation even without connection) will having char work or do you still need to break out the WiFi connection first… and then is this correct syntax for both?
Interesting idea… but wouldn’t that potentially cause all sorts of issues when switching servers, all your widget settings would get reset (or changed to that server’s last know state - if you have that function coded)?
I could see that working if there was some way of keeping the servers themselves synchronized - may not even have to change Auth that way… Hey it’s open sourced, I’m sure someone will figure out a way
true. it really depends on the app. if you are relying on external sensor information you can just do a simple refresh and you are re-synced. Any other settings would revert to default values.
Very true. I would hate to be in the smart house run by multiple servers in a majority rule architecture with random server failures… lights a flickering, doors randomly opening and closing, the fridge giving up it frosty role and heading somewhere tropical.
Sci Fi dreaming aside… how would you get the app to determine which server to link with? It currently doesn’t even have the option to remember the Local IP if you temporarily switch to Cloud
obviously this is for redundancy or when maintenance required on a server you can switch to the other ! the hope is it hardly ever needs to occur. But when it does you have a plan !
a simple approach would be that you could have a simple rule that switches to next round-robin server if number of RECONNECT retries exceeds a specific value.