mirror of
https://github.com/arduino/Arduino.git
synced 2024-12-10 21:24:12 +01:00
updated ScanNetworks to include RSSI and encryption (really this time!)
This commit is contained in:
parent
1236c15e09
commit
1d7d421cef
@ -24,19 +24,19 @@ void setup() {
|
|||||||
|
|
||||||
// attempt to connect using WEP encryption:
|
// attempt to connect using WEP encryption:
|
||||||
Serial.println("Initializing Wifi...");
|
Serial.println("Initializing Wifi...");
|
||||||
//WiFi.begin("no network");
|
|
||||||
printMacAddress();
|
printMacAddress();
|
||||||
|
|
||||||
|
|
||||||
// scan for existing networks:
|
// scan for existing networks:
|
||||||
Serial.println("Scanning available networks...");
|
Serial.println("Scanning available networks...");
|
||||||
scanNetworks();
|
listNetworks();
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
delay(10000);
|
delay(10000);
|
||||||
// scan for existing networks:
|
// scan for existing networks:
|
||||||
Serial.println("Scanning available networks...");
|
Serial.println("Scanning available networks...");
|
||||||
scanNetworks();
|
listNetworks();
|
||||||
}
|
}
|
||||||
|
|
||||||
void printMacAddress() {
|
void printMacAddress() {
|
||||||
@ -59,19 +59,20 @@ void printMacAddress() {
|
|||||||
Serial.println(mac[0],HEX);
|
Serial.println(mac[0],HEX);
|
||||||
}
|
}
|
||||||
|
|
||||||
void scanNetworks() {
|
void listNetworks() {
|
||||||
// scan for nearby networks:
|
// scan for nearby networks:
|
||||||
Serial.println("** Scan Networks **");
|
Serial.println("** Scan Networks **");
|
||||||
byte numSsid = WiFi.scanNetworks();
|
byte numSsid = WiFi.scanNetworks();
|
||||||
|
|
||||||
// print the list of networks seen:
|
// print the list of networks seen:
|
||||||
Serial.print("SSID List:");
|
Serial.print("number of available networks:");
|
||||||
Serial.println(numSsid);
|
Serial.println(numSsid);
|
||||||
Serial.println("#\tNetwork:\tRSSI:\tEncryption:");
|
|
||||||
|
Serial.println("#\tName\tRSSI\tencryptionType:");
|
||||||
// print the network number and name for each network found:
|
// print the network number and name for each network found:
|
||||||
for (int thisNet = 0; thisNet<numSsid; thisNet++) {
|
for (int thisNet = 0; thisNet<numSsid; thisNet++) {
|
||||||
Serial.print(thisNet);
|
Serial.print(thisNet);
|
||||||
Serial.print(")\t");
|
Serial.print("\t");
|
||||||
Serial.print(WiFi.SSID(thisNet));
|
Serial.print(WiFi.SSID(thisNet));
|
||||||
Serial.print("\t");
|
Serial.print("\t");
|
||||||
Serial.print(WiFi.RSSI(thisNet));
|
Serial.print(WiFi.RSSI(thisNet));
|
||||||
|
Loading…
Reference in New Issue
Block a user