Closed
Description
Basic Infos
- This issue complies with the issue POLICY doc.
- I have read the documentation at readthedocs and the issue is not addressed there.
- I have tested that the issue is present in current master branch (aka latest git).
- I have searched the issue tracker for a similar issue.
- If there is a stack dump, I have decoded it.
- I have filled out all fields below.
Platform
- Hardware: all
- Core Version: git 06/04/2019
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:
uint8_t* WiFiClass::BSSID(uint8_t* bssid)
{
uint8_t* _bssid = WiFiDrv::getCurrentBSSID();
memcpy(bssid, _bssid, WL_MAC_ADDR_LENGTH);
return bssid;
}
esp8266 code:
uint8_t* ESP8266WiFiSTAClass::BSSID(void) {
static struct station_config conf;
wifi_station_get_config(&conf);
return reinterpret_cast<uint8_t*>(conf.bssid);
}
same for the wifi scan:
arduino code:
uint8_t* WiFiClass::BSSID(uint8_t networkItem, uint8_t* bssid)
{
return WiFiDrv::getBSSIDNetowrks(networkItem, bssid);
}
esp8266 code:
uint8_t * ESP8266WiFiScanClass::BSSID(uint8_t i) {
struct bss_info* it = reinterpret_cast<struct bss_info*>(_getScanInfoByIndex(i));
if(!it) {
return 0;
}
return it->bssid;
}
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:
uint8_t* ESP8266WiFiSTAClass::macAddress(uint8_t* mac) {
wifi_get_macaddr(STATION_IF, mac);
return mac;
}
Also, making it compatible with the arduino api is not a major change since, i think, it won't break anything
MCVE Sketch
#include <ESP8266WiFi.h>
char ssid[] = "Aster-gopro3";
char pass[] = "password";
int status = 0;
void setup()
{
Serial.begin(115200);
}
void loop ()
{
if (status != WL_CONNECTED) {
WiFi.begin(ssid, pass);
Serial.println(".");
}
else {
// print the MAC address of the router you're attached to:
byte mac[6];
WiFi.macAddress(mac);
printMacAddress(mac);
byte bssid[6];
WiFi.BSSID(bssid);
printMacAddress(bssid);
delay(2000);
}
}
void printMacAddress(byte mac[]) {
for (int i = 5; i >= 0; i--) {
if (mac[i] < 16) {
Serial.print("0");
}
Serial.print(mac[i], HEX);
if (i > 0) {
Serial.print(":");
}
}
Serial.println();
}