Page 1 of 1
Get ssid of currently connected wifi network?
Posted: Sat Apr 07, 2018 5:33 pm
by larsks
Is there any way of getting the ssid of the wifi network to which the esp8266 is currently connected? I was hoping for:
Code: Select all
sta = network.WLAN(network.STA_IF)
sta.config('ssid')
...but that reports "unknown config param".
Re: Get ssid of currently connected wifi network?
Posted: Sat Apr 07, 2018 11:56 pm
by devnull
How to determine wlan connected ESSID ?
Re: Get ssid of currently connected wifi network?
Posted: Mon Apr 09, 2018 2:55 am
by larsks
That is...pretty much exactly what I am asking, yes.
I took a look at the sources and it seems as if this would be a reasonably easy feature to add, except that I am unsure where the various MP_QSTR_ constants come from (like MP_QSTR_essid). They get generated as part of the build process, but I'm not sure from what.
Re: Get ssid of currently connected wifi network?
Posted: Mon Apr 09, 2018 5:10 pm
by dhylands
The MP_QSTR constants are generated by scanning the source code and looking for use in the source code.
So if the source code uses MP_QSTR_foobar, then the scanner will generate a qstr for foobar.
Re: Get ssid of currently connected wifi network?
Posted: Mon Apr 09, 2018 7:38 pm
by larsks
Dave,
Thanks for the pointer. That's magical!
Anway, I've posted
https://github.com/micropython/micropython/pull/3705 which allows one to ask for the essid of both Station and AP network interfaces:
Code: Select all
>>> import network
>>> sta = network.WLAN(network.STA_IF)
>>> ap = network.WLAN(network.AP_IF)
>>> ap.config('essid')
'MicroPython-66e36c'
>>> sta.config('essid')
'mynetwork'