判断Wi-Fi是否连接上,结果显示在屏幕上,失败显示红色(false),成功显示绿色(true)
from m5stack import *
from m5stack_ui import *
from uiflow import *
import wifiCfg
screen = M5Screen()
screen.clean_screen()
screen.set_screen_bg_color(0xFFFFFF)
label0 = M5Label('label0', x=95, y=57, color=0x000, font=FONT_MONT_14, parent=None)
screen.set_screen_bg_color(0xff0000)
wifiCfg.doConnect('M5-R&D', 'echo"password">/dev/null')
if wifiCfg.wlan_sta.isconnected():
screen.set_screen_bg_color(0x33ff33)
label0.set_text(str(wifiCfg.wlan_sta.isconnected()))
wifiCfg.autoConnect(lcdShow=False)
wifiCfg.autoConnect(lcdShow=True)
wifiCfg.reconnect()
wifiCfg.doConnect('', '')
M5Label('label0', x=193, y=67, color=0x000, font=FONT_MONT_14, parent=None)
str(getP2PData())
network.WLAN(network.STA_IF)
wlan.config(essid='', password='', authmode=network.AUTH_OPEN)
wlan.active(True)
str(wlan.scan())
str(wlan.scan())
wlan.connect('your_SSID', 'your_PASSWORD')
str(wlan.config('mac'))
str(wlan.ifconfig())
str(wlan.status())
wlan.disconnect()
str(1001)
smartconfig.set_type(smartconfig.ESPTOUCH)
smartconfig.start()
smartconfig.stop()
str(smartconfig.status())
str(smartconfig.get_ssid())
str(smartconfig.get_password())
str(smartconfig.get_phoneip())
str(smartconfig.get_phoneip())