wifi.py 文件源码

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

项目:thingflow-python 作者: mpi-sws-rse 项目源码 文件源码
def wifi_connect(essid, password):
    # Connect to the wifi. Based on the example in the micropython
    # documentation.
    wlan = network.WLAN(network.STA_IF)
    wlan.active(True)
    if not wlan.isconnected():
        print('connecting to network ' + essid + '...')
        wlan.connect(essid, password)
        # connect() appears to be async - waiting for it to complete
        while not wlan.isconnected():
            print('waiting for connection...')
            utime.sleep(4)
            print('checking connection...')
        print('Wifi connect successful, network config: %s' % repr(wlan.ifconfig()))
    else:
        # Note that connection info is stored in non-volatile memory. If
        # you are connected to the wrong network, do an explicity disconnect()
        # and then reconnect.
        print('Wifi already connected, network config: %s' % repr(wlan.ifconfig()))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号