Skip to content

Commit 156c102

Browse files
committed
Updated ScanNetworks example to give network encryption types by name
1 parent 056895d commit 156c102

File tree

1 file changed

+26
-5
lines changed

1 file changed

+26
-5
lines changed

WiFi/examples/ScanNetworks/ScanNetworks.ino

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
1111
created 13 July 2010
1212
by dlf (Metodo2 srl)
13-
modified 31 May 2012
14-
by Tom Igoe
13+
modified 21 Junn 2012
14+
by Tom Igoe and Jaymes Dec
1515
*/
1616

1717

@@ -24,14 +24,14 @@ void setup() {
2424
while (!Serial) {
2525
; // wait for serial port to connect. Needed for Leonardo only
2626
}
27-
27+
2828
// check for the presence of the shield:
2929
if (WiFi.status() == WL_NO_SHIELD) {
3030
Serial.println("WiFi shield not present");
3131
// don't continue:
3232
while(true);
3333
}
34-
34+
3535
// Print WiFi MAC address:
3636
printMacAddress();
3737

@@ -90,9 +90,30 @@ void listNetworks() {
9090
Serial.print(WiFi.RSSI(thisNet));
9191
Serial.print(" dBm");
9292
Serial.print("\tEncryption: ");
93-
Serial.println(WiFi.encryptionType(thisNet));
93+
printEncryptionType(WiFi.encryptionType(thisNet));
9494
}
9595
}
9696

97+
void printEncryptionType(int thisType) {
98+
// read the encryption type and print out the name:
99+
switch (thisType) {
100+
case ENC_TYPE_WEP:
101+
Serial.println("WEP");
102+
break;
103+
case ENC_TYPE_TKIP:
104+
Serial.println("WPA");
105+
break;
106+
case ENC_TYPE_CCMP:
107+
Serial.println("WPA2");
108+
break;
109+
case ENC_TYPE_NONE:
110+
Serial.println("None");
111+
break;
112+
case ENC_TYPE_AUTO:
113+
Serial.println("Auto");
114+
break;
115+
}
116+
}
117+
97118

98119

0 commit comments

Comments
 (0)