@@ -181,7 +181,7 @@ void APScan::sendResults(){
181
181
182
182
}
183
183
184
- String APScan::getResults (){
184
+ String APScan::getResultsJSON (){
185
185
if (debug) Serial.print (" getting AP scan result JSON " );
186
186
String json = " { \" aps\" :[ " ;
187
187
for (int i=0 ;i<results && i<maxAPScanResults;i++){
@@ -206,26 +206,42 @@ String APScan::getResults(){
206
206
return json;
207
207
}
208
208
209
- String APScan::getResult (int i){
210
- if (debug) Serial.print (" getting AP scan result JSON for ID " + String (i));
211
- String json = " { \" aps\" :[ " ;
212
- if (debug) Serial.print (" ." );
213
- json += " {" ;
214
- json += " \" i\" :" +(String)i+" ," ;
215
- json += " \" c\" :" +(String)getAPChannel (i)+" ," ;
216
- json += " \" m\" :\" " +getAPMac (i)+" \" ," ;
217
- json += " \" ss\" :\" " +getAPName (i)+" \" ," ;
218
- json += " \" r\" :" +(String)getAPRSSI (i)+" ," ;
219
- json += " \" e\" :" +(String)encryption[i]+" ," ;
220
- // json += "\"v\":\""+getAPVendor(i)+"\",";
221
- json += " \" se\" :" +(String)getAPSelected (i);
222
- json += " }" ;
223
- json += " ] }" ;
224
- if (debug){
225
- Serial.println (json);
226
- Serial.println (" done" );
209
+ void APScan::sort (){
210
+ if (debug) Serial.println (" sorting APs " );
211
+
212
+ // bubble sort
213
+ for (int i=0 ;i<results-1 ;i++){
214
+ Serial.println (" --------------" );
215
+ for (int h=0 ;h<results-i-1 ;h++){
216
+
217
+ if (rssi[h] < rssi[h+1 ]){
218
+ Serial.println (" switched: " +(String)rssi[h]+" > " +(String)rssi[h+1 ]);
219
+ int tmpA = channels[h];
220
+ channels[h] = channels[h+1 ];
221
+ channels[h+1 ] = tmpA;
222
+
223
+ tmpA = rssi[h];
224
+ rssi[h] = rssi[h+1 ];
225
+ rssi[h+1 ] = tmpA;
226
+
227
+ tmpA = encryption[h];
228
+ encryption[h] = encryption[h+1 ];
229
+ encryption[h+1 ] = tmpA;
230
+
231
+ String tmpB = names[h];
232
+ strncpy (names[h],names[h+1 ],32 );
233
+ tmpB.toCharArray (names[h+1 ],32 );
234
+
235
+ bool tmpC = hidden[h];
236
+ hidden[h] = hidden[h+1 ];
237
+ hidden[h+1 ] = tmpC;
238
+
239
+ tmpC = selected[h];
240
+ selected[h] = selected[h+1 ];
241
+ selected[h+1 ] = tmpC;
242
+ }else Serial.println ((String)rssi[h]+" < " +(String)rssi[h+1 ]);
243
+ }
227
244
}
228
- return json;
229
245
}
230
246
231
247
void APScan::select (int num){
0 commit comments