Closed
Description
Not my finest example but I found constantly adding Ap's could crash the party.
I added in a dirty check for existing matching entries,
there should be another test for password matching but I am super lazy.
This works in both 2.3 and 2.4
I see that the CleanApList is also being made public.
Just seems wrong to clean a list, simply to create it again.
// ESP8266WiFiMulti.h
public:
bool existsAP(const char* ssid, const char *passphrase = NULL);
private:
bool APlistExists(const char* ssid, const char *passphrase = NULL);
// ESP8266WiFiMulti.cpp
// added a call to new function APlistExists ()
// just above above the line that follows in function ESP8266WiFiMulti::APlistAdd
if (APlistExists(ssid,passphrase)){return true;}
newAP.ssid = strdup(ssid);
// This was the public function.
// I normally put this just above the public addAP function near the top.
bool ESP8266WiFiMulti::existsAP(const char* ssid, const char *passphrase) { return APlistExists(ssid, passphrase);}
// This was the private function.
// I normally put this at the bottom
bool ESP8266WiFiMulti::APlistExists(const char* ssid, const char *passphrase) {
for(uint32_t i = 0; i < APlist.size(); i++) {
WifiAPlist_t entry = APlist[i];
if(entry.ssid && entry.ssid == ssid){return true;}
}
return false;
}
Hope it comes out code friendly.