So I’m trying to scan for networks in an area where several access points broadcast with the same name, and I only want each one to appear once in my list.
I have tried various things, and am now attempting a string comparison to see if this SSID has been seen before, but I am getting very odd results, where networks with different names are being treated as the same, and ones with the same name as different, apparently without logic!
I’m sure I have made a stupid error, but please help!
for (int i = 0; i < NoOfNetworks; i++) {
boolean InList = false;
for (int j = 0; j < i; j++) {
if (strcmp(WiFi.SSID(j),WiFi.SSID(i))) {
InList = true;
}
}
if (!InList) {
Serial.print("New SSID: ");
Serial.println(WiFi.SSID(i));
// Print SSID and RSSI for each network found
st += "<input type='radio' name='ssid' value='";
st += WiFi.SSID(i);
st += "'>";
st += WiFi.SSID(i);
st += " (";
st += WiFi.RSSI(i);
st += ")";
st += (WiFi.encryptionType(i) == ENC_TYPE_NONE) ? " " : "*";
st += "
";
}
else{
Serial.print(WiFi.SSID(i));
Serial.println(" already in list");
}
}
This gives the following on the Serial monitor:
New SSID: cafe
New SSID: cafe
cafe-PPSK already in list
cafe-PPSK already in list
cafe already in list
cafe-PPSK already in list
cafe-PPSK already in list
cafe already in list
cafe-PPSK already in list
cafe already in list
cafe already in list
cafe-PPSK already in list
cafe already in list
cafe already in list
cafe-PPSK already in list
cafe-PPSK already in list
cafe-PPSK already in list
cafe-PPSK already in list
and the list only contains “cafe” and “cafe”
What am I doing wrong? :’(