Kallisto Linux API
Library for interacting with Kallisto devices
battery_soc_sensor.hpp
Go to the documentation of this file.
1 
42 #ifndef BATTERY_SOC_SENSOR_HPP
43 #define BATTERY_SOC_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 
57 private:
59  static const std::vector<unsigned char> IDENTIFIERS; //Holds the available instances identifiers
61  static const std::vector<std::string> SERVICE_UUIDS; //Holds the service UUIDS that holds the sensor characteristics
63  static const std::vector<std::string> DATA_CHAR_UUIDS; //Holds the data characteristic UUIDs
65  static const unsigned char MANUFACTURER_DATA_TYPE; //Type used in manufacturer data to identify a sensor of this type
66 
67  //Constants to populate the sensor data
69  static const std::string NAME;
71  static const std::string VENDOR;
73  static const std::string STRING_TYPE;
75  static const float MAX_RANGE;
77  static const float RESOLUTION;
79  static const float POWER;
81  static const std::chrono::microseconds MIN_DELAY;
83  static const std::chrono::microseconds MAX_DELAY;
84 
86  InternalSensorEventListener m_listener; //Holder for the sensor callback
88  kallisto::util::Executor m_executor{"BatterySoc", 1};
89 protected:
93  BatterySocSensor(std::string name, std::string address, std::string vendor, unsigned int version, SensorType type, std::string string_type,
94  ReportingMode reporting_mode, unsigned int identifier, float max_range, float resolution, float power, std::chrono::microseconds min_delay,
95  std::chrono::microseconds max_delay, util::Executor& event_dispatcher, bluetooth::BluetoothDispatcher& bluetooth_dispatcher);
96 
106  error::KallistoDetailedResult start(std::map<std::string, const void*> parameters, InternalSensorEventListener internal_listener);
107 
116  error::KallistoDetailedResult update(std::map<std::string, const void*> parameters);
117 
122  std::map<std::string, const void*> getParameters();
123 
130  error::KallistoDetailedResult stop(bool link_loss);
131 
140  void onNotification(std::string address, std::string service_uuid, std::string characteristic_uuid, const std::vector<unsigned char>& values);
141 
142 public:
147 
151  BatterySocSensor(BatterySocSensor const&) = delete;
152 
156  void operator=(BatterySocSensor const&) = delete;
157 
164  static bool isAvailable(unsigned int identifier, const std::map<uint16_t, std::vector<uint8_t> >& manufacturer_data);
165 
173  static bool isAvailable(unsigned int identifier, bluetooth::BluetoothDispatcher& bluetooth_dispatcher);
174 
184  static std::vector<std::unique_ptr<SensorImpl> > build(std::string address, util::Executor& event_dispatcher,
185  bluetooth::BluetoothDispatcher& bluetooth_dispatcher,
186  const std::map<uint16_t, std::vector<uint8_t> >& manufacturer_data);
187 };
188 
189 } /* namespace hardware */
190 } /* namespace kallisto */
191 
192 #endif // BATTERY_SOC_HPP
void onNotification(std::string address, std::string service_uuid, std::string characteristic_uuid, const std::vector< unsigned char > &values)
Definition: bluetooth_adapter.hpp:52
Class that encapsulates a result.
Definition: kallisto_error.hpp:81
static bool isAvailable(unsigned int identifier, const std::map< uint16_t, std::vector< uint8_t > > &manufacturer_data)
SensorType
Definition: sensor.hpp:60
Definition: bluetooth_dispatcher.hpp:57
error::KallistoDetailedResult update(std::map< std::string, const void *> parameters)
Definition: battery_soc_sensor.hpp:55
void operator=(BatterySocSensor const &)=delete
Definition: executor.hpp:71
BatterySocSensor(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)
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)
error::KallistoDetailedResult stop(bool link_loss)
error::KallistoDetailedResult start(std::map< std::string, const void *> parameters, InternalSensorEventListener internal_listener)
std::map< std::string, const void * > getParameters()
std::function< void(SensorEvent &event)> InternalSensorEventListener
Definition: sensor_impl.hpp:65
Definition: sensor_impl.hpp:70
ReportingMode
Definition: sensor.hpp:126