def connect():
global wifi_cfg, _wlan
_ap.active(False)
_wlan.active(True)
# removed scan of networks to allow connect to hidden essid
# Try to connect
_wlan.connect(wifi_cfg.name, wifi_cfg.password)
tries=15
for i in range(tries):
print("%d/%d. Trying to connect." %(i+1, tries))
machine.idle()
time.sleep(1)
# if _wlan.isconnected(): break
if _wlan.status() == network.STAT_GOT_IP: break
if _wlan.isconnected() and _wlan.status() == network.STAT_GOT_IP:
print('Wifi: connection succeeded!')
print(_wlan.ifconfig())
else:
print('Wifi: connection failed, starting accesspoint!')
accesspoint()
nr.start(nostop=True)
评论列表
文章目录