-
Notifications
You must be signed in to change notification settings - Fork 59
/
WiFiScannerExample.ino
46 lines (37 loc) · 1.12 KB
/
WiFiScannerExample.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/**
* WiFi scanner example
* Print WiFi hotspots with their RSSI in Json format
*
* Enter the name of the location to start scanning
* Enter 'stop' to stop the scanning
*/
// replace with WiFiNINA.h if you use a different board
#include "WiFi.h"
#include "eloquent.h"
#include "eloquent/networking/wifi/WifiScanner.h"
String location;
void setup() {
Serial.begin(115200);
delay(2000);
Serial.println("Instructions:");
Serial.println("\tEnter the name of the location to start scanning");
Serial.println("\tEnter 'stop' to stop scanning");
// you can identify networks either by MAC address
wifiScanner.identifyByMAC();
// or SSID (default)
wifiScanner.identifyBySSID();
}
void loop() {
// await user to input his current location or "stop" to abort scanning
if (Serial.available()) {
location = Serial.readStringUntil('\n');
}
// if a location is set, perform scan
if (location != "" && location != "stop") {
Serial.print(location);
Serial.print(": ");
wifiScanner.scan();
wifiScanner.printAsJson(Serial);
delay(2000);
}
}