From c01e2c499d2e9d73eabcabefad85cecf6aa9215d Mon Sep 17 00:00:00 2001 From: Masaki Koyanagi Date: Sun, 3 Dec 2017 13:44:35 +0900 Subject: [PATCH] Allow PSK instead of passphrase in WiFiSTA::begin --- libraries/WiFi/src/WiFiSTA.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/libraries/WiFi/src/WiFiSTA.cpp b/libraries/WiFi/src/WiFiSTA.cpp index 1c462db1bc6..48fa9746637 100644 --- a/libraries/WiFi/src/WiFiSTA.cpp +++ b/libraries/WiFi/src/WiFiSTA.cpp @@ -110,7 +110,7 @@ wl_status_t WiFiSTAClass::begin(const char* ssid, const char *passphrase, int32_ return WL_CONNECT_FAILED; } - if(passphrase && strlen(passphrase) > 63) { + if(passphrase && strlen(passphrase) > 64) { // fail passphrase too long! return WL_CONNECT_FAILED; } @@ -119,7 +119,10 @@ wl_status_t WiFiSTAClass::begin(const char* ssid, const char *passphrase, int32_ strcpy(reinterpret_cast(conf.sta.ssid), ssid); if(passphrase) { - strcpy(reinterpret_cast(conf.sta.password), passphrase); + if (strlen(passphrase) == 64) // it's not a passphrase, is the PSK + memcpy(reinterpret_cast(conf.sta.password), passphrase, 64); + else + strcpy(reinterpret_cast(conf.sta.password), passphrase); } else { *conf.sta.password = 0; }