我正在尝试使用内置的STM32解释器将一个SPWF04SA连接到我们的无线网络。根据数据表,应该支持它。
我可以列出可用的网络
import network
wlan = WLAN()
nets = wlan.scan()
for net in nets:
print(net)我得到了
(ssid='PE0000', bssid='00:13:60:FF:8F:2D', auth='WPA2 ', channel=4, rssi=-65)
(ssid='PE9000', bssid='02:13:60:FF:8F:2D', auth='WPA2 ', channel=4, rssi=-67)
(ssid='PE0200', bssid='B8:C7:5D:07:CF:D3', auth='WPA2 ', channel=6, rssi=-85)然后,我尝试使用以下方法连接到网络PE9000 (或其中任何一个):
wlan.connect('PE9000',(WLAN.WPA2,'xxxx'))我得到了:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: type object 'WLAN' has no attribute 'WPA2'如果我尝试使用WLAN.WPA作为安全类型,我不会得到错误,但很明显,它不会连接到网络。
任何帮助都将不胜感激。
发布于 2017-11-01 11:33:07
我终于让它起作用了。如果其他人遇到这种情况,这些板的语法似乎有点不规范。我没有调用wlan.connect(),而是使用以下方法:
w.init(mode=WLAN.STA, ssid='PE9000', auth=(WLAN.WPA, 'xxxx'))即使我指定WPA而不是WPA2,它也必须解决它并进行连接。
发布于 2017-09-27 22:53:29
我的ESP8266模块也有同样的问题。我已经包括了一些代码,帮助我解决了这个问题。我使用的是micropython 1.9.2。
configuration_filename = 'configuration.json'
station_config = network.WLAN(network.STA_IF)
if not station_config.isconnected():
with open(configuration_filename, 'r') as configuration_file:
json_configuration = configuration_file.read()
json_config = json.loads(json_configuration)
ssid = json_config['ssid']
password = json_config['password']
station_config.connect(ssid, password)
while not station_config.isconnected():
machine.idle() # save power while waiting
print('WLAN connection succeeded!') https://stackoverflow.com/questions/46412513
复制相似问题