Created
November 13, 2018 20:45
-
-
Save nlharri/b18284d75608b077cca9237d67267d0e to your computer and use it in GitHub Desktop.
WiFiScannerLinux - main.cpp - wifiScannerThread
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void wifiScannerThread(std::future<void> futureObj, std::string WifiIfName, WifiAPCollection *wifiAPCollection) { | |
int maxNumberOfAPs = 6; // maximal number of APs scanned | |
int refreshTimeInMillis = 3000; // scan frequency | |
while (futureObj.wait_for(std::chrono::milliseconds(1)) == std::future_status::timeout) { | |
std::this_thread::sleep_for(std::chrono::milliseconds(refreshTimeInMillis)); | |
int status, i; | |
struct bss_info bss[maxNumberOfAPs]; | |
struct wifi_scan *wifi = wifi_scan_init(WifiIfName.c_str()); | |
status=wifi_scan_all(wifi, bss, maxNumberOfAPs); | |
std::vector<WifiAP> APs; | |
for (i=0;i<status && i<maxNumberOfAPs;++i) | |
APs.push_back(WifiAP(bss[i].ssid, bss[i].signal_mbm/100)); | |
mu.lock(); | |
wifiAPCollection->addAPs(APs); | |
mu.unlock(); | |
wifi_scan_close(wifi); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment