def connect(self):
self.wlan = network.WLAN(mode=network.WLAN.STA)
if not self.wlan.isconnected() or self.ssid() != self.SSID:
for net in self.wlan.scan():
if net.ssid == self.SSID:
self.wlan.connect(self.SSID, auth=(network.WLAN.WPA2,
self.password))
while not self.wlan.isconnected():
machine.idle() # save power while waiting
break
else:
raise Exception("Cannot find network '{}'".format(SSID))
else:
# Already connected to the correct WiFi
pass
评论列表
文章目录