Skip to content

Commit 628b668

Browse files
dok-netme-no-dev
andauthored
Add overloads to support __FlashStringHelper like ESP8266 has them. (espressif#8111)
Co-authored-by: Me No Dev <me-no-dev@users.noreply.github.com>
1 parent 9d8471d commit 628b668

File tree

4 files changed

+13
-4
lines changed

4 files changed

+13
-4
lines changed

cores/esp32/WString.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
// A pure abstract class forward used as a means to proide a unique pointer type
3535
// but really is never defined.
3636
class __FlashStringHelper;
37-
#define FPSTR(pstr_pointer) (reinterpret_cast<const __FlashStringHelper *>(pstr_pointer))
37+
#define FPSTR(str_pointer) (reinterpret_cast<const __FlashStringHelper *>(str_pointer))
3838
#define F(string_literal) (FPSTR(PSTR(string_literal)))
3939

4040
// An inherited class for holding the result of a concatenation. These

libraries/ESPmDNS/src/ESPmDNS.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,15 @@ MDNSResponder::~MDNSResponder() {
6060
end();
6161
}
6262

63-
bool MDNSResponder::begin(const char* hostName){
63+
bool MDNSResponder::begin(const String& hostName){
6464
if(mdns_init()){
6565
log_e("Failed starting MDNS");
6666
return false;
6767
}
6868
//WiFi.onEvent(_on_sys_event);
6969
_hostname = hostName;
7070
_hostname.toLowerCase();
71-
if(mdns_hostname_set(hostName)) {
71+
if(mdns_hostname_set(hostName.c_str())) {
7272
log_e("Failed setting MDNS hostname");
7373
return false;
7474
}

libraries/ESPmDNS/src/ESPmDNS.h

+4-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,10 @@ class MDNSResponder {
5454
public:
5555
MDNSResponder();
5656
~MDNSResponder();
57-
bool begin(const char* hostName);
57+
bool begin(const String& hostName);
58+
bool begin(const char* hostName){
59+
return begin(String(hostName));
60+
}
5861
void end();
5962

6063
void setInstanceName(String name);

libraries/WiFi/src/WiFiSTA.h

+6
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,13 @@ class WiFiSTAClass
4545
public:
4646

4747
wl_status_t begin(const char* wpa2_ssid, wpa2_auth_method_t method, const char* wpa2_identity=NULL, const char* wpa2_username=NULL, const char *wpa2_password=NULL, const char* ca_pem=NULL, const char* client_crt=NULL, const char* client_key=NULL, int32_t channel=0, const uint8_t* bssid=0, bool connect=true);
48+
wl_status_t begin(const String& wpa2_ssid, wpa2_auth_method_t method, const String& wpa2_identity = (const char*)NULL, const String& wpa2_username = (const char*)NULL, const String& wpa2_password = (const char*)NULL, const String& ca_pem = (const char*)NULL, const String& client_crt = (const char*)NULL, const String& client_key = (const char*)NULL, int32_t channel=0, const uint8_t* bssid=0, bool connect=true) {
49+
return begin(wpa2_ssid.c_str(), method, wpa2_identity.c_str(), wpa2_username.c_str(), wpa2_password.c_str(), ca_pem.c_str(), client_crt.c_str(), client_key.c_str(), channel, bssid, connect);
50+
}
4851
wl_status_t begin(const char* ssid, const char *passphrase = NULL, int32_t channel = 0, const uint8_t* bssid = NULL, bool connect = true);
52+
wl_status_t begin(const String& ssid, const String& passphrase = (const char*)NULL, int32_t channel = 0, const uint8_t* bssid = NULL, bool connect = true) {
53+
return begin(ssid.c_str(), passphrase.c_str(), channel, bssid, connect);
54+
}
4955
wl_status_t begin(char* ssid, char *passphrase = NULL, int32_t channel = 0, const uint8_t* bssid = NULL, bool connect = true);
5056
wl_status_t begin();
5157

0 commit comments

Comments
 (0)