@@ -10,6 +10,20 @@ namespace Eloquent {
1010 class WifiScanner {
1111 public:
1212
13+ /* *
14+ * Identify networks by SSID
15+ */
16+ void identifyBySSID () {
17+ useMac = false ;
18+ }
19+
20+ /* *
21+ * Identify networks by MAC address
22+ */
23+ void identifyByMAC () {
24+ useMac = true ;
25+ }
26+
1327 /* *
1428 * Perform scan
1529 */
@@ -41,7 +55,7 @@ namespace Eloquent {
4155 }
4256
4357 /* *
44- * Get SID of current network
58+ * Get SSID of current network
4559 * @return
4660 */
4761 String ssid () {
@@ -60,6 +74,26 @@ namespace Eloquent {
6074 return WiFi.SSID (i);
6175 }
6276
77+ /* *
78+ * Get MAC address of current network
79+ * @return
80+ */
81+ String mac () {
82+ if (hasNext ())
83+ return macAt (i);
84+
85+ return " " ;
86+ }
87+
88+ /* *
89+ * Get Mac address of given network
90+ * @param i
91+ * @return
92+ */
93+ String macAt (uint8_t i) {
94+ return WiFi.BSSIDstr (i);
95+ }
96+
6397 /* *
6498 * Get RSSI of current network
6599 * @return
@@ -80,6 +114,15 @@ namespace Eloquent {
80114 return WiFi.RSSI (i);
81115 }
82116
117+ /* *
118+ * Get identifier of given network
119+ * @param i
120+ * @return
121+ */
122+ String idAt (uint8_t i) {
123+ return useMac ? macAt (i) : ssidAt (i);
124+ }
125+
83126 /* *
84127 * Print scan results as JSON
85128 * @tparam Stream
@@ -91,7 +134,7 @@ namespace Eloquent {
91134
92135 for (uint8_t i = 0 ; i < numNetworks; i++) {
93136 stream.print (' "' );
94- stream.print (ssidAt (i));
137+ stream.print (idAt (i));
95138 stream.print (' "' );
96139 stream.print (' :' );
97140 stream.print (rssiAt (i));
@@ -107,6 +150,7 @@ namespace Eloquent {
107150 protected:
108151 uint8_t i = 0 ;
109152 uint8_t numNetworks;
153+ bool useMac = false ;
110154 };
111155 }
112156 }
0 commit comments