本文整理汇总了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())
示例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
示例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
示例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