本文整理汇总了Python中network.WLAN.antenna方法的典型用法代码示例。如果您正苦于以下问题:Python WLAN.antenna方法的具体用法?Python WLAN.antenna怎么用?Python WLAN.antenna使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类network.WLAN
的用法示例。
在下文中一共展示了WLAN.antenna方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Exception
# 需要导入模块: from network import WLAN [as 别名]
# 或者: from network.WLAN import antenna [as 别名]
raise Exception('Board not supported!')
def wait_for_connection(wifi, timeout=10):
while not wifi.isconnected() and timeout > 0:
time.sleep(1)
timeout -= 1
if wifi.isconnected():
print('Connected')
else:
print('Connection failed!')
wifi = WLAN()
print(wifi.mode() == WLAN.STA)
print(wifi.antenna() == WLAN.INT_ANT)
wifi = WLAN(mode=WLAN.AP)
print(wifi.mode() == WLAN.AP)
print(wifi.channel() == 1)
print(wifi.auth() == None)
print(wifi.antenna() == WLAN.INT_ANT)
wifi = WLAN(0, mode=WLAN.AP, ssid='test-wlan', auth=(WLAN.WPA, '123456abc'), channel=7)
print(wifi.mode() == WLAN.AP)
print(wifi.channel() == 7)
print(wifi.ssid() == 'test-wlan')
print(wifi.auth() == (WLAN.WPA, '123456abc'))
print(wifi.antenna() == WLAN.INT_ANT)
wifi = WLAN(mode=WLAN.STA)
print(wifi.mode() == WLAN.STA)
示例2: settimeout
# 需要导入模块: from network import WLAN [as 别名]
# 或者: from network.WLAN import antenna [as 别名]
from network import WLAN
from mqtt import MQTTClient
import machine
import time
def settimeout(duration):
pass
wlan = WLAN(mode=WLAN.STA)
wlan.antenna(WLAN.EXT_ANT)
wlan.connect("yourwifinetwork", auth=(WLAN.WPA2, "wifipassword"), timeout=5000)
while not wlan.isconnected():
machine.idle()
print("Connected to Wifi\n")
client = MQTTClient("demo", "broker.hivemq.com", port=1883)
client.settimeout = settimeout
client.connect()
while True:
print("Sending ON")
client.publish("/lights", "ON")
time.sleep(1)
print("Sending OFF")
client.publish("/lights", "OFF")
time.sleep(1)