From 73ba67166ba0da79596b2ef5ab1f29b9fd144dec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E7=AB=8B=E5=B8=AE?= <3294713004@qq.com> Date: Wed, 23 Oct 2024 18:20:32 +0800 Subject: [PATCH] =?UTF-8?q?Update(boards):=20micropython=E6=9D=BF=E5=8D=A1?= =?UTF-8?q?=E6=89=A7=E8=A1=8C=20`build:prod`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../default/micropython/build/lib/mixiot.py | 21 +++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/boards/default/micropython/build/lib/mixiot.py b/boards/default/micropython/build/lib/mixiot.py index 975b4e7f..a1db293f 100644 --- a/boards/default/micropython/build/lib/mixiot.py +++ b/boards/default/micropython/build/lib/mixiot.py @@ -8,17 +8,26 @@ from matcher import MQTTMatcher ADDITIONAL_TOPIC = 'b640a0ce465fa2a4150c36b305c1c11b' WILL_TOPIC = '9d634e1a156dc0c1611eb4c3cff57276' - -def wlan_connect(ssid='MYSSID', password='MYPASS'): +def wlan_connect(ssid='MYSSID', password='MYPASS', timeout=10): import network wlan = network.WLAN(network.STA_IF) if not wlan.active() or not wlan.isconnected(): wlan.active(True) - print('connecting to:', ssid) - wlan.connect(ssid, password) - while not wlan.isconnected(): + print('connecting to:', ssid, end ="") + try: + wlan.connect(ssid, password) + except: pass - print('network config:', wlan.ifconfig()) + _num = 0 + while not wlan.isconnected(): + _num += 1 + time.sleep(1) + print('.',end ="") + if _num > timeout: + wlan.active(False) + print('') + raise RuntimeError("WiFi connection timeout, Please check only 2.4G supported name and password") + print('\nnetwork config:', wlan.ifconfig()) return wlan def ntp(url='mixio.mixly.cn'):