[Solved] Blynk.connected() internals

Does Blynk.connected() internally call Blynk.connect()? Serial output shows the connecting message twice when using this code:

Serial.println("... before Blynk.connect()...");
Serial.println("...after Blynk.connect()...");

In the serial monitor:

... before Blynk.connect()...
[1731768] Connecting to blynk-cloud.com:8442
[1738085] Connecting to blynk-cloud.com:8442
...after Blynk.connect()...

My question/confusion is this: Where is the second output message coming from?

It just means it didn’t connect to the server first time so it tried again.

Thanks for your response, I understand the mechanics of what it’s doing :slight_smile: What I want to know is why that’s displaying twice before the default timeout period has elapsed (30 seconds according to documentation), and not from any code written in the sketch. Each time it is close to 5 seconds apart.

If I had access to the Blynk cpp files, I could answer my own question - but…yeah. :confused:

You do have access to all the Blynk library files.

I have always found the timeout’s a bit suspect so I don’t use them and I have my own that work just fine. I suspect what is supposed to happen is it tries for 30s and then gives up but in the meantime it will try several times.

Maybe I’m blind, but I am only seeing the declarations (.h) and not the definitions (.cpp) on github. Am I looking in the wrong place?

Take a look at https://github.com/blynkkk/blynk-library/blob/master/src/Blynk/BlynkProtocol.h and that might make it clearer to you.

1 Like

Exactly what I was looking for. Thanks.