This repository has been archived on 2020-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
Files
YASMIN/sensors/android/WiFiSensorAndroid.h
kazu 075d8bb633 a lot!!! of changes
added main menu
added debug display
many debug widgets for plotting live data
worked on android live sensors
added offline-data sensor feeding
some dummy data sensors
worked on the map display
added ui debug for grid-points, particles and weights
added a cool dude to display the estimation
added real filtering based on the Indoor components
c++11 fixes for android compilation
online and offline filtering support
new resampling technique for testing
map loading via dialog
2016-09-16 19:30:04 +02:00

68 lines
1.3 KiB
C++

#ifndef WIFISENSORANDROID_H
#define WIFISENSORANDROID_H
#ifdef ANDROID
#include <QAndroidJniObject>
#include "../../misc/Debug.h"
#include "../WiFiSensor.h"
class WiFiSensorAndroid : public WiFiSensor {
private:
/** hidden ctor. use singleton! */
WiFiSensorAndroid() {;}
public:
/** singleton access */
static WiFiSensorAndroid& get() {
static WiFiSensorAndroid wifi;
return wifi;
}
void start() override {
// start scanning
int res = QAndroidJniObject::callStaticMethod<int>("indoor/java/WiFi", "start", "()I");
(void) res;
}
void stop() override {
throw "todo";
}
/** called from java. handle the given incoming scan result */
void handle(const std::string& data) {
// to-be-constructed sensor data
WiFiMeasurements sensorData;
// parse each mac->rssi entry
for (int i = 0; i < (int)data.length(); i += 17+1+2) {
const std::string bssid = data.substr(i, 17);
const int8_t rssi = data[i+17];
const int8_t pad1 = data[i+18];
const int8_t pad2 = data[i+19];
if (pad1 != 0 || pad2 != 0) {Debug::error("padding error within WiFi scan result");}
sensorData.entries.push_back(WiFiMeasurement(AccessPoint(bssid), rssi));
}
// call listeners
informListeners(sensorData);
}
};
#endif
#endif // WIFISENSORANDROID_H