Skip to content

Commit e82b74e

Browse files
committed
Merge pull request #1850 from 4m1g0/fixPSK
Allow PSK instead of passphrase in WiFiSTA::begin
2 parents fa7e903 + a06ceb8 commit e82b74e

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

libraries/ESP8266WiFi/src/ESP8266WiFiSTA.cpp

+5-2
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ wl_status_t ESP8266WiFiSTAClass::begin(const char* ssid, const char *passphrase,
106106
return WL_CONNECT_FAILED;
107107
}
108108

109-
if(passphrase && strlen(passphrase) > 63) {
109+
if(passphrase && strlen(passphrase) > 64) {
110110
// fail passphrase too long!
111111
return WL_CONNECT_FAILED;
112112
}
@@ -115,7 +115,10 @@ wl_status_t ESP8266WiFiSTAClass::begin(const char* ssid, const char *passphrase,
115115
strcpy(reinterpret_cast<char*>(conf.ssid), ssid);
116116

117117
if(passphrase) {
118-
strcpy(reinterpret_cast<char*>(conf.password), passphrase);
118+
if (strlen(passphrase) == 64) // it's not a passphrase, is the PSK
119+
memcpy(reinterpret_cast<char*>(conf.password), passphrase, 64);
120+
else
121+
strcpy(reinterpret_cast<char*>(conf.password), passphrase);
119122
} else {
120123
*conf.password = 0;
121124
}

0 commit comments

Comments
 (0)