File tree Expand file tree Collapse file tree 1 file changed +23
-2
lines changed Expand file tree Collapse file tree 1 file changed +23
-2
lines changed Original file line number Diff line number Diff line change 11#include " WiFi.h"
22
3+ #define SSID_MAX_COUNT 12
4+
35using namespace std ;
46
57/* -------------------------------------------------------------------------- */
@@ -265,7 +267,7 @@ int8_t CWifi::scanNetworks() {
265267
266268 vector<string> aps;
267269 if (modem.write (string (PROMPT (_WIFISCAN)),res,CMD (_WIFISCAN))) {
268-
270+
269271 split (aps, res, string (" \r\n " ));
270272 for (uint16_t i = 0 ; i < aps.size (); i++) {
271273 CAccessPoint ap;
@@ -278,7 +280,26 @@ int8_t CWifi::scanNetworks() {
278280 ap.rssi = tokens[2 ];
279281 ap.channel = tokens[3 ];
280282 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+ }
282303 }
283304 }
284305 }
You can’t perform that action at this time.
0 commit comments