I have a project to map the cellular coverage with a GPS-antenna and a router modem, where I tend to lose internet connection every now and then (purposely). I would like to be able to reconnect to blynk whenever the internet is back, but the problem is that i would also like to set a timeout of the blynk.connect(), and continue with the rest of the code after x seconds if the connect() does not work. Now it just stops in the blynk.connect() and searches forever till a connection is to be found. I’ve thought of using mutli-threading but i was wonduring if it was an easier solution, like blynk.settimeout()?
fyi: blynk.state = 0 means that the blynk is disconnected, blynk.state = 1 means that its being reconnected and blynk.state = 2 means that its connected.
here is an example of a use case:
code in python
if blynk.state == 0: # if there are no blynk connection
print(“No internet is available”)
blynk.settimeout(5) # I want something like this
else: # if the measurement system is connecting or connected to blynk servers
print(“Internet is available”)