当前位置: 首页>>代码示例>>Python>>正文


Python WLAN.active方法代码示例

本文整理汇总了Python中network.WLAN.active方法的典型用法代码示例。如果您正苦于以下问题:Python WLAN.active方法的具体用法?Python WLAN.active怎么用?Python WLAN.active使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在network.WLAN的用法示例。


在下文中一共展示了WLAN.active方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: do_connect

# 需要导入模块: from network import WLAN [as 别名]
# 或者: from network.WLAN import active [as 别名]
def do_connect():
    from network import WLAN
    sta_if = WLAN(network.STA_IF)
    if not sta_if.isconnected():
        print('connecting to network...')
        sta_if.active(True)
        sta_if.connect(WIFISSID, WIFIPASS)
        while not sta_if.isconnected():
            pass
    print('network config:', sta_if.ifconfig())
开发者ID:Naish21,项目名称:themostat,代码行数:12,代码来源:main.py

示例2: connect_to_wifi

# 需要导入模块: from network import WLAN [as 别名]
# 或者: from network.WLAN import active [as 别名]
def connect_to_wifi(ssid, password, retries=10):
    """
    Connect to a WIFI network
    """
    try:
        from network import STA_IF
    except ImportError:
        return connect_to_wifi_wipy(ssid, password, retries=retries)

    wlan = WLAN(STA_IF)
    wlan.active(True)
    wlan.connect(ssid, password)
    retry_count = 0
    while not wlan.isconnected():
        sleep(1)
        retry_count += 1
        if retry_count > retries:
            return False
    return True
开发者ID:dwighthubbard,项目名称:micropython-bootconfig,代码行数:21,代码来源:wifi.py

示例3: connect_to_ap

# 需要导入模块: from network import WLAN [as 别名]
# 或者: from network.WLAN import active [as 别名]
def connect_to_ap(essids, tries=3):
    from network import WLAN, STA_IF
    from time import sleep
    wlan = WLAN(STA_IF)
    wlan.active(True)
    ## Select only known networks
    ap_list = list(filter(lambda ap: ap[0].decode('UTF-8') in 
            essids.keys(), wlan.scan()))
    ## sort by signal strength
    ap_list.sort(key=lambda ap: ap[3], reverse=True)
    for ap in ap_list:
        essid = ap[0].decode('UTF-8')
        wlan.connect(essid, essids[essid])
        for i in range(5):
            ## this is somewhat crude, we actually have a
            ## wlan.status() we can inspect. oh well...
            if wlan.isconnected():
                return True
            sleep(1)
    return False
开发者ID:yschaeff,项目名称:ICantBelieveItsNotDNS,代码行数:22,代码来源:boot.py

示例4: WLAN

# 需要导入模块: from network import WLAN [as 别名]
# 或者: from network.WLAN import active [as 别名]
# bare minimum to initalize webrepl and start meowton

# disable debug
# import esp
# esp.osdebug(1)

### network stuff
import config
import network
from network import WLAN
wlan = WLAN(network.STA_IF) # get current object, without changing the mode
wlan.active(True)
# wlan.ifconfig(config.network)
wlan.connect(config.wifi_essid, config.wifi_password)

import webrepl
webrepl.start()

# import utelnetserver
# utelnetserver.start()

import temp
开发者ID:psy0rz,项目名称:stuff,代码行数:24,代码来源:main.py


注:本文中的network.WLAN.active方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。