1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-04-19 23:22:16 +03:00

Merge pull request #1850 from 4m1g0/fixPSK

Allow PSK instead of passphrase in WiFiSTA::begin
This commit is contained in:
Ivan Grokhotkov 2016-04-13 14:17:46 +03:00
commit e82b74eab2

View File

@ -106,7 +106,7 @@ wl_status_t ESP8266WiFiSTAClass::begin(const char* ssid, const char *passphrase,
return WL_CONNECT_FAILED;
}
if(passphrase && strlen(passphrase) > 63) {
if(passphrase && strlen(passphrase) > 64) {
// fail passphrase too long!
return WL_CONNECT_FAILED;
}
@ -115,7 +115,10 @@ wl_status_t ESP8266WiFiSTAClass::begin(const char* ssid, const char *passphrase,
strcpy(reinterpret_cast<char*>(conf.ssid), ssid);
if(passphrase) {
strcpy(reinterpret_cast<char*>(conf.password), passphrase);
if (strlen(passphrase) == 64) // it's not a passphrase, is the PSK
memcpy(reinterpret_cast<char*>(conf.password), passphrase, 64);
else
strcpy(reinterpret_cast<char*>(conf.password), passphrase);
} else {
*conf.password = 0;
}