Skip to content

Commit 79e5d4c

Browse files
masciime-no-dev
authored andcommitted
Allow PSK instead of passphrase in WiFiSTA::begin (#897)
1 parent 7d2bffb commit 79e5d4c

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

libraries/WiFi/src/WiFiSTA.cpp

+5-2
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ wl_status_t WiFiSTAClass::begin(const char* ssid, const char *passphrase, int32_
110110
return WL_CONNECT_FAILED;
111111
}
112112

113-
if(passphrase && strlen(passphrase) > 63) {
113+
if(passphrase && strlen(passphrase) > 64) {
114114
// fail passphrase too long!
115115
return WL_CONNECT_FAILED;
116116
}
@@ -119,7 +119,10 @@ wl_status_t WiFiSTAClass::begin(const char* ssid, const char *passphrase, int32_
119119
strcpy(reinterpret_cast<char*>(conf.sta.ssid), ssid);
120120

121121
if(passphrase) {
122-
strcpy(reinterpret_cast<char*>(conf.sta.password), passphrase);
122+
if (strlen(passphrase) == 64) // it's not a passphrase, is the PSK
123+
memcpy(reinterpret_cast<char*>(conf.sta.password), passphrase, 64);
124+
else
125+
strcpy(reinterpret_cast<char*>(conf.sta.password), passphrase);
123126
} else {
124127
*conf.sta.password = 0;
125128
}

0 commit comments

Comments
 (0)