1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-07-24 19:42:27 +03:00

Expand access to SDK's struct bss_info (#8683)

The NONOS SDK's `struct bss_info` in `user_interface.h` has grown since the
beginning of this project. The additional elements are not accessible.
Add a method for R/O access to full `struct bss_info`.

See #7965 (comment)
This commit is contained in:
M Hightower
2022-10-10 05:56:44 -07:00
committed by GitHub
parent a0c7a85649
commit 3df5693697
3 changed files with 34 additions and 2 deletions

View File

@ -22,7 +22,7 @@ void loop() {
String ssid;
int32_t rssi;
uint8_t encryptionType;
uint8_t* bssid;
uint8_t *bssid;
int32_t channel;
bool hidden;
int scanResult;
@ -40,7 +40,30 @@ void loop() {
for (int8_t i = 0; i < scanResult; i++) {
WiFi.getNetworkInfo(i, ssid, encryptionType, rssi, bssid, channel, hidden);
Serial.printf(PSTR(" %02d: [CH %02d] [%02X:%02X:%02X:%02X:%02X:%02X] %ddBm %c %c %s\n"), i, channel, bssid[0], bssid[1], bssid[2], bssid[3], bssid[4], bssid[5], rssi, (encryptionType == ENC_TYPE_NONE) ? ' ' : '*', hidden ? 'H' : 'V', ssid.c_str());
// get extra info
const bss_info *bssInfo = WiFi.getScanInfoByIndex(i);
String phyMode;
const char *wps = "";
if (bssInfo) {
phyMode.reserve(12);
phyMode = F("802.11");
String slash;
if (bssInfo->phy_11b) {
phyMode += 'b';
slash = '/';
}
if (bssInfo->phy_11g) {
phyMode += slash + 'g';
slash = '/';
}
if (bssInfo->phy_11n) {
phyMode += slash + 'n';
}
if (bssInfo->wps) {
wps = PSTR("WPS");
}
}
Serial.printf(PSTR(" %02d: [CH %02d] [%02X:%02X:%02X:%02X:%02X:%02X] %ddBm %c %c %-11s %3S %s\n"), i, channel, bssid[0], bssid[1], bssid[2], bssid[3], bssid[4], bssid[5], rssi, (encryptionType == ENC_TYPE_NONE) ? ' ' : '*', hidden ? 'H' : 'V', phyMode.c_str(), wps, ssid.c_str());
yield();
}
} else {

View File

@ -147,6 +147,14 @@ void ESP8266WiFiScanClass::scanDelete() {
_scanComplete = false;
}
/**
* returns const pointer to the requested scanned wifi entry for furthor parsing.
* @param networkItem int
* @return struct bss_info*, may be NULL
*/
const bss_info *ESP8266WiFiScanClass::getScanInfoByIndex(int i) {
return reinterpret_cast<const bss_info*>(_getScanInfoByIndex(i));
};
/**
* loads all infos from a scanned wifi in to the ptr parameters

View File

@ -41,6 +41,7 @@ class ESP8266WiFiScanClass {
void scanDelete();
// scan result
const bss_info *getScanInfoByIndex(int i);
bool getNetworkInfo(uint8_t networkItem, String &ssid, uint8_t &encryptionType, int32_t &RSSI, uint8_t* &BSSID, int32_t &channel, bool &isHidden);
String SSID(uint8_t networkItem);