Comparing WiFi.SSID()s?


so i'm trying scan networks in area several access points broadcast same name, , want each 1 appear once in list.
i have tried various things, , attempting string comparison see if ssid has been seen before, getting odd results, networks different names being treated same, , ones same name different, apparently without logic!
i'm sure have made stupid error, please help!
code: [select]
for (int = 0; < noofnetworks; i++) {
    boolean inlist = false;
    (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 , rssi 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 += "<br />";
    }
    else{
      serial.print(wifi.ssid(i));
      serial.println(" in list");
    }
  }


this gives following on serial monitor:
code: [select]
new ssid: cafe
new ssid: cafe
cafe-ppsk in list
cafe-ppsk in list
cafe in list
cafe-ppsk in list
cafe-ppsk in list
cafe in list
cafe-ppsk in list
cafe in list
cafe in list
cafe-ppsk in list
cafe in list
cafe in list
cafe-ppsk in list
cafe-ppsk in list
cafe-ppsk in list
cafe-ppsk in list


and list contains "cafe" , "cafe"

what doing wrong? :'(

i fixed changing:

code: [select]
if (strcmp(wifi.ssid(j),wifi.ssid(i))) {
        inlist = true;
      }


into:

code: [select]
if ((string(wifi.ssid(j))==string(wifi.ssid(i)))) {
        inlist = true;
      }


anyone able shed light on going on here?
 :smiley-confuse:


Arduino Forum > Using Arduino > Programming Questions > Comparing WiFi.SSID()s?


arduino

Comments