Board.py 文件源码

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

项目:illuminOS 作者: idimitrakopoulos 项目源码 文件源码
def connect_to_wifi(self, ssid, password, mode, wait_for_ip=0):
        import network, time

        log.info("Attempting to connect to WiFi '{}' with password '{}'...".format(ssid, password))
        n = network.WLAN(mode)
        n.active(True)
        n.connect(ssid, password)

        # Wait for IP address to be provided
        count = 0
        while not n.isconnected() and count < wait_for_ip:
            log.info("Waiting to obtain IP ... ({} sec remaining)".format(str(wait_for_ip - count)))
            time.sleep(1)
            count += 1

        # Get provided IP
        ip = n.ifconfig()[0]

        if ip == "0.0.0.0":
            log.info("Could not obtain IP on '{}'".format(ssid))
        else:

            log.info("Connected with IP '{}'".format(ip))

        return ip

    # @timed_function
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号