Gen3 reading incorrect wireless security, cipher


#1

I am currently writing a program to dump all configuration data from any Particle device using WiFi.getCredentials. When I run the code on a Photon, I get the correct wireless SSID, security type and cipher type.

When I run the same code on an Argon or Xenon, I get the correct SSID but the security type shows “open” and the cipher shows “not set”.

I did the obligatory doc search but didn’t find anything related. Does anyone know of any differences? Here is the code:

    byte bssid[6],
         mac[6];
    WiFiAccessPoint ap[5];
    
    int found = WiFi.getCredentials(ap, 5);
    Serial.printf("WiFi Scan:\n\n");
    
    // WIFI MAC
    WiFi.macAddress(mac);
    Serial.print("MAC: ");
    Serial.printlnf("%02X:%02X:%02X:%02X:%02X:%02X", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);    
    
    // Local IP
    Serial.print("Local IP: ");
    Serial.println(WiFi.localIP());
    
    // BSSID
    WiFi.BSSID(bssid);
    Serial.print("BSSID: ");
    Serial.printlnf("%02X:%02X:%02X:%02X:%02X:%02X", bssid[0], bssid[1], bssid[2], bssid[3], bssid[4], bssid[5]);    
    
    // Print all known wireless networks
    for (int i = 0; i < found; i++) 
    {
        Serial.printf("Network: %d\n", i);
        Serial.print("  SSID: ");
        Serial.println(ap[i].ssid);
        // Security type
        Serial.print("  Security: ");
        switch (ap[i].security)
        {
            case WLAN_SEC_UNSEC:
                Serial.println("Open");
                break;
            case WLAN_SEC_WEP:
                Serial.println("WEP");
                break;
            case WLAN_SEC_WPA:
                Serial.println("WPA");
                break;
            case WLAN_SEC_WPA2:
                Serial.println("WPA2");
                break;
#if Wiring_WpaEnterprise == 1
            case WLAN_SEC_WPA_ENTERPRISE:
                Serial.println("WPA Enterprise");
                break;
            case WLAN_SEC_WPA2_ENTERPRISE:
                Serial.println("WPA2 Enterprise");
                break;
#endif
            default:
                Serial.println("Unknown");
                break;
        }
        // Cipher type
        Serial.print("  Cipher: ");
        switch (ap[i].cipher)
        {
            case WLAN_CIPHER_NOT_SET:
                Serial.println("Not set");
                break;
            case WLAN_CIPHER_AES:
                Serial.println("AES");
                break;
            case WLAN_CIPHER_TKIP:
                Serial.println("TKIP");
                break;
            case WLAN_CIPHER_AES_TKIP:
                Serial.println("AES-TKIP");
                break;
            default:
                Serial.println("Unknown");
                break;
        }
    }

#2

Ignore the Xenon mention above…obviously it doesn’t have wireless.

And for the record, the security is WPA2 and the cipher is AES.


#3

Playing around I put the Argon into listen mode and re-entered the wireless config.

Now the security correctly shows “WPA2” but the cipher is still showing “not set”.


#4

Thanks for the report! @cheong would you take a look and see if the WiFi.getCredentials function is properly supported at the HAL level for Gen 3 devices?


#5

@will Thanks…I’ll be happy to help test if you wish.


#6

We identified that there was an issue with the underlying HAL function and have issued a pull request to fix, visible here:

Looks like it will likely be merged into the upcoming release of v080-rc.27.


#7

@will I’m not sure how this fixes my original issue. I didn’t have a problem reading the MAC address, I had the issue of the Argon not properly determining the security type for the wireless connection. The code works fine with a Photon but always reads “not set” when working with the Argon.

Or is this change you referenced also going to fix my issue?


#8

Oops – apologies if I misunderstood the issue. @cheong would you take another look at the issue that @syrinxtech is reporting?


#9

@will, @cheong Any movement on testing the Argon’s ability to correctly read the wireless security cipher setting?


#10

Hi @syrinxtech, thanks for your report, we are looking into this issue and will get back to you as soon as possible.


#11

Thanks @cheong.


#12

The cipher setting does not make much sense on an Argon, as there is no way to enforce the cipher type during the connection attempt. As you are most likely aware we use ESP32 as the Network Co-Processor, the only two cases where the cipher comes into play in STA mode in esp-idf is when retrieving the information on the current access point the device is connected or during the scan, however this information is not exposed in esp32-at, which our Argon NCP firmware is based on.

As a compatibility workaround for now we will most likely simply return WLAN_CIPHER_AES_TKIP for WPA and WPA2 access points in both getCredentials() and scan() indicating ‘automatic’ selection.

@syrinxtech Could you tell us more about the use case for this?


#13

The reason the issue came up is that I was writing a program to dump as much configuration about a Particle device as possible. One of those groups of configuration information for wireless-capable devices was a list of stored SSIDs, security types and ciphers. This information was obtained using the getCredentials() call as shown in the code that I posted earlier in this thread. It worked fine on a Photon but on the Argon it always returned a 0, or “not set” for the cipher type.

Now that you told me it isn’t exposed by esp32-at, that makes sense that it always returns 0. So, if I understand correctly, you’re going to make a change so that it always returns TKIP or WPA2? That’s fine, as long as I know that ahead of time I can deal with it.

Thanks for the clarification.


#14

So, if I understand correctly, you’re going to make a change so that it always returns TKIP or WPA2?

The security type (i.e. UNSEC / WEP / WPA / WPA2) should be returned correctly, the change I propose is to always return WLAN_CIPHER_AES_TKIP (i.e. both CCMP and TKIP) for any stored credentials that have security type set to WPA or WPA2.


#15

That works for me.