Kallisto Linux API
Library for interacting with Kallisto devices
rssi_sensor.hpp
Go to the documentation of this file.
1 
42 #ifndef RSSI_SENSOR_HPP
43 #define RSSI_SENSOR_HPP
44 
45 #include <string>
46 #include <vector>
47 #include <memory>
48 #include <chrono>
49 
51 #include "../sensor_impl.hpp"
52 
53 namespace kallisto {
54 namespace hardware {
55 
56 class RssiSensor : public SensorImpl {
57 private:
58  //Constants to populate the sensor data
60  static const std::string NAME;
62  static const std::string VENDOR;
64  static const std::string STRING_TYPE;
66  static const float MAX_RANGE;
68  static const float RESOLUTION;
70  static const float POWER;
72  static const std::chrono::microseconds MIN_DELAY;
74  static const std::chrono::microseconds MAX_DELAY;
75 
77  std::chrono::microseconds m_delay = std::chrono::microseconds(0);
79  InternalSensorEventListener m_listener; //Holder for the sensor callback
81  std::thread m_rssi_thread;
83  std::mutex m_rssi_mtx;
85  std::condition_variable m_rssi_cv;
86 
87 protected:
91  RssiSensor(std::string name, std::string address, std::string vendor, unsigned int version, SensorType type, std::string string_type,
92  ReportingMode reporting_mode, unsigned int identifier, float max_range, float resolution, float power, std::chrono::microseconds min_delay,
93  std::chrono::microseconds max_delay, util::Executor& event_dispatcher, bluetooth::BluetoothDispatcher& bluetooth_dispatcher);
94 
104  error::KallistoDetailedResult start(std::map<std::string, const void*> parameters, InternalSensorEventListener internal_listener);
105 
114  error::KallistoDetailedResult update(std::map<std::string, const void*> parameters);
115 
120  std::map<std::string, const void*> getParameters();
121 
128  error::KallistoDetailedResult stop(bool link_loss);
129 
133  void startWorker();
134 
135 public:
139  ~RssiSensor();
140 
144  RssiSensor(RssiSensor const&) = delete;
145 
149  void operator=(RssiSensor const&) = delete;
150 
161  static std::vector<std::unique_ptr<SensorImpl> > build(std::string address, util::Executor& event_dispatcher,
162  bluetooth::BluetoothDispatcher& bluetooth_dispatcher,
163  const std::map<uint16_t, std::vector<uint8_t> >& manufacturer_data);
164 };
165 
166 } /* namespace hardware */
167 } /* namespace kallisto */
168 
169 #endif // BATTERY_SOC_HPP
void operator=(RssiSensor const &)=delete
Definition: bluetooth_adapter.hpp:52
Class that encapsulates a result.
Definition: kallisto_error.hpp:81
error::KallistoDetailedResult start(std::map< std::string, const void *> parameters, InternalSensorEventListener internal_listener)
SensorType
Definition: sensor.hpp:60
Definition: bluetooth_dispatcher.hpp:57
error::KallistoDetailedResult stop(bool link_loss)
std::map< std::string, const void * > getParameters()
Definition: executor.hpp:71
error::KallistoDetailedResult update(std::map< std::string, const void *> parameters)
Definition: rssi_sensor.hpp:55
RssiSensor(std::string name, std::string address, std::string vendor, unsigned int version, SensorType type, std::string string_type, ReportingMode reporting_mode, unsigned int identifier, float max_range, float resolution, float power, std::chrono::microseconds min_delay, std::chrono::microseconds max_delay, util::Executor &event_dispatcher, bluetooth::BluetoothDispatcher &bluetooth_dispatcher)
std::function< void(SensorEvent &event)> InternalSensorEventListener
Definition: sensor_impl.hpp:65
static std::vector< std::unique_ptr< SensorImpl > > build(std::string address, util::Executor &event_dispatcher, bluetooth::BluetoothDispatcher &bluetooth_dispatcher, const std::map< uint16_t, std::vector< uint8_t > > &manufacturer_data)
Definition: sensor_impl.hpp:70
ReportingMode
Definition: sensor.hpp:126