Skip to content

Commit e95a615

Browse files
committed
Merge pull request #843 from pgollor/wifilib_mod
use String instead of char pointer for SSID() and psk()
2 parents 3241d90 + 9351984 commit e95a615

File tree

3 files changed

+9
-13
lines changed

3 files changed

+9
-13
lines changed

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

+4-4
Original file line numberDiff line numberDiff line change
@@ -370,18 +370,18 @@ IPAddress ESP8266WiFiClass::gatewayIP()
370370
return IPAddress(ip.gw.addr);
371371
}
372372

373-
char* ESP8266WiFiClass::SSID()
373+
String ESP8266WiFiClass::SSID() const
374374
{
375375
static struct station_config conf;
376376
wifi_station_get_config(&conf);
377-
return reinterpret_cast<char*>(conf.ssid);
377+
return String(reinterpret_cast<char*>(conf.ssid));
378378
}
379379

380-
const char* ESP8266WiFiClass::psk()
380+
String ESP8266WiFiClass::psk() const
381381
{
382382
static struct station_config conf;
383383
wifi_station_get_config(&conf);
384-
return reinterpret_cast<const char*>(conf.password);
384+
return String(reinterpret_cast<char*>(conf.password));
385385
}
386386

387387
uint8_t* ESP8266WiFiClass::BSSID(void)

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -173,21 +173,21 @@ class ESP8266WiFiClass
173173
*
174174
* return: ssid string
175175
*/
176-
char* SSID();
176+
String SSID() const;
177177

178178
/*
179179
* Return the current pre shared key associated with the network
180180
*
181181
* return: psk string
182182
*/
183-
const char* psk();
183+
String psk() const;
184184

185185
/*
186186
* Return the current bssid / mac associated with the network if configured
187187
*
188188
* return: bssid uint8_t *
189189
*/
190-
uint8_t * BSSID(void);
190+
uint8_t *BSSID(void);
191191

192192
/*
193193
* Return the current bssid / mac associated with the network if configured

hardware/esp8266com/esp8266/libraries/ESP8266mDNS/examples/OTA-mDNS-SPIFFS/OTA-mDNS-SPIFFS.ino

+2-6
Original file line numberDiff line numberDiff line change
@@ -240,12 +240,8 @@ void setup()
240240
delay(10);
241241
}
242242

243-
// ... Load sdk config.
244-
String ssid(WiFi.SSID());
245-
String psk(WiFi.psk());
246-
247-
// ... Compare fiel config with sdk config.
248-
if (ssid != station_ssid || psk != station_psk)
243+
// ... Compare file config with sdk config.
244+
if (WiFi.SSID() != station_ssid || WiFi.psk() != station_psk)
249245
{
250246
Serial.println("WiFi config changed.");
251247

0 commit comments

Comments
 (0)