mirror of
https://github.com/esp8266/Arduino.git
synced 2025-06-06 05:21:22 +03:00
do check if ssid is an empty String ""
use strdup to save some flash #386 part 2
This commit is contained in:
parent
c0df9b0430
commit
b620060671
@ -68,7 +68,7 @@ int ESP8266WiFiClass::begin(const char* ssid, const char *passphrase, int32_t ch
|
||||
mode(WIFI_STA);
|
||||
}
|
||||
|
||||
if(!ssid || strlen(ssid) > 31) {
|
||||
if(!ssid || *ssid == 0x00 || strlen(ssid) > 31) {
|
||||
// fail SSID to long or missing!
|
||||
return WL_CONNECT_FAILED;
|
||||
}
|
||||
@ -154,7 +154,7 @@ void ESP8266WiFiClass::softAP(const char* ssid, const char* passphrase, int chan
|
||||
mode(WIFI_AP);
|
||||
}
|
||||
|
||||
if(!ssid || strlen(ssid) > 31) {
|
||||
if(!ssid || *ssid == 0x00 || strlen(ssid) > 31) {
|
||||
// fail SSID to long or missing!
|
||||
return;
|
||||
}
|
||||
|
@ -25,6 +25,7 @@
|
||||
|
||||
#include "ESP8266WiFiMulti.h"
|
||||
#include <limits.h>
|
||||
#include <string.h>
|
||||
|
||||
ESP8266WiFiMulti::ESP8266WiFiMulti() {
|
||||
}
|
||||
@ -151,7 +152,7 @@ bool ESP8266WiFiMulti::APlistAdd(const char* ssid, const char *passphrase) {
|
||||
|
||||
WifiAPlist_t newAP;
|
||||
|
||||
if(!ssid || strlen(ssid) > 31) {
|
||||
if(!ssid || *ssid == 0x00 || strlen(ssid) > 31) {
|
||||
// fail SSID to long or missing!
|
||||
return false;
|
||||
}
|
||||
@ -161,21 +162,18 @@ bool ESP8266WiFiMulti::APlistAdd(const char* ssid, const char *passphrase) {
|
||||
return false;
|
||||
}
|
||||
|
||||
newAP.ssid = (char*) malloc((strlen(ssid) + 1));
|
||||
newAP.ssid = strdup(ssid);
|
||||
|
||||
if(!newAP.ssid) {
|
||||
return false;
|
||||
}
|
||||
|
||||
strcpy(newAP.ssid, ssid);
|
||||
|
||||
if(passphrase && *passphrase != 0x00) {
|
||||
newAP.passphrase = (char*) malloc((strlen(passphrase) + 1));
|
||||
newAP.passphrase = strdup(passphrase);
|
||||
if(!newAP.passphrase) {
|
||||
free(newAP.ssid);
|
||||
return false;
|
||||
}
|
||||
strcpy(newAP.passphrase, passphrase);
|
||||
}
|
||||
|
||||
APlist.push_back(newAP);
|
||||
|
Loading…
x
Reference in New Issue
Block a user