Skip to content

Commit 8f28c7c

Browse files
JAndrassyhasenradball
authored andcommitted
WiFi.BSSID and scan result BSSID with parameter as other WiFi libraries (esp8266#9008)
1 parent 9d77b2d commit 8f28c7c

File tree

4 files changed

+29
-0
lines changed

4 files changed

+29
-0
lines changed

libraries/ESP8266WiFi/src/ESP8266WiFiSTA.cpp

+12
Original file line numberDiff line numberDiff line change
@@ -607,6 +607,18 @@ uint8_t* ESP8266WiFiSTAClass::BSSID(void) {
607607
return reinterpret_cast<uint8_t*>(conf.bssid);
608608
}
609609

610+
/**
611+
* Fill the current bssid / mac associated with the network if configured
612+
* @param bssid pointer to uint8_t array with length WL_MAC_ADDR_LENGTH
613+
* @return bssid uint8_t *
614+
*/
615+
uint8_t* ESP8266WiFiSTAClass::BSSID(uint8_t* bssid) {
616+
struct station_config conf;
617+
wifi_station_get_config(&conf);
618+
memcpy(bssid, conf.bssid, WL_MAC_ADDR_LENGTH);
619+
return bssid;
620+
}
621+
610622
/**
611623
* Return the current bssid / mac associated with the network if configured
612624
* @return String bssid mac

libraries/ESP8266WiFi/src/ESP8266WiFiSTA.h

+1
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ class ESP8266WiFiSTAClass: public LwipIntf {
7979
String psk() const;
8080

8181
uint8_t * BSSID();
82+
uint8_t * BSSID(uint8_t* bssid);
8283
String BSSIDstr();
8384

8485
int8_t RSSI();

libraries/ESP8266WiFi/src/ESP8266WiFiScan.cpp

+15
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,21 @@ uint8_t * ESP8266WiFiScanClass::BSSID(uint8_t i) {
259259
return it->bssid;
260260
}
261261

262+
/**
263+
* fill MAC / BSSID of scanned wifi
264+
* @param i specify from which network item want to get the information
265+
* @param bssid pointer to uint8_t array with length WL_MAC_ADDR_LENGTH
266+
* @return uint8_t * MAC / BSSID of scanned wifi
267+
*/
268+
uint8_t * ESP8266WiFiScanClass::BSSID(uint8_t i, uint8_t* bssid) {
269+
struct bss_info* it = reinterpret_cast<struct bss_info*>(_getScanInfoByIndex(i));
270+
if(!it) {
271+
return 0;
272+
}
273+
memcpy(bssid, it->bssid, WL_MAC_ADDR_LENGTH);
274+
return bssid;
275+
}
276+
262277
/**
263278
* return MAC / BSSID of scanned wifi
264279
* @param i specify from which network item want to get the information

libraries/ESP8266WiFi/src/ESP8266WiFiScan.h

+1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ class ESP8266WiFiScanClass {
4848
uint8_t encryptionType(uint8_t networkItem);
4949
int32_t RSSI(uint8_t networkItem);
5050
uint8_t * BSSID(uint8_t networkItem);
51+
uint8_t * BSSID(uint8_t networkItem, uint8_t* bssid);
5152
String BSSIDstr(uint8_t networkItem);
5253
int32_t channel(uint8_t networkItem);
5354
bool isHidden(uint8_t networkItem);

0 commit comments

Comments
 (0)