更新C5的wifi配网错误提示
This commit is contained in:
@@ -11,8 +11,10 @@ WILL_TOPIC = '9d634e1a156dc0c1611eb4c3cff57276'
|
|||||||
def wlan_connect(ssid='MYSSID', password='MYPASS', timeout=10):
|
def wlan_connect(ssid='MYSSID', password='MYPASS', timeout=10):
|
||||||
import network
|
import network
|
||||||
wlan = network.WLAN(network.STA_IF)
|
wlan = network.WLAN(network.STA_IF)
|
||||||
if not wlan.active() or not wlan.isconnected():
|
if not wlan.active():
|
||||||
wlan.active(True)
|
wlan.active(True)
|
||||||
|
time.sleep(0.5)
|
||||||
|
if not wlan.isconnected():
|
||||||
print('connecting to:', ssid, end ="")
|
print('connecting to:', ssid, end ="")
|
||||||
try:
|
try:
|
||||||
wlan.connect(ssid, password)
|
wlan.connect(ssid, password)
|
||||||
@@ -26,7 +28,11 @@ def wlan_connect(ssid='MYSSID', password='MYPASS', timeout=10):
|
|||||||
if _num > timeout:
|
if _num > timeout:
|
||||||
wlan.active(False)
|
wlan.active(False)
|
||||||
print('')
|
print('')
|
||||||
raise RuntimeError("WiFi connection timeout, Please check only 2.4G supported name and password")
|
import os
|
||||||
|
if 'c5' in os.uname().machine.lower():
|
||||||
|
raise RuntimeError("WiFi connection timeout. Please check the SSID and password")
|
||||||
|
else:
|
||||||
|
raise RuntimeError("WiFi connection timeout, Please check the SSID and password (only 2.4GHz networks are supported)")
|
||||||
print('\nnetwork config:', wlan.ifconfig())
|
print('\nnetwork config:', wlan.ifconfig())
|
||||||
return wlan
|
return wlan
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user