Skip to content

Commit

Permalink
WiFi.BSSID and scan result BSSID with parameter as other WiFi librari…
Browse files Browse the repository at this point in the history
…es (#9008)
  • Loading branch information
JAndrassy authored Nov 4, 2023
1 parent 1662248 commit 497dacc
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 0 deletions.
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

0 comments on commit 497dacc

Please sign in to comment.