-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathrobustwlan.py
More file actions
29 lines (27 loc) · 870 Bytes
/
robustwlan.py
File metadata and controls
29 lines (27 loc) · 870 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import network
import time
import _thread
def connwifithread(ssid, clave):
nic = network.WLAN(network.STA_IF)
try:
nic.active(True)
except Exception as e:
print("No se pudo activar WiFi: "+str(e))
if nic.active():
print("WiFi activado")
while True:
if not nic.isconnected():
try:
nic.connect(ssid, clave)
except Exception as e:
print(e)
time.sleep(3)
if nic.isconnected():
print("Se ha conectado a la red")
print(nic.ifconfig())
elif nic.isconnected():
pass
else:
print("Intentar ejecutar el metodo connectwifi de nuevo")
def connectwifi(nombre, clave):
_thread.start_new_thread(connwifithread(nombre, clave), ())