Does ESP32 MP port implement AP password?

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
Post Reply
paulg
Posts: 29
Joined: Fri Oct 23, 2015 1:06 pm

Does ESP32 MP port implement AP password?

Post by paulg » Sun Nov 03, 2019 3:23 pm

Hi,
Can anyone confirm whether or not the ESP32 MicroPython port implements the password when one creates an Access Point? The documentation suggests it does, but I have not been able together it to work. I copied the following code to main.py on my TinyPICO and pressed the Reset button.

Code: Select all

# Test program 9: Create a Wi-Fi Access Point with a password

import network
print('\nHello. This is test 9')
ap = network.WLAN(network.AP_IF)
ap.config(essid = 'esp32-test', password = '123456789')
ap.active(True)
print('Access Point created: ', ap.ifconfig())
print(ap.config('essid'), ap.config('channel'))
#print(ap.config('essid'), ap.config('channel'), ap.config('password'))
print('Goodbye!\n')
The result was:

Hello. This is test 9
I (130) wifi: wifi driver task: 3ffd2b10, prio:23, stack:3584, core=0
I (1846) system_api: Base MAC address is not set, read default base MAC address from BLK0 of EFUSE
I (1856) system_api: Base MAC address is not set, read default base MAC address from BLK0 of EFUSE
I (1876) wifi: wifi firmware version: 10f4364
I (1876) wifi: config NVS flash: enabled
I (1876) wifi: config nano formating: disabled
I (1876) wifi: Init dynamic tx buffer num: 32
I (1886) wifi: Init data frame dynamic rx buffer num: 32
I (1886) wifi: Init management frame dynamic rx buffer num: 32
I (1896) wifi: Init management short buffer num: 32
I (1896) wifi: Init static rx buffer size: 1600
I (1906) wifi: Init static rx buffer num: 10
I (1906) wifi: Init dynamic rx buffer num: 32
I (1996) phy: phy_version: 4102, 2fa7a43, Jul 15 2019, 13:06:06, 0, 0
I (1996) wifi: mode : softAP (d8:a0:1d:54:6e:75)
I (2006) wifi: Total power save buffer number: 16
I (2006) wifi: Init max length of beacon: 752/752
I (2006) wifi: Init max length of beacon: 752/752
I (2016) network: event 14
Access Point created: ('192.168.4.1', '255.255.255.0', '192.168.4.1', '0.0.0.0')
esp32-test 1
Goodbye!

Scanning Wi-Fi networks on my phoned showed that esp32-test1 existed and was not protected.

If I uncomment the last but one print, I get:

Access Point created: ('192.168.4.1', '255.255.255.0', '192.168.4.1', '0.0.0.0')
esp32-test 1
Traceback (most recent call last):
File "main.py", line 12, in <module>
ValueError: unknown config param

This suggests to me that password is not implemented.

Christian Walther
Posts: 169
Joined: Fri Aug 19, 2016 11:55 am

Re: Does ESP32 MP port implement AP password?

Post by Christian Walther » Sun Nov 03, 2019 9:47 pm

The following code works for me on a TinyPICO with MicroPython v1.10-231-g673db939b-dirty. Reading out the password seems to be prohibited, but setting it works.

Code: Select all

import network
import time
ap = network.WLAN(network.AP_IF)
ap.active(True)
import ubinascii
essid = b"MicroPython-%s" % ubinascii.hexlify(ap.config("mac")[-3:])
password = b"micropythoN"
for i in range(8):
	time.sleep(0.1)
	if ap.active():
		break
ap.config(essid=essid, authmode=network.AUTH_WPA_WPA2_PSK, password=password, hidden=False)
print('pass:{:s}\nname:{:s}'.format(password, essid))

User avatar
jimmo
Posts: 2754
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: Does ESP32 MP port implement AP password?

Post by jimmo » Sun Nov 03, 2019 11:38 pm

Yes, the important detail is setting "authmode=network.AUTH_WPA_WPA2_PSK" in addition to the password.

paulg
Posts: 29
Joined: Fri Oct 23, 2015 1:06 pm

Re: Does ESP32 MP port implement AP password?

Post by paulg » Mon Nov 04, 2019 4:38 pm

Thanks Christian and Jimmo. Most helpful.

I doubt I would have worked that out as none of the examples I had seen mentioned authmode.

Post Reply