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
Fusion2016/code/frank/WiFiSensorReader.h

47 lines
916 B
C++
Executable File

#ifndef WIFISENSORREADER_H
#define WIFISENSORREADER_H
#include "../reader/SensorReader.h"
#include "WiFiObservation.h"
#include <cassert>
class WiFiSensorReader {
public:
/** get wifi observation data from one CSV entry */
static WiFiObservation readWifi(const SensorEntry& se) {
std::string tmp = se.data;
WiFiObservation obs;
// process all APs
while(!tmp.empty()) {
std::string mac = tmp.substr(0, 17);
tmp = tmp.substr(17);
assert(tmp[0] == ';'); tmp = tmp.substr(1);
std::string freq = tmp.substr(0, 4);
tmp = tmp.substr(4);
assert(tmp[0] == ';'); tmp = tmp.substr(1);
int pos = tmp.find(';');
std::string rssi = tmp.substr(0, pos);
tmp = tmp.substr(pos);
assert(tmp[0] == ';'); tmp = tmp.substr(1);
WiFiObservationEntry e(se.ts, mac, std::stoi(freq), std::stoi(rssi));
obs.entries.push_back(e);
}
return obs;
}
};
#endif // WIFISENSORREADER_H