#ifndef BEACONSENSORREADER_H
#define BEACONSENSORREADER_H

#include "../reader/SensorReader.h"
#include "BeaconObservation.h"
#include "Settings.h"
#include <cassert>

class BeaconSensorReader {

public:

//	/** get wifi observation data from one CSV entry */
//	static BeaconObservation* readBeacons(const SensorEntry& se) {

//		std::string tmp = se.data;
//		BeaconObservation* obs = new BeaconObservation();
//		obs->ts = se.ts;

//		std::string mac = tmp.substr(0, 17);
//		tmp = tmp.substr(17);
//		assert(tmp[0] == ';');	tmp = tmp.substr(1);

//		std::string rssi = tmp;

//		BeaconObservationEntry e(mac, std::stoi(rssi));
//		obs->entries.push_back(e);

//		/** skip unknown beacons */
//		if (settings.getBeacon(mac) == nullptr) {return nullptr;}

//		return obs;

//	}

	/** get wifi observation data from one CSV entry */
	static BeaconObservationEntry getBeacon(const SensorEntry& se) {

		BeaconObservationEntry boe;
		std::string tmp = se.data;

		std::string mac = tmp.substr(0, 17);
		tmp = tmp.substr(17);
		assert(tmp[0] == ';');	tmp = tmp.substr(1);

		std::string rssi = tmp;

		BeaconObservationEntry e(se.ts, mac, std::stoi(rssi));

		/** skip unknown beacons */
		if (settings.getBeacon(mac) == nullptr) {return BeaconObservationEntry();}

		return e;

	}

};


#endif // BEACONSENSORREADER_H
