Skip to content

Commit f8507fa

Browse files
restoring CWiFi methods to extract scanned access point info
1 parent ae01d58 commit f8507fa

File tree

4 files changed

+116
-4
lines changed

4 files changed

+116
-4
lines changed

libraries/WiFi/src/WiFi.cpp

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,36 @@ uint8_t CWifi::channel() {
208208
}
209209
/* -------------------------------------------------------------------------- */
210210

211+
/* -------------------------------------------------------------------------- */
212+
const char* CWifi::SSID(uint8_t networkItem) {
213+
return WiFiStation.getSSID(networkItem);
214+
}
215+
/* -------------------------------------------------------------------------- */
216+
217+
/* -------------------------------------------------------------------------- */
218+
int32_t CWifi::RSSI(uint8_t networkItem) {
219+
return WiFiStation.getRSSI(networkItem);
220+
}
221+
/* -------------------------------------------------------------------------- */
222+
223+
/* -------------------------------------------------------------------------- */
224+
uint8_t CWifi::encryptionType(uint8_t networkItem) {
225+
return WiFiStation.getEncrType(networkItem);
226+
}
227+
/* -------------------------------------------------------------------------- */
228+
229+
/* -------------------------------------------------------------------------- */
230+
uint8_t* CWifi::BSSID(uint8_t networkItem, uint8_t* bssid) {
231+
return WiFiStation.getBSSID(networkItem,bssid);
232+
}
233+
/* -------------------------------------------------------------------------- */
234+
235+
/* -------------------------------------------------------------------------- */
236+
uint8_t CWifi::channel(uint8_t networkItem) {
237+
return WiFiStation.getChannel(networkItem);
238+
}
239+
/* -------------------------------------------------------------------------- */
240+
211241
/* -------------------------------------------------------------------------- */
212242
uint8_t CWifi::status() { // FIXME
213243
/* -------------------------------------------------------------------------- */

libraries/WiFi/src/WiFiC3.h

Lines changed: 43 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -171,10 +171,10 @@ class CWifi {
171171
int32_t RSSI();
172172

173173
/*
174-
* Return the Encryption Type associated with the network
175-
*
176-
* return: one value of wl_enc_type enum
177-
*/
174+
* Return the Encryption Type associated with the network
175+
*
176+
* return: one value of wl_enc_type enum
177+
*/
178178
uint8_t encryptionType();
179179

180180
/*
@@ -183,6 +183,45 @@ class CWifi {
183183
* return: Number of discovered networks
184184
*/
185185
int8_t scanNetworks();
186+
/*
187+
* Return the SSID discovered during the network scan.
188+
*
189+
* param networkItem: specify from which network item want to get the information
190+
*
191+
* return: SSID string of the specified item on the networks scanned list
192+
*/
193+
const char* SSID(uint8_t networkItem);
194+
195+
/*
196+
* Return the encryption type of the networks discovered during the scanNetworks
197+
*
198+
* param networkItem: specify from which network item want to get the information
199+
*
200+
* return: encryption type (enum wl_enc_type) of the specified item on the networks scanned list
201+
* enum wl_enc_type :
202+
* ENC_TYPE_WEP,
203+
* ENC_TYPE_WPA,
204+
* ENC_TYPE_WPA2,
205+
* ENC_TYPE_WPA2_ENTERPRISE,
206+
* ENC_TYPE_WPA3,
207+
* ENC_TYPE_NONE,
208+
* ENC_TYPE_AUTO,
209+
* ENC_TYPE_UNKNOWN = 255
210+
*/
211+
uint8_t encryptionType(uint8_t networkItem);
212+
213+
uint8_t* BSSID(uint8_t networkItem, uint8_t* bssid);
214+
uint8_t channel(uint8_t networkItem);
215+
216+
/*
217+
* Return the RSSI of the networks discovered during the scanNetworks
218+
*
219+
* param networkItem: specify from which network item want to get the information
220+
*
221+
* return: signed value of RSSI of the specified item on the networks scanned list
222+
*/
223+
int32_t RSSI(uint8_t networkItem);
224+
186225

187226
uint8_t channel();
188227

libraries/lwIpWrapper/src/CNetIf.cpp

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -811,6 +811,43 @@ uint8_t CWifiStation::getChannel() {
811811
return (uint8_t)access_point_cfg.channel;
812812
}
813813

814+
const char* CWifiStation::getSSID(uint8_t i)
815+
{
816+
if (access_points.size() > 0 && i < access_points.size()) {
817+
return (const char*)access_points[i].ssid;
818+
}
819+
return nullptr;
820+
}
821+
822+
int32_t CWifiStation::getRSSI(uint8_t i) {
823+
if (access_points.size() > 0 && i < access_points.size()) {
824+
return (int32_t)access_points[i].rssi;
825+
}
826+
return 0;
827+
}
828+
829+
uint8_t CWifiStation::getEncrType(uint8_t i) {
830+
if (access_points.size() > 0 && i < access_points.size()) {
831+
return Encr2wl_enc(access_points[i].encryption_mode);
832+
}
833+
return 0;
834+
}
835+
836+
uint8_t* CWifiStation::getBSSID(uint8_t i, uint8_t* bssid) {
837+
if (access_points.size() > 0 && i < access_points.size()) {
838+
CNetUtilities::macStr2macArray(bssid, (const char*)access_points[i].bssid);
839+
return bssid;
840+
}
841+
return nullptr;
842+
}
843+
844+
uint8_t CWifiStation::getChannel(uint8_t i) {
845+
if (access_points.size() > 0 && i < access_points.size()) {
846+
return (uint8_t)access_points[i].channel;
847+
}
848+
return 0;
849+
}
850+
814851
int CWifiStation::setLowPowerMode() {
815852
return CEspControl::getInstance().setPowerSaveMode(1);
816853
}

libraries/lwIpWrapper/src/CNetIf.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,12 @@ class CWifiStation : public CNetIf {
259259
virtual uint8_t getEncryptionType();
260260
virtual uint8_t getChannel();
261261

262+
const char* getSSID(uint8_t i);
263+
int32_t getRSSI(uint8_t i);
264+
uint8_t getEncrType(uint8_t i);
265+
uint8_t* getBSSID(uint8_t i, uint8_t* bssid);
266+
uint8_t getChannel(uint8_t i);
267+
262268
int setLowPowerMode();
263269
int resetLowPowerMode();
264270
protected:

0 commit comments

Comments
 (0)