-
Notifications
You must be signed in to change notification settings - Fork 13.3k
BSSID incompatibility with arduino API #5952
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
Comments
You seem to be confusing the MAC address of the ESP's station interface with the MAC address of the router the station interface is connected to, aka Arduino's BSSID.
Our ESP8266WiFi::BSSID(void) gets the BSSID of the ESP's station interface. None of them gets the BSSID of the router to which the station interface is connected. There is currently no way to get the router's BSSID. This is a limitation of the SDK. One thing you could do is scan, then iterate over the scan results to match the SSID you specified with the SSIDs found, then when there is a match get the BSSID. However, in the case where there are several routers with the same SSID and each with a different BSSID, you can't assure picking the correct scan item. The one exception is when you specify which BSSID the station interface should connect to in the begin() method, and even then I think you can't really retrieve it the way you seem to want. Closing. |
Hi @devyte, I wasn't aware that the sdk can't get the address of the router 😕 Everyone who uses the bssid function expect to get the address of the router we are connected to, not the address of the esp board! Is this explained somewhere? Just for curiosity: could the freertos sdk do that? |
readthedocs
Probably not, the internal code is very similar. I can't say for sure, though, i don't use the freertos sdk. Notice that our wifi class is named ESP8266WiFi. This is on purpose, precisely because it can't be fully compatible. |
https://arduino-esp8266.readthedocs.io/en/2.5.0/esp8266wifi/station-class.html#bssid Well, english is not my first language but this could be misleading, from your words i know that
But in the docs is not very clear And by the way imho it would be better just to make the function returning an empty pointer then returning something i wasn t looking for |
This is the function that returns the mac of the station interface. Notice that it is a thin layer over the SDK functionality. About the docs, you're right, it's not clear. Reopening to track a doc update. |
Actually, after reading Espressif's NONOS API ref document 2c, I'm wrong: the returned mac is not the one of the station interface, it's the bssid the user specified the station should connect to. |
you mean the 4th parameter here, right?
edit: yes Arduino/libraries/ESP8266WiFi/src/ESP8266WiFiSTA.cpp Lines 166 to 171 in 885276e
anyway @devyte consider my purpose: since the
make this function return a empty array if bssid_set is 0 and the correct MAC if it is set to 1 |
WiFi.BSSID() is indeed confusing.
@aster94 Have you tried something on your side that would be worth being integrated to the core ? |
hello @d-a-v actually not, but would something like this work? uint8_t* ESP8266WiFiSTAClass::BSSID(void) {
static struct station_config conf;
wifi_station_get_config(&conf);
if (conf.bssid_set == 1)
{
return 0;
}
else
{
return reinterpret_cast<uint8_t*>(conf.bssid);
}
} sorry for bad formattation but i wrote it here |
Basic Infos
Platform
Settings in IDE
not relevant
Problem Description
The BSSID core api is incompatible with the arduino one
Wifi nina code which I copy it here to see it easier:
esp8266 code:
same for the wifi scan:
arduino code:
esp8266 code:
At the end the BSSID and macAddress functions are similar, both gave back a mac address, and for this reason them should be used in a similar way, note that your macAddress function is perfect:
Also, making it compatible with the arduino api is not a major change since, i think, it won't break anything
MCVE Sketch
The text was updated successfully, but these errors were encountered: