From 156c102c0debaa42cdff60d115bbff76e448f4f3 Mon Sep 17 00:00:00 2001 From: Tom Igoe Date: Thu, 21 Jun 2012 22:04:31 -0400 Subject: [PATCH] Updated ScanNetworks example to give network encryption types by name --- WiFi/examples/ScanNetworks/ScanNetworks.ino | 31 +++++++++++++++++---- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/WiFi/examples/ScanNetworks/ScanNetworks.ino b/WiFi/examples/ScanNetworks/ScanNetworks.ino index 829e25409..93b30006e 100644 --- a/WiFi/examples/ScanNetworks/ScanNetworks.ino +++ b/WiFi/examples/ScanNetworks/ScanNetworks.ino @@ -10,8 +10,8 @@ created 13 July 2010 by dlf (Metodo2 srl) - modified 31 May 2012 - by Tom Igoe + modified 21 Junn 2012 + by Tom Igoe and Jaymes Dec */ @@ -24,14 +24,14 @@ void setup() { while (!Serial) { ; // wait for serial port to connect. Needed for Leonardo only } - + // check for the presence of the shield: if (WiFi.status() == WL_NO_SHIELD) { Serial.println("WiFi shield not present"); // don't continue: while(true); } - + // Print WiFi MAC address: printMacAddress(); @@ -90,9 +90,30 @@ void listNetworks() { Serial.print(WiFi.RSSI(thisNet)); Serial.print(" dBm"); Serial.print("\tEncryption: "); - Serial.println(WiFi.encryptionType(thisNet)); + printEncryptionType(WiFi.encryptionType(thisNet)); } } +void printEncryptionType(int thisType) { + // read the encryption type and print out the name: + switch (thisType) { + case ENC_TYPE_WEP: + Serial.println("WEP"); + break; + case ENC_TYPE_TKIP: + Serial.println("WPA"); + break; + case ENC_TYPE_CCMP: + Serial.println("WPA2"); + break; + case ENC_TYPE_NONE: + Serial.println("None"); + break; + case ENC_TYPE_AUTO: + Serial.println("Auto"); + break; + } +} +