-
Notifications
You must be signed in to change notification settings - Fork 0
/
Scan_Networks.ino
59 lines (47 loc) · 1001 Bytes
/
Scan_Networks.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
47
48
49
50
51
52
53
54
55
56
57
58
#include<WiFi.h>
#include<string.h>
int r1,r2,r3,r4;
int count=0;
void setup()
{
Serial.begin(115200);
Serial1.begin(9600);
WiFi.init();
Serial.println("Welcome!");
//while(!(Serial1.available()));
//char ch=Serial1.read();
//listNetworks();
}
void loop()
{
//delay(10);
listNetworks();
if(Serial.available())
{
int ch =Serial.read();
Serial1.print(ch);
delay(500);
}
}
void listNetworks()
{
int numSsid = WiFi.scanNetworks();
for (int thisNet=0; thisNet<numSsid;thisNet++)
{
if(strlen(WiFi.SSID(thisNet))==30)
r1=WiFi.RSSI(thisNet);
else if(strlen(WiFi.SSID(thisNet))==31)
r2=WiFi.RSSI(thisNet);
else if(strlen(WiFi.SSID(thisNet))==28)
r3=WiFi.RSSI(thisNet);
else if(strlen(WiFi.SSID(thisNet))==29)
r4=WiFi.RSSI(thisNet);
}
Serial.print(r1);
Serial.print(",");
Serial.print(r2);
Serial.print(",");
Serial.print(r3);
Serial.print(",");
Serial.println(r4);
}