#include "grid/Grid.h" #include "grid/GridPoint.h" class Test : public GridPoint { }; #include "tests/Tests.h" #include "sensors/radio/VAPGrouper.h" #include #include #include #include #ifdef WIFI_LINUX #include "sensors/radio/scan/WiFiScanLinux.h" void wifi() { K::Gnuplot gp; K::GnuplotPlot plot; std::vector lines; lines.resize(5); std::vector 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); 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(); } } #endif int main(int argc, char** argv) { //wifi(); return 0; #ifdef WITH_TESTS ::testing::InitGoogleTest(&argc, argv); // skip all tests starting with LIVE_ //::testing::GTEST_FLAG(filter) = "*Barometer*"; //::testing::GTEST_FLAG(filter) = "*Distribution.T*"; //::testing::GTEST_FLAG(filter) = "*RingBuffer*"; //::testing::GTEST_FLAG(filter) = "*Grid.*"; ::testing::GTEST_FLAG(filter) = "*NavMeshDijkstra*"; //::testing::GTEST_FLAG(filter) = "*LogDistanceCeilingModelBeacon*"; //::testing::GTEST_FLAG(filter) = "*WiFiOptimizer*"; //::testing::GTEST_FLAG(filter) = "*Offline.readWrite*"; //::testing::GTEST_FLAG(filter) = "*Triangle*"; //::testing::GTEST_FLAG(filter) = "*Ray.ModelFac*"; //::testing::GTEST_FLAG(filter) = "*DataMap3*"; //::testing::GTEST_FLAG(filter) = "*Matrix4*"; //::testing::GTEST_FLAG(filter) = "*Sphere3*"; //::testing::GTEST_FLAG(filter) = "*Quaternion*"; //::testing::GTEST_FLAG(filter) = "Timestamp*"; //::testing::GTEST_FLAG(filter) = "*RayTrace3*"; //::testing::GTEST_FLAG(filter) = "*BVH*"; //::testing::GTEST_FLAG(filter) = "*Barometer*"; //::testing::GTEST_FLAG(filter) = "*GridWalk2RelPressure*"; //::testing::GTEST_FLAG(filter) = "Heading*"; //::testing::GTEST_FLAG(filter) = "*WiFiVAPGrouper*"; //::testing::GTEST_FLAG(filter) = "*Offline*"; //::testing::GTEST_FLAG(filter) = "*Walk*"; return RUN_ALL_TESTS(); #endif return 0; }