Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it valid for wifi.sta.getapinfo() to return a null BSSID? #2025

Closed
marcelstoer opened this issue Jul 3, 2017 · 3 comments
Closed

Is it valid for wifi.sta.getapinfo() to return a null BSSID? #2025

marcelstoer opened this issue Jul 3, 2017 · 3 comments
Labels

Comments

@marcelstoer
Copy link
Member

marcelstoer commented Jul 3, 2017

Running the example from https://nodemcu.readthedocs.io/en/latest/en/modules/wifi/#wifistagetapinfo I see that I get nil for my AP's BSSID. Is that an ok condition or does that signify a bug in the SDK or our mapping to Lua?

Maybe something for @dnc40085?

@dnc40085
Copy link
Contributor

dnc40085 commented Jul 3, 2017

Yes, that is an ok condition.
From the wifi.sta.getapinfo() documentation

bssid MAC address of Access Point, nil if no MAC address was configured

Unless your station was configured with the AP's mac address( ex: wifi.sta.config({ssid=ssid, pwd=pwd, bssid="AA:BB:CC:DD:EE:FF"})), the bssid field should be nil.

The reasoning behind this is that when no BSSID is set during station configuration, the station_config.bssid_set byte is set to 0 and the 6 byte station_config.bssid array is ignored and the corresponding location in flash is not modified. This location being unmodified could potentially contain a BSSID that does not correspond with the SSID so it must be ignored when the access point info is retrieved from flash.

Considering the confusion, maybe it would be prudent to change it to return an invalid mac address(00:00:00:00:00:00) instead of nil.

@marcelstoer
Copy link
Member Author

marcelstoer commented Jul 3, 2017

Thanks for the explanation.
Before I posted this question I had checked the documentation but "nil if no MAC address was configured" confused me. Why would I configure the AP's MAC I thought, it's got a MAC automatically. It didn't occur to me that this would be the MAC I set explicitly while configuring the station.
Then I looked at https://github.com/nodemcu/nodemcu-firmware/blob/dev/app/modules/wifi.c#L564 and tracked the use of bssid_set. However, not being a firmware developer this didn't fully resolve my confusion. Hence, this issue.

Conclusion: there's no way we could figure out the AP's MAC from Lua land unless we knew it beforehand?

dnc40085 added a commit to dnc40085/nodemcu-firmware that referenced this issue Jul 4, 2017
Improved documentation for wifi.sta.getapinfo
fix for nodemcu#2025
dnc40085 added a commit to dnc40085/nodemcu-firmware that referenced this issue Jul 4, 2017
Improved documentation for wifi.sta.getapinfo
fix for nodemcu#2025
@dnc40085
Copy link
Contributor

dnc40085 commented Jul 4, 2017

Conclusion: there's no way we could figure out the AP's MAC from Lua land unless we knew it beforehand?

The submitted PR should give you a way to get the currently configured AP's MAC address.

marcelstoer pushed a commit that referenced this issue Jul 8, 2017
* Modified wifi.sta.get*config() to return AP's MAC even if bssid_set==0
* Improved documentation for wifi.sta.getapinfo, fixes #2025
eiselekd pushed a commit to eiselekd/nodemcu-firmware that referenced this issue Jan 7, 2018
* Modified wifi.sta.get*config() to return AP's MAC even if bssid_set==0
* Improved documentation for wifi.sta.getapinfo, fixes nodemcu#2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants