@@ -89,7 +89,8 @@ int CLAppConn::start() {
8989 // WiFi.setHostname(mdnsName);
9090
9191 // Initiate network connection request (3rd argument, channel = 0 is 'auto')
92- WiFi.begin (bestBSSID, stationList[bestStation]->password .c_str (), 0 , bestBSSID);
92+ // WiFi.begin(bestBSSID, stationList[bestStation]->password.c_str(), 0, bestBSSID);
93+ WiFi.begin (stationList[bestStation]->ssid .c_str (), stationList[bestStation]->password .c_str ());
9394
9495 // Wait to connect, or timeout
9596 unsigned long start = millis ();
@@ -231,7 +232,7 @@ int CLAppConn::loadPrefs() {
231232 json[" stations" ].as <JsonArray>()[i][" pass" ] ) {
232233 Station s;
233234 s.ssid = json[" stations" ].as <JsonArray>()[i][" ssid" ].as <String>();
234- this ->urlDecode (& s.password , & json[" stations" ].as <JsonArray>()[i][" pass" ].as <String>());
235+ this ->urlDecode (s.password , json[" stations" ].as <JsonArray>()[i][" pass" ].as <String>(). c_str ());
235236 Serial.println (s.ssid );
236237 stationList[i] = &s;
237238 stationCount++;
@@ -255,7 +256,8 @@ int CLAppConn::loadPrefs() {
255256 load_as_ap = json[" accesspoint" ].as <bool >();
256257 this ->apName = json[" ap_ssid" ].as <String>().c_str ();
257258
258- this ->urlDecode (&this ->apPass , &json[" ap_pass" ].as <String>());
259+ String apPassStr = json[" ap_pass" ].as <String>();
260+ this ->urlDecode (this ->apPass , json[" ap_pass" ].as <String>().c_str ());
259261
260262 if (json[" ap_channel" ]) { this ->ap_channel = json[" ap_channel" ].as <int >(); } else { ap_channel = 1 ; }
261263 if (json[" ap_dhcp" ]) { this ->ap_dhcp = json[" ap_dhcp" ].as <bool >(); } else { ap_dhcp = true ; }
@@ -272,7 +274,7 @@ int CLAppConn::loadPrefs() {
272274
273275 // OTA
274276 this ->otaEnabled = json[" ota_enabled" ].as <bool >();
275- this ->urlDecode (& this ->otaPassword , & json[" ota_password" ].as <String>());
277+ this ->urlDecode (this ->otaPassword , json[" ota_password" ].as <String>(). c_str ());
276278
277279 // NTP
278280 this ->ntpServer = json[" ntp_server" ].as <String>();
@@ -323,18 +325,22 @@ int CLAppConn::savePrefs() {
323325 uint8_t i=0 ;
324326 if (index < 0 && this ->ssid != " " ) {
325327 json[" stations" ][i][" ssid" ] = this ->ssid ;
326- this ->urlEncode (& this ->password , & json[" stations" ][i][" pass" ].as <String>());
328+ this ->urlEncode (this ->password , json[" stations" ][i][" pass" ].as <String>(). c_str ());
327329 i++;
328330 }
329331
330332 for (int i=0 ; i < count && stationList[i]; i++) {
331333 json[" stations" ][i][" ssid" ] = stationList[i]->ssid ;
332334
333335 if (index >= 0 && i == index) {
334- this ->urlEncode (&json[" stations" ][i][" pass" ].as <String>(), &this ->password );
336+ String encString (" " );
337+ this ->urlEncode (encString, this ->password .c_str ());
338+ json[" stations" ][i][" pass" ] = encString;
335339 }
336340 else {
337- this ->urlEncode (&json[" stations" ][i][" pass" ].as <String>(), &stationList[i]->password );
341+ String encString (" " );
342+ this ->urlEncode (encString, stationList[i]->password .c_str ());
343+ json[" stations" ][i][" pass" ] = encString;
338344 }
339345 }
340346 }
@@ -351,11 +357,15 @@ int CLAppConn::savePrefs() {
351357 json[" user" ] = this ->user ;
352358 json[" pwd" ] = this ->pwd ;
353359 json[" ota_enabled" ] = this ->otaEnabled ;
354- this ->urlEncode (&json[" ota_password" ].as <String>(), &this ->otaPassword );
360+ String t (" " );
361+ this ->urlEncode (t, this ->otaPassword .c_str ());
362+ json[" ota_password" ] = t;
355363
356364 json[" accesspoint" ] = this ->load_as_ap ;
357365 json[" ap_ssid" ] = this -> apName;
358- this ->urlEncode (&json[" ap_pass" ].as <String>(), &this ->otaPassword );
366+ t = " " ;
367+ this ->urlEncode (t, this ->otaPassword .c_str ());
368+ json[" ap_pass" ] = t;
359369 json[" ap_dhcp" ] = this ->ap_dhcp ;
360370 if (apIP.ip ) json[" ap_ip" ][" ip" ] = apIP.ip ->toString ();
361371 if (apIP.netmask ) json[" ap_ip" ][" netmask" ] = apIP.netmask ->toString ();
0 commit comments