Skip to content

WiFi.BSSID and scan result BSSID with parameter as in WiFi libraries by Arduino #9008

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

Merged
merged 2 commits into from
Nov 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions libraries/ESP8266WiFi/src/ESP8266WiFiSTA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -607,6 +607,18 @@ uint8_t* ESP8266WiFiSTAClass::BSSID(void) {
return reinterpret_cast<uint8_t*>(conf.bssid);
}

/**
* Fill the current bssid / mac associated with the network if configured
* @param bssid pointer to uint8_t array with length WL_MAC_ADDR_LENGTH
* @return bssid uint8_t *
*/
uint8_t* ESP8266WiFiSTAClass::BSSID(uint8_t* bssid) {
struct station_config conf;
wifi_station_get_config(&conf);
memcpy(bssid, conf.bssid, WL_MAC_ADDR_LENGTH);
return bssid;
}

/**
* Return the current bssid / mac associated with the network if configured
* @return String bssid mac
Expand Down
1 change: 1 addition & 0 deletions libraries/ESP8266WiFi/src/ESP8266WiFiSTA.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ class ESP8266WiFiSTAClass: public LwipIntf {
String psk() const;

uint8_t * BSSID();
uint8_t * BSSID(uint8_t* bssid);
String BSSIDstr();

int8_t RSSI();
Expand Down
15 changes: 15 additions & 0 deletions libraries/ESP8266WiFi/src/ESP8266WiFiScan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,21 @@ uint8_t * ESP8266WiFiScanClass::BSSID(uint8_t i) {
return it->bssid;
}

/**
* fill MAC / BSSID of scanned wifi
* @param i specify from which network item want to get the information
* @param bssid pointer to uint8_t array with length WL_MAC_ADDR_LENGTH
* @return uint8_t * MAC / BSSID of scanned wifi
*/
uint8_t * ESP8266WiFiScanClass::BSSID(uint8_t i, uint8_t* bssid) {
struct bss_info* it = reinterpret_cast<struct bss_info*>(_getScanInfoByIndex(i));
if(!it) {
return 0;
}
memcpy(bssid, it->bssid, WL_MAC_ADDR_LENGTH);
return bssid;
}

/**
* return MAC / BSSID of scanned wifi
* @param i specify from which network item want to get the information
Expand Down
1 change: 1 addition & 0 deletions libraries/ESP8266WiFi/src/ESP8266WiFiScan.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class ESP8266WiFiScanClass {
uint8_t encryptionType(uint8_t networkItem);
int32_t RSSI(uint8_t networkItem);
uint8_t * BSSID(uint8_t networkItem);
uint8_t * BSSID(uint8_t networkItem, uint8_t* bssid);
String BSSIDstr(uint8_t networkItem);
int32_t channel(uint8_t networkItem);
bool isHidden(uint8_t networkItem);
Expand Down