Skip to content

use String instead of char pointer for SSID() and psk() #843

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 30, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -370,18 +370,18 @@ IPAddress ESP8266WiFiClass::gatewayIP()
return IPAddress(ip.gw.addr);
}

char* ESP8266WiFiClass::SSID()
String ESP8266WiFiClass::SSID() const
{
static struct station_config conf;
wifi_station_get_config(&conf);
return reinterpret_cast<char*>(conf.ssid);
return String(reinterpret_cast<char*>(conf.ssid));
}

const char* ESP8266WiFiClass::psk()
String ESP8266WiFiClass::psk() const
{
static struct station_config conf;
wifi_station_get_config(&conf);
return reinterpret_cast<const char*>(conf.password);
return String(reinterpret_cast<char*>(conf.password));
}

uint8_t* ESP8266WiFiClass::BSSID(void)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,21 +173,21 @@ class ESP8266WiFiClass
*
* return: ssid string
*/
char* SSID();
String SSID() const;

/*
* Return the current pre shared key associated with the network
*
* return: psk string
*/
const char* psk();
String psk() const;

/*
* Return the current bssid / mac associated with the network if configured
*
* return: bssid uint8_t *
*/
uint8_t * BSSID(void);
uint8_t *BSSID(void);

/*
* Return the current bssid / mac associated with the network if configured
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,12 +240,8 @@ void setup()
delay(10);
}

// ... Load sdk config.
String ssid(WiFi.SSID());
String psk(WiFi.psk());

// ... Compare fiel config with sdk config.
if (ssid != station_ssid || psk != station_psk)
// ... Compare file config with sdk config.
if (WiFi.SSID() != station_ssid || WiFi.psk() != station_psk)
{
Serial.println("WiFi config changed.");

Expand Down