View Single Post
Old 12-28-2019, 03:40 PM   #3
handyguy
Connoisseur
handyguy is a marvel to beholdhandyguy is a marvel to beholdhandyguy is a marvel to beholdhandyguy is a marvel to beholdhandyguy is a marvel to beholdhandyguy is a marvel to beholdhandyguy is a marvel to beholdhandyguy is a marvel to beholdhandyguy is a marvel to beholdhandyguy is a marvel to beholdhandyguy is a marvel to behold
 
handyguy's Avatar
 
Posts: 72
Karma: 11789
Join Date: Dec 2019
Device: PW4
python code to turn wifi on and wait until connected

I found this code to work well - turn wifi on, wait until connected, allow a timeout:
Code:
sp = subprocess.Popen(['lipc-set-prop', 'com.lab126.cmd', 'wirelessEnable', '1'], stdout=subprocess.PIPE)
wifi = 'OFF'
loop = 0
while loop < 40:
sp = subprocess.Popen(['lipc-get-prop', 'com.lab126.wifid', 'cmState'], stdout=subprocess.PIPE)
response, _ = sp.communicate()
if response.find("CONNECTED") > -1:
wifi = 'ON'
break
else:
loop +=1
sleep(1.5)

Last edited by handyguy; 12-31-2019 at 12:41 PM.
handyguy is offline   Reply With Quote