blynkkk / blynk-library

Blynk library for IoT boards. Works with Arduino, ESP32, ESP8266, Raspberry Pi, Particle, ARM Mbed, etc.
https://blynk.io
MIT License
3.81k stars 1.38k forks source link

A Callback Function for Blynk.connect() ? #479

Closed W-O-X-Y closed 4 years ago

W-O-X-Y commented 4 years ago

Blynk library version: [v0.6.1] IDE: [Arduino.] IDE version: [1.8.5] Board type: [Uno R3]

The Issue: I'm trying to run some code asynchronously while my blynk client (Arduino Uno with ESP8266 as WiFi Shield) is trying to connect to my Blynk local Server, I went through the library and it seems the Blynk.connect() function blocks the code flow while waiting for connectivity to the server.

My question or feature request: is there any way a callback or event can be added to allow execution of code while waiting for connectivity to the server?

vshymanskyy commented 4 years ago

You should be able to use this pattern:

// Start connection (timeout=0, immediately exit)
Blynk.connect(0);
// Then, periodically:
Blynk.run();
if (Blynk.connected()) { ... }