-
Notifications
You must be signed in to change notification settings - Fork 2
/
wifi.py
66 lines (29 loc) · 957 Bytes
/
wifi.py
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
from RX_config import *
def connect(ssid,password):
import network
import time
import machine
station = network.WLAN(network.STA_IF) # Now the File exist so make Connection
if station.isconnected() == True:
print("Schon verbunden")
return
station.active(True)
if len(ip) > 7: # mit fester IP
station.ifconfig((ip,subnet,gateway,dns))
station.connect(ssid,password)
station.isconnected()
count=0
while not station.isconnected():
time.sleep(0.5)
#print("*",end="")
count+=1
if count> 10: # Error open connection from File
break
print(station.ifconfig())
return (station.isconnected())
def disconnect():
import network
station = network.WLAN(network.STA_IF)
station.disconnect()
station.active(False)
#print("WiFi off!")