we are now able to record bluetooth fingerprints

for this, we use the same ui interface and fingerprint positions as wifi. if wifi has done 30 scans, also the ble
scans will be stopped. this is just a quick and dirte solution, as changing the gui completely for this two options
was to time consuming
This commit is contained in:
mail@toni-fetzer.de
2019-06-06 17:42:11 +02:00
parent 8a1f8430fb
commit ef6066ae14
9 changed files with 420 additions and 293 deletions

View File

@@ -20,91 +20,96 @@
#include "../../../sensors/SensorFactory.h"
struct WiFiCalibPoint {
std::string name; // title
Point3 pos_m; // map position + smartphone height
Point2 pos_px; // screen position
WiFiCalibPoint(const std::string& name, const Point3 pos_m, const Point2 pos_px) : name(name), pos_m(pos_m), pos_px(pos_px) {;}
WiFiCalibPoint() {;}
std::string name; // title
Point3 pos_m; // map position + smartphone height
Point2 pos_px; // screen position
WiFiCalibPoint(const std::string& name, const Point3 pos_m, const Point2 pos_px) : name(name), pos_m(pos_m), pos_px(pos_px) {;}
WiFiCalibPoint() {;}
};
/**
* helper for wifi calibration
* TODO: Make this generic for BLE and WiFI
*/
class WiFiCalibTool : public Renderable2D {
private:
WiFiCalibrationDataModel* mdl;
Floorplan::IndoorMap* map;
WiFiCalibrationDataModel* wifiMdl;
BLECalibrationDataModel* bleMdl;
std::vector<WiFiCalibPoint> currentlyVisible;
WiFiCalibPoint currentlySelected;
Floorplan::IndoorMap* map;
std::vector<WiFiCalibPoint> currentlyVisible;
WiFiCalibPoint currentlySelected;
public:
/** ctor */
WiFiCalibTool(WiFiCalibrationDataModel* mdl, Floorplan::IndoorMap* map) : mdl(mdl), map(map) {
/** ctor */
WiFiCalibTool(WiFiCalibrationDataModel* wifiMdl, BLECalibrationDataModel* bleMdl, Floorplan::IndoorMap* map) : wifiMdl(wifiMdl), bleMdl(bleMdl), map(map) {
}
}
virtual void selectNode(const int idx) {
currentlySelected = currentlyVisible[idx];
showCalib(currentlySelected);
}
virtual void selectNode(const int idx) {
currentlySelected = currentlyVisible[idx];
showCalib(currentlySelected);
}
/** get all selectable caliration nodes */
virtual std::vector<Point2> getNodes() const {
std::vector<Point2> pts;
for (const WiFiCalibPoint& cp : currentlyVisible) {pts.push_back(cp.pos_px);}
return pts;
}
/** get all selectable caliration nodes */
virtual std::vector<Point2> getNodes() const {
std::vector<Point2> pts;
for (const WiFiCalibPoint& cp : currentlyVisible) {pts.push_back(cp.pos_px);}
return pts;
}
protected:
void doRender(QPainter& qp, const Scaler2D& s, const RenderParams2D& r) override {
void doRender(QPainter& qp, const Scaler2D& s, const RenderParams2D& r) override {
currentlyVisible.clear();
const QFont font("Arial", 10);
qp.setFont(font);
currentlyVisible.clear();
const QFont font("Arial", 10);
qp.setFont(font);
// get all fingerprint-locations that are currently visible on the 2D map
for (const Floorplan::Floor* floor : map->floors) {
for (const Floorplan::FingerprintLocation* fpLoc : floor->fpLocations) {
// get all fingerprint-locations that are currently visible on the 2D map
for (const Floorplan::Floor* floor : map->floors) {
for (const Floorplan::FingerprintLocation* fpLoc : floor->fpLocations) {
//const Point3 p = beacon->pos + Point3(0,0,floor->atHeight) + Point3(0,0,Settings::smartphoneAboveGround);
const Point3 p = fpLoc->getPosition(*floor); // is already above ground as configured within the map
const Point2 pt = s.mapToScreen(p.xy());
//const Point3 p = beacon->pos + Point3(0,0,floor->atHeight) + Point3(0,0,Settings::smartphoneAboveGround);
const Point3 p = fpLoc->getPosition(*floor); // is already above ground as configured within the map
const Point2 pt = s.mapToScreen(p.xy());
if (floor->atHeight < r.clip.belowHeight_m) {continue;}
if (floor->atHeight > r.clip.aboveHeight_m) {continue;}
if (floor->atHeight < r.clip.belowHeight_m) {continue;}
if (floor->atHeight > r.clip.aboveHeight_m) {continue;}
const WiFiCalibPoint cp(fpLoc->name, p, pt);
currentlyVisible.push_back(cp);
const WiFiCalibPoint cp(fpLoc->name, p, pt);
currentlyVisible.push_back(cp);
const WiFiFingerprint& fp = mdl->getFingerprint(cp.pos_m);
const QString txt1(fpLoc->name.c_str());
const QString txt2 = QString::number(fp.measurements.entries.size());
qp.setPen(Qt::black);
const WiFiFingerprint& wfp = wifiMdl->getFingerprint(cp.pos_m);
const BeaconFingerprint& bfp = bleMdl->getFingerprint(cp.pos_m);
if (currentlySelected.name == cp.name) {
qp.setBrush(Qt::blue);
} else {
qp.setBrush(Qt::NoBrush);
}
const QString txt1(fpLoc->name.c_str());
const QString txt2 = QString::number(wfp.measurements.entries.size());
qp.setPen(Qt::black);
//FONT SIZE??
if (currentlySelected.name == cp.name) {
qp.setBrush(Qt::blue);
} else {
qp.setBrush(Qt::NoBrush);
}
//FONT SIZE??
int s = 20;
qp.drawEllipse(pt.x-s, pt.y-s, s*2, s*2);
qp.drawText(pt.x+s*2, pt.y-s, txt1);
qp.drawText(pt.x+s*2, pt.y+s, txt2);
int s = 20;
qp.drawEllipse(pt.x-s, pt.y-s, s*2, s*2);
qp.drawText(pt.x+s*2, pt.y-s, txt1);
qp.drawText(pt.x+s*2, pt.y+s, txt2);
}
}
}
}
}
}
@@ -113,18 +118,21 @@ private:
void showCalib(const WiFiCalibPoint& cp) {
void showCalib(const WiFiCalibPoint& cp) {
// get (or create an empty one) the fingerprint for this location
WiFiFingerprint& fp = mdl->getFingerprint(cp.pos_m);
// get (or create an empty one) the fingerprint for this location
WiFiFingerprint& wfp = wifiMdl->getFingerprint(cp.pos_m);
BeaconFingerprint& bfp = bleMdl->getFingerprint(cp.pos_m);
// edit it (blocking!)
WiFiCalibrationScanDialog::get(fp);
// edit it (blocking!)
WiFiCalibrationScanDialog::get(wfp, bfp);
// save the model
mdl->save();
// save the model
wifiMdl->save();
}
//save bluetooth model here!
bleMdl->save();
}
};