本文整理汇总了Python中network.WLAN.disconnect方法的典型用法代码示例。如果您正苦于以下问题:Python WLAN.disconnect方法的具体用法?Python WLAN.disconnect怎么用?Python WLAN.disconnect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类network.WLAN
的用法示例。
在下文中一共展示了WLAN.disconnect方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: disconnectWLAN
# 需要导入模块: from network import WLAN [as 别名]
# 或者: from network.WLAN import disconnect [as 别名]
def disconnectWLAN(self):
try:
from network import WLAN
wlan=None
if self.isWipy1():
wlan=WLAN()
else:
wlan=WLAN(mode=WLAN.STA)
wlan.disconnect()
except:
pass
示例2: disconnectWLAN
# 需要导入模块: from network import WLAN [as 别名]
# 或者: from network.WLAN import disconnect [as 别名]
def disconnectWLAN(self):
# disconnect wlan because it spams debug messages that disturb the monitor protocol
try:
from network import WLAN
wlan = None
if self.isWipy1():
wlan = WLAN()
else:
wlan = WLAN(mode=WLAN.STA)
wlan.disconnect()
except:
# if wifi disconnect fails for whatever reason, let it continue to sync
# often this is the 'OSError: the requested oparation is not possible' thrown by the wlan.disconnect line
pass
示例3: print
# 需要导入模块: from network import WLAN [as 别名]
# 或者: from network.WLAN import disconnect [as 别名]
wifi.antenna(WLAN.INT_ANT)
wifi.mode(WLAN.STA)
print(wifi.mode() == WLAN.STA)
wifi.connect(testconfig.wlan_ssid, auth=testconfig.wlan_auth, timeout=10000)
wait_for_connection(wifi)
wifi.ifconfig(config='dhcp')
wait_for_connection(wifi)
print('0.0.0.0' not in wifi.ifconfig())
wifi.ifconfig(0, ('192.168.178.109', '255.255.255.0', '192.168.178.1', '8.8.8.8'))
wait_for_connection(wifi)
print(wifi.ifconfig(0) == ('192.168.178.109', '255.255.255.0', '192.168.178.1', '8.8.8.8'))
wait_for_connection(wifi)
print(wifi.isconnected() == True)
wifi.disconnect()
print(wifi.isconnected() == False)
t0 = time.ticks_ms()
wifi.connect(testconfig.wlan_ssid, auth=testconfig.wlan_auth, timeout=0)
print(time.ticks_ms() - t0 < 500)
wifi.disconnect()
print(wifi.isconnected() == False)
# test init again
wifi.init(WLAN.AP, ssid='www.wipy.io', auth=None, channel=5, antenna=WLAN.INT_ANT)
print(len(wifi.mac()) == 6)
# next ones MUST raise
示例4: __init__
# 需要导入模块: from network import WLAN [as 别名]
# 或者: from network.WLAN import disconnect [as 别名]
#.........这里部分代码省略.........
# create a raw LoRa socket
self.lora_sock = usocket.socket(usocket.AF_LORA, usocket.SOCK_RAW)
self.lora_sock.setblocking(False)
self.lora_tx_done = False
self.lora.callback(trigger=(LoRa.RX_PACKET_EVENT | LoRa.TX_PACKET_EVENT), handler=self._lora_cb)
self._log('LoRaWAN nano gateway online')
def stop(self):
"""
Stops the LoRaWAN nano gateway.
"""
self._log('Stopping...')
# send the LoRa radio to sleep
self.lora.callback(trigger=None, handler=None)
self.lora.power_mode(LoRa.SLEEP)
# stop the NTP sync
self.rtc.ntp_sync(None)
# cancel all the alarms
self.stat_alarm.cancel()
self.pull_alarm.cancel()
# signal the UDP thread to stop
self.udp_stop = True
while self.udp_stop:
utime.sleep_ms(50)
# disable WLAN
self.wlan.disconnect()
self.wlan.deinit()
def _connect_to_wifi(self):
self.wlan.connect(self.ssid, auth=(None, self.password))
while not self.wlan.isconnected():
utime.sleep_ms(50)
self._log('WiFi connected to: {}', self.ssid)
def _dr_to_sf(self, dr):
sf = dr[2:4]
if sf[1] not in '0123456789':
sf = sf[:1]
return int(sf)
def _dr_to_bw(self, dr):
bw = dr[-5:]
if bw == 'BW125':
return LoRa.BW_125KHZ
elif bw == 'BW250':
return LoRa.BW_250KHZ
else:
return LoRa.BW_500KHZ
def _sf_bw_to_dr(self, sf, bw):
dr = 'SF' + str(sf)
if bw == LoRa.BW_125KHZ:
return dr + 'BW125'
elif bw == LoRa.BW_250KHZ:
return dr + 'BW250'
else:
return dr + 'BW500'