Skip to content

Commit

Permalink
update examples WifiPing, ScanNetworks
Browse files Browse the repository at this point in the history
  • Loading branch information
hasenradball committed Dec 12, 2023
1 parent 2a3383e commit 8fea688
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 23 deletions.
63 changes: 40 additions & 23 deletions examples/ScanNetworks/ScanNetworks.ino
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
/*
This example prints the board's MAC address, and
scans for available WiFi networks using the NINA module.
Every ten seconds, it scans again. It doesn't actually
connect to any network, so no encryption scheme is specified.
Circuit:
* Board with NINA module (Arduino MKR WiFi 1010, MKR VIDOR 4000 and Uno WiFi Rev.2)
created 13 July 2010
by dlf (Metodo2 srl)
modified 21 Junn 2012
by Tom Igoe and Jaymes Dec
This example prints the board's MAC address, and
scans for available WiFi networks using the NINA module.
Every ten seconds, it scans again. It doesn't actually
connect to any network, so no encryption scheme is specified.
Circuit:
* Board with NINA module (Arduino MKR WiFi 1010, MKR VIDOR 4000 and Uno WiFi Rev.2)
created 13 July 2010
by dlf (Metodo2 srl)
modified 12 December 2023
by Frank Häfele
*/


Expand Down Expand Up @@ -45,34 +45,51 @@ void setup() {

void loop() {
// scan for existing networks:
Serial.println("Scanning available networks...");
Serial.println("\nScanning available networks...");
listNetworks();
delay(10000);
delay(25000);
}

void listNetworks() {
// scan for nearby networks:
Serial.println("** Scan Networks **");
Serial.println("\n** Scan Networks **");
int numSsid = WiFi.scanNetworks();
if (numSsid == -1) {
Serial.println("Couldn't get a WiFi connection");
while (true);
}

// print the list of networks seen:
Serial.print("number of available networks:");
Serial.print("number of available networks: ");
Serial.println(numSsid);

Serial.print("\tSSID");
Serial.print(" Signal");
Serial.print(" Channel");
Serial.println(" Encryption");


// print the network number and name for each network found:
for (int thisNet = 0; thisNet < numSsid; thisNet++) {
Serial.print(thisNet);
Serial.print(") ");
Serial.print(WiFi.SSID(thisNet));
Serial.print("\tSignal: ");
for (int thisNet = 0; thisNet < numSsid; ++thisNet) {
Serial.print(thisNet + 1);
Serial.print(")\t");

String str = WiFi.SSID(thisNet);
size_t len = str.length();
Serial.print(str);

for(size_t i = 32U - len; i > 0; --i) {
Serial.print(" ");
}
Serial.print(WiFi.RSSI(thisNet));
Serial.print(" dBm");
Serial.print("\tEncryption: ");
Serial.print(" dBm\t ");

Serial.print(WiFi.channel(thisNet));
Serial.print("\t ");

printEncryptionType(WiFi.encryptionType(thisNet));

Serial.flush();
}
}

Expand Down
1 change: 1 addition & 0 deletions examples/WiFiPing/WiFiPing.ino
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ void setup() {
Serial.println("\nYou're connected to the network");
printCurrentNet();
printWiFiData();
Serial.println();
}

void loop() {
Expand Down

0 comments on commit 8fea688

Please sign in to comment.