WiFi.encryptionType output 255

Hi everyone,

i have done a wifi networkscan on an ESP8266 (programmed by Arduino IDE).

 byte numSsid = WiFi.scanNetworks();

then i get the encryption of each network:

byte encryption = WiFi.encryptionType();

for the results of the encryption, the reference shows the possible returns:

  • TKIP (WPA) = 2
  • WEP = 5
  • CCMP (WPA) = 4
  • NONE = 7
  • AUTO = 8

but for some networks i get the result 255.
The question is, what means 255?.

alex

kalex:
the reference shows the possible returns

The WiFi library doesn't work with ESP8266 so either you're using the wrong library or you're using the wrong reference. Please post your entire sketch using code tags(</> button on the toolbar) and explain how you're using the ESP8266(i.e. as a serial module connected to a standard Arduino board, or programming the ESP8266 directly using the esp8266 Arduino core).

i programmed the ESP8266 directly using the esp8266 Arduino core.

The ESP supports the WiFi library in so far, that the ESP8266WiFi library refers directly to the Arduino Wifi library.

Here is my code:

String scanWIFI() {
  String wifi1 = "";

  int n = WiFi.scanNetworks();
  if (n == 0)
  wifi1 = "no networks found";		// if nothing is found

  else {
    wifi1 = "WLANs: " ;
    wifi1 = wifi1 + n;

    for (int i = 0; i < n; ++i)
    {
      wifi1 = wifi1 + "WIFI:(";                        // zeige am Zeilenanfang, dass es sich um eine "Wlan-Zeile" handelt
      wifi1 = wifi1 + WiFi.encryptionType(i);   //AuthType
      wifi1 = wifi1 + "," + char(34);
      wifi1 = wifi1 + WiFi.SSID(i);             // SSID
      wifi1 = wifi1 + char(34) + ",";
      wifi1 = wifi1 + WiFi.RSSI(i);              // Signal Strength
      wifi1 = wifi1 + ",";
      wifi1 = wifi1 + WiFi.BSSIDstr(i);         // Mac
      wifi1 = wifi1 + ",";
      wifi1 = wifi1 + WiFi.channel(i) ;   // Kanal
      wifi1 = wifi1  + ")\n";             // Klammer zu und Zeilenwechsel
    // Serial.println(WiFi.encryptionType(i));  
    }
  }

  return wifi1;
}

What i have done, is mainly

  int n = WiFi.scanNetworks();

and then i get for some networks

 wifi1 = wifi1 + WiFi.encryptionType(i);

the result 255, which is nowhere described.

kalex:
The ESP supports the WiFi library in so far, that the ESP8266WiFi library refers directly to the Arduino Wifi library.

There are some differences so you can't assume the Arduino reference always applies perfectly. Unfortunately the enc8266 core libraries are very lacking in documentation, apparently they expect you to just dig around in the source code to figure things out.

kalex:
for some networks i get the result 255.
The question is, what means 255?.

The source for encryptionType() is at:

As you can see, there are a couple of cases where it will return -1 which becomes 255 when cast to uint8_t.

thanks for your support.
the Link is quite interessting, i should have this idea before :slight_smile: