_wifi.py 文件源码

python
阅读 18 收藏 0 点赞 0 评论 0

项目:ulnoiot 作者: ulno 项目源码 文件源码
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)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号