Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Reconnecting to WiFi
-
Hello
I’m using an iPad as a data logger. The Pythonista program works great. My internet not so much. I loose connection several times a day on everything connected to it.
My question is: how I get python to check if it’s connected and if not, reconnect? I’ve looked at a lot of posts across the Internet and nothing addresses this.
-
You can use objc_util to check your connection type.
from objc_util import * NWPathEvaluator = ObjCClass('NWPathEvaluator') connection = NWPathEvaluator.sharedDefaultEvaluator() def isOnWifi(): info=connection.path() if info.isExpensive(): #on cellular data return False #Not on wifi elif info.status() == 2: #no connection return False #Not on wifi elif info.status() == 1: #on wifi return True #Wifi! else: return None #Unknown or Error
Will continue to see if there’s a way to retry a connection....