File tree 1 file changed +23
-2
lines changed
1 file changed +23
-2
lines changed Original file line number Diff line number Diff line change 1
1
#include " WiFi.h"
2
2
3
+ #define SSID_MAX_COUNT 12
4
+
3
5
using namespace std ;
4
6
5
7
/* -------------------------------------------------------------------------- */
@@ -265,7 +267,7 @@ int8_t CWifi::scanNetworks() {
265
267
266
268
vector<string> aps;
267
269
if (modem.write (string (PROMPT (_WIFISCAN)),res,CMD (_WIFISCAN))) {
268
-
270
+
269
271
split (aps, res, string (" \r\n " ));
270
272
for (uint16_t i = 0 ; i < aps.size (); i++) {
271
273
CAccessPoint ap;
@@ -278,7 +280,26 @@ int8_t CWifi::scanNetworks() {
278
280
ap.rssi = tokens[2 ];
279
281
ap.channel = tokens[3 ];
280
282
ap.encryption_mode = tokens[4 ];
281
- access_points.push_back (ap);
283
+
284
+ if (access_points.size () == 0 ) {
285
+ access_points.push_back (ap);
286
+ }
287
+ else {
288
+ if (RSSI (access_points.size ()-1 ) < atoi (ap.rssi .c_str ())) {
289
+ if (access_points.size () < SSID_MAX_COUNT){
290
+ std::vector<CAccessPoint>::reverse_iterator rit = access_points.rbegin ();
291
+ access_points.insert (rit.base (), ap);
292
+ }
293
+ else {
294
+ access_points.pop_back ();
295
+ access_points.push_back (ap);
296
+ }
297
+ }else {
298
+ if (access_points.size () < SSID_MAX_COUNT){
299
+ access_points.push_back (ap);
300
+ }
301
+ }
302
+ }
282
303
}
283
304
}
284
305
}
You can’t perform that action at this time.
0 commit comments