Can I put code inside "while (Blynk.connect() == false) {"?

I have a wireless light switch that I would like to automatically turn off if my arduino disconnects from Blynk… Can I do something like…

while (Blynk.connect() == false) {
digitalWrite(1, LOW);
}

?

I’d rather put an IF statement in there, not sure why, but it sounds more logical to me. I think it should work, have you tried?

I think we have something like

BLYNK_DISCONNECTED

@vshymanskyy is that working?

Instead of if (Blynk.connect()==…), I would use (if Blynk.connected)

/**
 * Connects to the server.
 * Blocks until connected or timeout happens.
 * May take less or more then timeout value.
 *
 * @param timeout    Connection timeout
 * @returns          True if connected to the server
 */
bool connect(unsigned long timeout = BLYNK_TIMEOUT_MS*3);

/**
 * @returns          True if connected to the server
 */
bool connected();

As mentioned before Blynk.connected() is your only option since you don’t want to connect to blink cloud again.

No, this feature is postponed for later release (multiple implementations possible).