Connect to WIFI with specific BSSID (parsing issue)

All ESP8266 boards running MicroPython.
Official boards are the Adafruit Huzzah and Feather boards.
Target audience: MicroPython users with an ESP8266 board.
Post Reply
cchhsu
Posts: 1
Joined: Fri Sep 14, 2018 6:04 am

Connect to WIFI with specific BSSID (parsing issue)

Post by cchhsu » Fri Sep 14, 2018 6:38 am

When I parsed the BSSID string from a.config file to nic.connect("SSID", "password", bssid=BSSID bytes variable) using the micropython version: 1.9.4, I always got the error message. (ValueError)

:a.config
key="305A3A51B448"

code:
f = open('a.config')
f_read = f.read()
f.close()
key = bytes(f_read.split('\n')[0].split('=')[1], 'utf-8')
x =['\\x' + key[i:i+2] for i in range(0, len(key), 2)]
b_ssid=bytes(''.join(x), 'utf-8)
import network
nic = network.WLAN(network.STA_IF)
nic.active(True)
nic.connect("AC66", "12345678", bssid=b_ssid)
After running this code, show error messages as below:
Trackback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError:

But, I input the bssid value as \x30\x5A\x3A\x51\xB4\x48 manually, I am able to connect to AP successfully.
nic.connect("AC66", "12345678", bssid=b'\x30\x5A\x3A\x51\xB4\x48')

Have anybody know how should I solve this issue?
Thanks.

Post Reply