main.py 文件源码

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

项目:esp8266sketches 作者: lekum 项目源码 文件源码
def wifi_connect(ssid, pwd):
    """
    Connect to a wifi 'ssid' with password 'pwd'
    """

    sta_if = network.WLAN(network.STA_IF)
    ap_if = network.WLAN(network.AP_IF)
    if ap_if.active():
        ap_if.active(False)
    if not sta_if.isconnected():
        print('connecting to network...')
        sta_if.active(True)
        sta_if.connect(ssid, pwd)
        while not sta_if.isconnected():
            pass
    return 'IP address: %s' % sta_if.ifconfig()[0]
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号