Jump to content
electrotwelve

WiFi encryption type keeps showing zero

Recommended Posts

Hi @@electrotwelve

 

I suggest looking in Wifi.cpp and WiFi.h of the CC3200 libraries folder in your version of Energia - the code is pretty clear as to what is happening.  I don't use the CC3200 at the moment so can't comment a whole lot more... Note that it is an adaptation of the Arduino code and you might a search there as well.

Share this post


Link to post
Share on other sites

Hi @@Fmilburn,

 

I think I've got this working for now. There seem to be two variants for the encrytionType function and the default Energia example is calling the one which does not accept arguments:

uint8_t WiFiClass::encryptionType()
{
    return 0;
}
I changed the return value to verify this and it is indeed this one that is being called. The other variant accepts an integer value as an argument presumably the SSID number. I borrowed code sections from the ScanNetworks example. I compared the string returned by WiFi.encryptionType with the defined SSID and when they matched I printed out the encryption type. 
int numSsid = WiFi.scanNetworks();

if (numSsid == -1)
{
  Serial.println("Couldn't get a wifi connection");
  while (true);
}

for (int thisNet = 0; thisNet < numSsid; thisNet++) {
  if (strcmp(WiFi.SSID(thisNet),ssid) == 0) {
    Serial.print("Encryption: ");
    printEncryptionType(WiFi.encryptionType(thisNet));
  }
}

The printEncryptionType function is the same one from ScanNetworks example.

Share this post


Link to post
Share on other sites

There seem to be two variants for the encrytionType function...

 

 

Correct, 

uint8_t WiFiClass::encryptionType()

and 

uint8_t WiFiClass::encryptionType(uint8_t networkItem)

Two functions, with the same name, but different parameters. This is called Function Overloading. 

 

Your compiler determines the best fit for which function definition to process based on the types you give to said function.

 

For more information, see here: http://www.tutorialspoint.com/cplusplus/cpp_overloading.htm

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×