Also, some try and some strange result.
With a sketch with WiFi Manager, the sketch RUN with a invalid token too (of course not sync with the app but the sketch run, i can see temperature, etc etc).
This is the serial output:
[9167] Connecting to blynk-cloud.com:80
[9350] Invalid auth token
This is a invalid token
Check Run
Check Run
where i can see the print of INVALID TOKEN, but your:
if (Blynk.isTokenInvalid()){
Serial.println("This is a invalid token");
} else {
Serial.println("This is a valid token");
}
is work only if I call it with a timer in a void (I try to put everywhere, with no result in Monitor).
With a correct token, this is the output:
[3114] Connecting to blynk-cloud.com:80
[4227] Ready (ping: 61ms).
[6969] Time sync: OK
This is a valid token
So, seems ok.
Now, with this simple cleaned sketch and correct token (NO WIFI MANAGER):
bool tokenNotValid = Blynk.isTokenInvalid();
BlynkTimer timer;
void setup() {
Serial.begin(115200);
Blynk.begin(auth, ssid, pass);
if (Blynk.isTokenInvalid()){
Serial.println("This is a invalid token");
} else {
Serial.println("This is a valid token");
}
while (Blynk.connect() == false) {
}
timer.setInterval(5012L, checkRun);
}
void checkRun() {
Serial.println("Check Run");
}
void loop() {
Blynk.run();
timer.run();
}
The serial return me “This is a valid token” and the sketch RUN ok:
15:29:08.716 -> ___ __ __
15:29:08.716 -> / _ )/ /_ _____ / /__
15:29:08.716 -> / _ / / // / _ \/ '_/
15:29:08.716 -> /____/_/\_, /_//_/_/\_\
15:29:08.716 -> /___/ v0.6.1 on NodeMCU
15:29:08.716 ->
15:29:08.716 -> [10518] Connecting to blynk-cloud.com:80
15:29:08.889 -> [10689] Ready (ping: 47ms).
15:29:08.959 -> This is a valid token
15:29:13.872 -> [15690] Connecting to blynk-cloud.com:80
15:29:13.976 -> [15779] Ready (ping: 43ms).
15:29:19.058 -> Check Run
15:29:24.076 -> Check Run
…but with an incorrect token, the serial result is this:
15:22:08.215 -> [145523] Connecting to blynk-cloud.com:80
15:22:08.319 -> [145632] Invalid auth token
15:22:17.204 -> [154523] Connecting to blynk-cloud.com:80
15:22:17.305 -> [154629] Invalid auth token
15:22:26.198 -> [163523] Connecting to blynk-cloud.com:80
15:22:26.301 -> [163620] Invalid auth token
15:22:35.214 -> [172523] Connecting to blynk-cloud.com:80
15:22:35.315 -> [172621] Invalid auth token
15:22:44.204 -> [181523] Connecting to blynk-cloud.com:80
15:22:44.308 -> [181617] Invalid auth token
So, I think that in this last case there are no possibilities to insert some verification code, because the blynk.run is in its loop. Or, if it can be done, in some other way.
Thanks