worked on wifi-scanner for linux

new time-grouping for vap grouper
adjusted test-cases
minor changes/fixes/improvements
This commit is contained in:
2017-10-11 14:00:24 +02:00
parent 628be72e1f
commit da477866c1
13 changed files with 649 additions and 223 deletions

View File

@@ -11,10 +11,74 @@ class Test : public GridPoint {
#include "tests/Tests.h"
#include "sensors/radio/scan/WiFiScanLinux.h"
#include "sensors/radio/VAPGrouper.h"
#include <KLib/misc/gnuplot/Gnuplot.h>
#include <KLib/misc/gnuplot/GnuplotPlot.h>
#include <KLib/misc/gnuplot/GnuplotPlotElementLines.h>
#include <KLib/misc/gnuplot/GnuplotPlotElementPoints.h>
void wifi() {
const std::string dev = "wlp0s20u2u1";
K::Gnuplot gp;
K::GnuplotPlot plot;
std::vector<K::GnuplotPlotElementLines> lines; lines.resize(5);
std::vector<K::GnuplotPlotElementPoints> points; points.resize(5);
for (int i = 0; i < points.size(); ++i) {
plot.add(&points[i]);
plot.add(&lines[i]);
points[i].setPointSize(1);
points[i].setPointType(7);
lines[i].getStroke().setWidth(2);
}
points[0].getColor().setHexStr("#ff6666"); lines[0].getStroke().getColor().setHexStr("#ff0000");
points[1].getColor().setHexStr("#cccc66"); lines[1].getStroke().getColor().setHexStr("#cccc00");
points[2].getColor().setHexStr("#66cccc"); lines[2].getStroke().getColor().setHexStr("#00cccc");
points[3].getColor().setHexStr("#6666ff"); lines[3].getStroke().getColor().setHexStr("#0000ff");
points[4].getColor().setHexStr("#cc66cc"); lines[4].getStroke().getColor().setHexStr("#cc00cc");
VAPGrouper vap(VAPGrouper::Mode::LAST_MAC_DIGIT_TO_ZERO, VAPGrouper::Aggregation::MEDIAN, VAPGrouper::TimeAggregation::AVERAGE, 1);
const std::string dev = "wlp0s20u2u4";
WiFiScanLinux scanner(dev);
scanner.scan();
Timestamp start = Timestamp::fromUnixTime();
for (int i = 0; i < 500; ++i) {
WiFiMeasurements mes = scanner.scan();
for (const WiFiMeasurement& m : mes.entries) {
K::GnuplotPoint2 gp((m.getTimestamp()-start).ms(), m.getRSSI());
std::string mac = m.getAP().getMAC().asString().substr(0,14);
if (mac == "5C:CF:7F:C3:F9") {points[0].add(gp);}
if (mac == "18:FE:34:E1:2B") {points[1].add(gp);}
if (mac == "60:01:94:03:16") {points[2].add(gp);}
}
WiFiMeasurements mes2 = vap.group(mes);
for (const WiFiMeasurement& m : mes2.entries) {
K::GnuplotPoint2 gp((m.getTimestamp()-start).ms(), m.getRSSI());
std::string mac = m.getAP().getMAC().asString().substr(0,14);
if (mac == "5C:CF:7F:C3:F9") {lines[0].add(gp);}
if (mac == "18:FE:34:E1:2B") {lines[1].add(gp);}
if (mac == "60:01:94:03:16") {lines[2].add(gp);}
}
gp.draw(plot);
gp.flush();
}
}
int main(int argc, char** argv) {
@@ -45,7 +109,9 @@ int main(int argc, char** argv) {
//::testing::GTEST_FLAG(filter) = "*Matrix4*";
//::testing::GTEST_FLAG(filter) = "*Sphere3*";
::testing::GTEST_FLAG(filter) = "Geo_*";
::testing::GTEST_FLAG(filter) = "WiFiVAPGrouper*";
//::testing::GTEST_FLAG(filter) = "Timestamp*";
//::testing::GTEST_FLAG(filter) = "*RayTrace3*";
//::testing::GTEST_FLAG(filter) = "*BVH*";