[my-place][wifi_logger] Extend last scans pool expand by network name. 03/72303/1
authorMarcin Masternak <m.masternak@samsung.com>
Tue, 31 May 2016 10:10:18 +0000 (12:10 +0200)
committerMarcin Masternak <m.masternak@samsung.com>
Tue, 31 May 2016 10:24:22 +0000 (12:24 +0200)
Change-Id: Ic4308dabdcf224676e9474f2d238f083f7d5aa29
Signed-off-by: Marcin Masternak <m.masternak@samsung.com>
src/my-place/user_places/visit_detector.cpp
src/my-place/user_places/wifi_logger.cpp
src/my-place/user_places/wifi_logger.h

index f10fed6..39c2f75 100644 (file)
@@ -95,7 +95,11 @@ bool ctx::VisitDetector::__isValid(const ctx::Mac &mac)
 
 void ctx::VisitDetector::onWifiScan(ctx::MacEvent e)
 {
-       _D("timestamp=%d, curent_interval.end=%d, mac=%s", e.timestamp, __currentInterval.end, std::string(e.mac).c_str());
+       _D("timestamp=%d, current_interval.end=%d, mac=%s, network=%s",
+                       e.timestamp,
+                       __currentInterval.end,
+                       std::string(e.mac).c_str(),
+                       e.networkName.c_str());
        if (__isValid(e.mac)) {
                while (e.timestamp > __currentInterval.end) {
                        __processCurrentLogger();
index 6260bd1..e304a49 100644 (file)
@@ -169,7 +169,7 @@ bool ctx::WifiLogger::__wifiFoundApCb(wifi_ap_h ap, void *userData)
                if (WIFI_LOGGER_LOW_POWER_MODE
                                && (wifiLogger->__connectedToWifiAp || wifiLogger->__duringVisit) ) {
                        // Add to last scans AP's set
-                       wifiLogger->__lastScansPool.insert(std::string(bssid));
+                       wifiLogger->__lastScansPool.insert(std::pair<std::string, std::string>(std::string(bssid), std::string(essid)));
                }
        }
        if (WIFI_LOGGER_DATABASE)
@@ -349,10 +349,10 @@ bool ctx::WifiLogger::onTimerExpired(int id)
                _D("trying to send fake scan");
                if (__listener) {
                        _D("__listener != false -> CORRECT");
-                       for (std::string bssid : __lastScansPool) {
-                               Mac mac(bssid);
-                               MacEvent scan(now, mac);
-                               _D("send fake scan (%s)", bssid.c_str());
+                       for (std::pair<std::string, std::string> ap : __lastScansPool) {
+                               Mac mac(ap.first);
+                               MacEvent scan(now, mac, ap.second);
+                               _D("send fake scan (%s, %s)", ap.first.c_str(), ap.second.c_str());
                                __listener->onWifiScan(scan);
                        }
                }
index 9be2000..f167a4a 100644 (file)
@@ -20,7 +20,7 @@
 #include <WifiWrapper.h>
 #include <time.h>
 #include <vector>
-#include <set>
+#include <map>
 #include <TimerManager.h>
 #include "wifi_listener_iface.h"
 #include "visit_listener_iface.h"
@@ -100,7 +100,7 @@ namespace ctx {
 
                IWifiListener * const __listener;
                std::vector<MacEvent> __logs;
-               std::set<std::string> __lastScansPool;
+               std::map<std::string, std::string> __lastScansPool; // Mac address to network name map
                time_t __lastScanTime;
                time_t __lasTimerCallbackTime;
                bool __duringVisit;