Skip to content

Commit 1f670db

Browse files
committed
code review
1 parent 4ef2700 commit 1f670db

File tree

3 files changed

+19
-19
lines changed

3 files changed

+19
-19
lines changed

hardware/esp8266com/esp8266/libraries/ESP8266WiFi/src/ESP8266WiFi.cpp

+12-12
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ extern "C" void esp_schedule();
3838
extern "C" void esp_yield();
3939

4040
ESP8266WiFiClass::ESP8266WiFiClass()
41+
: _useApMode(false)
42+
, _useClientMode(false)
4143
{
42-
useApMode = false;
43-
useClientMode = false;
4444
}
4545

4646
void ESP8266WiFiClass::mode(WiFiMode m)
@@ -55,9 +55,9 @@ int ESP8266WiFiClass::begin(char* ssid, char *passphrase, int32_t channel, uint8
5555
}
5656

5757
int ESP8266WiFiClass::begin(const char* ssid, const char *passphrase, int32_t channel, uint8_t bssid[6]){
58-
useClientMode = true;
58+
_useClientMode = true;
5959

60-
if(useApMode) {
60+
if(_useApMode) {
6161
// turn on AP+STA mode
6262
mode(WIFI_AP_STA);
6363
} else {
@@ -143,7 +143,7 @@ void ESP8266WiFiClass::softAP(const char* ssid)
143143

144144
void ESP8266WiFiClass::softAP(const char* ssid, const char* passphrase, int channel)
145145
{
146-
if(useClientMode) {
146+
if(_useClientMode) {
147147
// turn on AP+STA mode
148148
mode(WIFI_AP_STA);
149149
} else {
@@ -371,18 +371,18 @@ bool ESP8266WiFiClass::isHidden(uint8_t i)
371371
return (it->is_hidden != 0);
372372
}
373373

374-
bool ESP8266WiFiClass::getNetworkInfo(uint8_t i, const char** ssid, uint8_t * encType, int32_t * RSSI, uint8_t ** BSSID, int32_t * channel, bool * isHidden)
374+
bool ESP8266WiFiClass::getNetworkInfo(uint8_t i, String &ssid, uint8_t &encType, int32_t &rssi, uint8_t* &bssid, int32_t &channel, bool &isHidden)
375375
{
376376
struct bss_info* it = reinterpret_cast<struct bss_info*>(_getScanInfoByIndex(i));
377377
if (!it)
378378
return false;
379379

380-
*ssid = (const char*) &it->ssid[0]; // move ptr
381-
*encType = encryptionType(i);
382-
*RSSI = it->rssi;
383-
*BSSID = &it->bssid[0]; // move ptr
384-
*channel = it->channel;
385-
*isHidden = (it->is_hidden != 0);
380+
ssid = (const char*)it->ssid;
381+
encType = encryptionType(i);
382+
rssi = it->rssi;
383+
bssid = it->bssid; // move ptr
384+
channel = it->channel;
385+
isHidden = (it->is_hidden != 0);
386386

387387
return true;
388388
}

hardware/esp8266com/esp8266/libraries/ESP8266WiFi/src/ESP8266WiFi.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ class ESP8266WiFiClass
238238
* @param isHidden bool *
239239
* @return (true if ok)
240240
*/
241-
bool getNetworkInfo(uint8_t networkItem, const char** ssid, uint8_t * encryptionType, int32_t * RSSI, uint8_t ** BSSID, int32_t * channel, bool * isHidden);
241+
bool getNetworkInfo(uint8_t networkItem, String &ssid, uint8_t &encryptionType, int32_t &RSSI, uint8_t* &BSSID, int32_t &channel, bool &isHidden);
242242

243243

244244
/*
@@ -290,8 +290,8 @@ class ESP8266WiFiClass
290290
static void _smartConfigDone(void* result);
291291
bool _smartConfigStarted = false;
292292

293-
bool useApMode;
294-
bool useClientMode;
293+
bool _useApMode;
294+
bool _useClientMode;
295295

296296
static size_t _scanCount;
297297
static void* _scanResult;

hardware/esp8266com/esp8266/libraries/ESP8266WiFi/src/ESP8266WiFiMulti.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -59,21 +59,21 @@ wl_status_t ESP8266WiFiMulti::run(void) {
5959
DEBUG_WIFI_MULTI("[WIFI] %d networks found\n", n);
6060
for(int8_t i = 0; i < n; ++i) {
6161

62-
const char * ssid_scan;
62+
String ssid_scan;
6363
int32_t rssi_scan;
6464
uint8_t sec_scan;
65-
uint8_t * BSSID_scan;
65+
uint8_t* BSSID_scan;
6666
int32_t chan_scan;
6767
bool hidden_scan;
6868

69-
WiFi.getNetworkInfo(i, &ssid_scan, &sec_scan, &rssi_scan, &BSSID_scan, &chan_scan, &hidden_scan);
69+
WiFi.getNetworkInfo(i, ssid_scan, sec_scan, rssi_scan, BSSID_scan, chan_scan, hidden_scan);
7070

7171

7272
bool known = false;
7373
for(uint32_t x = 0; x < APlist.size(); x++) {
7474
WifiAPlist_t entry = APlist[x];
7575

76-
if(strcmp(entry.ssid, ssid_scan) == 0) { // SSID match
76+
if(ssid_scan == entry.ssid) { // SSID match
7777
known = true;
7878
if(rssi_scan > bestNetworkDb) { // best network
7979
if(sec_scan == ENC_TYPE_NONE || entry.passphrase) { // check for passphrase if not open wlan

0 commit comments

Comments
 (0)