I have network names that I know and want the device to do something when it sees these networks I was using this code:
WiFiAccessPoint aps[20];
int found = WiFi.scan(aps, 20);
for (int i=0; i<found; i++) {
WiFiAccessPoint& ap = aps[i];
//if(ap.ssid == "FiOS-34K20"){!!!!
Serial.print("SSID: ");
Serial.println(ap.ssid);
Serial.print("Security: ");
Serial.println(ap.security);
Serial.print("Channel: ");
Serial.println(ap.channel);
Serial.print("RSSI: ");
Serial.println(ap.rssi);
//delay(5000);
//}!!!!
}
The part I am interested in I commented out and placed !!! next to, why would this if statement not work what kind of object is “ap.ssid” since this doesn’t work I am assuming it is not a string.
This is also a good example for the C/C++ practice @bko showed here to place the constant on the left side of the equality operator.
If you should happen to use the assignment operator (=) instead of equality (==) you will get a compiletime error and not a successful build producing a program that will behave in an unexpected manner.