-
Notifications
You must be signed in to change notification settings - Fork 0
/
board.py
57 lines (41 loc) · 1.21 KB
/
board.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
# ----------- Connect to a router ----------- #
@micropython.native
def STA(ssid: str, passw: str):
import network
sta = network.WLAN(network.STA_IF)
sta.active(True)
sta.connect(ssid, passw)
while not sta.isconnected():
pass
print('Connection successful')
print(sta.ifconfig())
return sta
# ---------- Connect to a router with a static IP ---------- #
@micropython.native
def SSSTA(ssid: str, passw: str, static: str, routerip: str):
import network
sssta = network.WLAN(network.STA_IF)
sssta.ifconfig((static, "255.255.255.0", routerip, routerip))
sssta.active(True)
sssta.connect(ssid, passw)
while not sssta.isconnected():
pass
print('Connection successful')
print(sssta.ifconfig())
return sssta
# --------- Create a Hotspot ---------- #
@micropython.native
def AP(ssid: str, maxc: int, pswd: str):
import network
ap = network.WLAN(network.AP_IF)
ap.config(essid=ssid)
ap.config(max_clients=maxc)
ap.config(password=pswd)
ap.active(True)
print('Connection successful')
print(ap.ifconfig())
return ap
def Wkill(cmd: bool):
import network
network.WLAN(0).active(cmd)
network.WLAN(1).active(cmd)