started to add ble functions
added ble as sensor to java and c++ added sensorlistener for ble added ble to observation and onDataSensor in filter started to work on ble fingerprints for optimization
This commit is contained in:
4
tools/calibration/BLECalibrationDataModel.h
Normal file
4
tools/calibration/BLECalibrationDataModel.h
Normal file
@@ -0,0 +1,4 @@
|
||||
#ifndef BLECALIBRATIONDATAMODEL_H
|
||||
#define BLECALIBRATIONDATAMODEL_H
|
||||
|
||||
#endif // BLECALIBRATIONDATAMODEL_H
|
||||
@@ -16,84 +16,94 @@
|
||||
/**
|
||||
* show a dialog to perform a WiFiScan
|
||||
*/
|
||||
class WiFiCalibrationScanDialog : public QObject, public SensorListener<WiFiMeasurements> {
|
||||
class WiFiCalibrationScanDialog : public QObject, public SensorListener<WiFiMeasurements>, public SensorListener<BeaconMeasurement> {
|
||||
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
private:
|
||||
|
||||
QDialog* dlg = new QDialog();
|
||||
QLabel* lblStats;
|
||||
QLabel* lblPoint;
|
||||
QProgressBar* barProg;
|
||||
QDialog* dlg = new QDialog();
|
||||
QLabel* lblStats;
|
||||
QLabel* lblPoint;
|
||||
QProgressBar* barProg;
|
||||
|
||||
struct Scan {
|
||||
const int numRecords = 30;
|
||||
int recordsDone = 0;
|
||||
} scan;
|
||||
struct Scan {
|
||||
const int numRecords = 30;
|
||||
int recordsDone = 0;
|
||||
} scan;
|
||||
|
||||
/** the measurements model to fill with scan-entries */
|
||||
WiFiFingerprint& model;
|
||||
/** the measurements model to fill with scan-entries */
|
||||
WiFiFingerprint& model;
|
||||
//BeaconFingerprint& blemodel;
|
||||
|
||||
public:
|
||||
|
||||
static void get(WiFiFingerprint& model) {
|
||||
WiFiCalibrationScanDialog dlg(model);
|
||||
dlg.show();
|
||||
}
|
||||
static void get(WiFiFingerprint& model) {
|
||||
WiFiCalibrationScanDialog dlg(model);
|
||||
dlg.show();
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
/** ctor */
|
||||
WiFiCalibrationScanDialog(WiFiFingerprint& model);
|
||||
/** ctor */
|
||||
WiFiCalibrationScanDialog(WiFiFingerprint& model);
|
||||
|
||||
void show() {
|
||||
refresh();
|
||||
dlg->exec();
|
||||
}
|
||||
void show() {
|
||||
refresh();
|
||||
dlg->exec();
|
||||
}
|
||||
|
||||
void close() {
|
||||
stopRecord();
|
||||
dlg->close();
|
||||
}
|
||||
void close() {
|
||||
stopRecord();
|
||||
dlg->close();
|
||||
}
|
||||
|
||||
void save() {
|
||||
//mdl.save();;
|
||||
}
|
||||
void save() {
|
||||
//mdl.save();;
|
||||
}
|
||||
|
||||
Q_INVOKABLE void refresh() {
|
||||
lblPoint->setText(QString(model.pos_m.asString().c_str()));
|
||||
lblStats->setText( QString::number(model.measurements.entries.size()) + " RSSI measurements\n" + QString::number(scan.recordsDone) + " scans");
|
||||
barProg->setValue(scan.recordsDone);
|
||||
barProg->setMaximum(scan.numRecords);
|
||||
}
|
||||
Q_INVOKABLE void refresh() {
|
||||
lblPoint->setText(QString(model.pos_m.asString().c_str()));
|
||||
lblStats->setText( QString::number(model.measurements.entries.size()) + " RSSI measurements\n" + QString::number(scan.recordsDone) + " scans");
|
||||
barProg->setValue(scan.recordsDone);
|
||||
barProg->setMaximum(scan.numRecords);
|
||||
}
|
||||
|
||||
void clear() {
|
||||
model.measurements.entries.clear();
|
||||
refresh();
|
||||
}
|
||||
void clear() {
|
||||
model.measurements.entries.clear();
|
||||
refresh();
|
||||
}
|
||||
|
||||
|
||||
void startRecord() {
|
||||
scan.recordsDone = 0;
|
||||
SensorFactory::get().getWiFi().addListener(this);
|
||||
if (!SensorFactory::get().getWiFi().isRunning()) {
|
||||
SensorFactory::get().getWiFi().start();
|
||||
}
|
||||
}
|
||||
void startRecord() {
|
||||
scan.recordsDone = 0;
|
||||
SensorFactory::get().getWiFi().addListener(this);
|
||||
if (!SensorFactory::get().getWiFi().isRunning()) {
|
||||
SensorFactory::get().getWiFi().start();
|
||||
}
|
||||
}
|
||||
|
||||
void stopRecord() {
|
||||
SensorFactory::get().getWiFi().removeListener(this);
|
||||
}
|
||||
void stopRecord() {
|
||||
SensorFactory::get().getWiFi().removeListener(this);
|
||||
}
|
||||
|
||||
virtual void onSensorData(Sensor<WiFiMeasurements>* sensor, const Timestamp ts, const WiFiMeasurements& data) override {
|
||||
(void) sensor;
|
||||
(void) ts;
|
||||
++scan.recordsDone;
|
||||
if (scan.recordsDone >= scan.numRecords) {stopRecord();}
|
||||
model.measurements.entries.insert(model.measurements.entries.end(), data.entries.begin(), data.entries.end());
|
||||
QMetaObject::invokeMethod(this, "refresh", Qt::QueuedConnection);
|
||||
}
|
||||
virtual void onSensorData(Sensor<WiFiMeasurements>* sensor, const Timestamp ts, const WiFiMeasurements& data) override {
|
||||
(void) sensor;
|
||||
(void) ts;
|
||||
++scan.recordsDone;
|
||||
if (scan.recordsDone >= scan.numRecords) {stopRecord();}
|
||||
model.measurements.entries.insert(model.measurements.entries.end(), data.entries.begin(), data.entries.end());
|
||||
QMetaObject::invokeMethod(this, "refresh", Qt::QueuedConnection);
|
||||
}
|
||||
|
||||
//tmp stuff
|
||||
virtual void onSensorData(Sensor<BeaconMeasurement>* sensor, const Timestamp ts, const BeaconMeasurement& data) override {
|
||||
(void) sensor;
|
||||
(void) ts;
|
||||
|
||||
|
||||
QMetaObject::invokeMethod(this, "refresh", Qt::QueuedConnection);
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user