Kallisto Linux API
Library for interacting with Kallisto devices
KallistoSensor Class Referenceabstract

#include <kallisto_sensor.hpp>

Inheritance diagram for KallistoSensor:
Collaboration diagram for KallistoSensor:

Public Member Functions

virtual ~KallistoSensor ()
 
 KallistoSensor (KallistoSensor const &)=delete
 
void operator= (KallistoSensor const &)=delete
 
- Public Member Functions inherited from SensorImpl
virtual ~SensorImpl ()
 
 SensorImpl (SensorImpl const &)=delete
 
 SensorImpl (SensorImpl &&)=delete
 
void operator= (SensorImpl const &)=delete
 
void operator= (SensorImpl &&)=delete
 
error::KallistoDetailedResult registerListener (std::map< std::string, const void *> parameters, SensorEventListener &listener)
 
error::KallistoDetailedResult unregisterListener (SensorEventListener &listener)
 
bool getEnabled ()
 
void onLinkLoss ()
 
error::KallistoDetailedResult onLinkRecovered ()
 
- Public Member Functions inherited from Sensor
unsigned int getHandle () const
 
std::string getName () const
 
std::string getAddress () const
 
std::string getVendor () const
 
unsigned int getVersion () const
 
SensorType getType () const
 
std::string getStringType () const
 
ReportingMode getReportingMode () const
 
unsigned int getIdentifier () const
 
float getMaximumRange () const
 
float getResolution () const
 
float getPower () const
 
std::chrono::microseconds getMinDelay () const
 
std::chrono::microseconds getMaxDelay () const
 
std::string toString ()
 
bool operator== (const Sensor &other) const
 
bool operator!= (const Sensor &other) const
 

Protected Member Functions

 KallistoSensor (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, TimeSynchronizer *sensor_synchronizer, std::string service_uuid, std::string configuration_char_uuid, std::string data_char_uuid)
 
error::KallistoDetailedResult start (std::map< std::string, const void *> parameters, InternalSensorEventListener internal_listener)
 
error::KallistoDetailedResult update (std::map< std::string, const void *> parameters)
 
std::map< std::string, const void * > getParameters ()
 
error::KallistoDetailedResult stop (bool link_loss)
 
void onNotification (std::string address, std::string service_uuid, std::string characteristic_uuid, const std::vector< unsigned char > &values)
 
virtual std::vector< unsigned char > parseConfiguration (bool enable, std::chrono::microseconds delay)=0
 
virtual std::vector< SensorEventparseData (const std::vector< unsigned char > &data)=0
 
- Protected Member Functions inherited from SensorImpl
 SensorImpl (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, TimeSynchronizer *sensor_synchronizer)
 
- Protected Member Functions inherited from Sensor
 Sensor (unsigned int handle, 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)
 
virtual ~Sensor ()
 
 Sensor (Sensor const &)=delete
 
 Sensor (Sensor &&)=delete
 
void operator= (Sensor const &)=delete
 
void operator= (Sensor &&)=delete
 
- Protected Member Functions inherited from BluetoothDispatcher::NotificationListener
 NotificationListener ()
 
virtual ~NotificationListener ()
 
 NotificationListener (NotificationListener const &)=delete
 
 NotificationListener (NotificationListener &&)=delete
 
void operator= (NotificationListener const &)=delete
 
void operator= (NotificationListener &&)=delete
 

Protected Attributes

std::string m_service_uuid
 
std::string m_configuration_char_uuid
 
std::string m_data_char_uuid
 
std::chrono::microseconds m_delay
 
InternalSensorEventListener m_listener
 
- Protected Attributes inherited from SensorImpl
bool m_link_loss
 
bluetooth::BluetoothDispatcherm_bluetooth_dispatcher
 
TimeSynchronizerm_sensor_synchronizer
 
- Protected Attributes inherited from Sensor
const unsigned int m_handle
 
const std::string m_name
 
const std::string m_address
 
const std::string m_vendor
 
const unsigned int m_version
 
const SensorType m_type
 
const std::string m_string_type
 
const ReportingMode m_reporting_mode
 
const unsigned int m_identifier
 
const float m_max_range
 
const float m_resolution
 
const float m_power
 
const std::chrono::microseconds m_min_delay
 
const std::chrono::microseconds m_max_delay
 

Additional Inherited Members

- Public Types inherited from Sensor
enum  SensorType {
  ACCELEROMETER, MAGNETIC_FIELD, GYROSCOPE, PRESSURE,
  RELATIVE_HUMIDITY, AMBIENT_TEMPERATURE, BATTERY_SOC, BATTERY_CHARGING_STATUS,
  RSSI, ANALOG, CO2_CONCENTRATION, TVOC_CONCENTRATION
}
 
enum  ReportingMode { REPORTING_MODE_CONTINUOUS, REPORTING_MODE_ON_CHANGE, REPORTING_MODE_ONE_SHOT, REPORTING_MODE_SPECIAL_TRIGGER }
 
- Static Public Member Functions inherited from SensorImpl
static unsigned int generateHandle ()
 
static const std::string & KEY_DELAY ()
 
static unsigned char getTypeFromManufacturerData (unsigned char byte)
 
static unsigned char getIdFromManufacturerData (unsigned char byte)
 
- Static Public Member Functions inherited from Sensor
static unsigned int getValueArraySize (SensorType type)
 

Detailed Description

Class that implements a Kallisto Sensor. The HAL communication is almost the same for all sensors so they are all subclasses of this class.

Constructor & Destructor Documentation

◆ KallistoSensor() [1/2]

KallistoSensor ( 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,
TimeSynchronizer sensor_synchronizer,
std::string  service_uuid,
std::string  configuration_char_uuid,
std::string  data_char_uuid 
)
protected

Constructor.

◆ ~KallistoSensor()

virtual ~KallistoSensor ( )
virtual

Destructor.

◆ KallistoSensor() [2/2]

KallistoSensor ( KallistoSensor const &  )
delete

Remove copy.

Member Function Documentation

◆ getParameters()

std::map<std::string, const void*> getParameters ( )
protectedvirtual

Get the current configured parameters.

Returns
The current configured parameter map.

Implements SensorImpl.

◆ onNotification()

void onNotification ( std::string  address,
std::string  service_uuid,
std::string  characteristic_uuid,
const std::vector< unsigned char > &  values 
)
protectedvirtual

Called when there is a new notification of a characteristic.

Parameters
addressThe mac address of the device that generated this event.
serviceUuidThe UUID of the service that contains the characteristic that generated this event.
characteristicUuidThe UUID of the characteristic that generated this event.
valuesA byte buffer with the new values of the characteristics.

Implements BluetoothDispatcher::NotificationListener.

◆ operator=()

void operator= ( KallistoSensor const &  )
delete

Remove attribution.

◆ parseConfiguration()

virtual std::vector<unsigned char> parseConfiguration ( bool  enable,
std::chrono::microseconds  delay 
)
protectedpure virtual

Parses the passed delay into configuration to be sent to the device configuration characteristic. In the Kallistos HALs, the configuration is a single byte, where the LSB signals if the sensor should be enabled and the 3 MSB codify the sensor rate.

Parameters
enableIf the sensor should be enabled or not.
delayThe desired delay, in microseconds.
Returns
A byte array with the configuration to be sent to the device.

Implemented in Ads1014Adc, Bme280Barometer, Bme280RelativeHumiditySensor, Bme280Thermometer, Bmi160Accelerometer, Bmi160Gyroscope, Bmi160Magnetometer, Ccs811Co2Sensor, and Ccs811TvocSensor.

◆ parseData()

virtual std::vector<SensorEvent> parseData ( const std::vector< unsigned char > &  data)
protectedpure virtual

Parses the received raw data into sensor events.

Parameters
dataThe received raw data.
Returns
An array of sensor events.

Implemented in Ads1014Adc, Bme280Barometer, Bme280RelativeHumiditySensor, Bme280Thermometer, Bmi160Accelerometer, Bmi160Gyroscope, Bmi160Magnetometer, Ccs811Co2Sensor, and Ccs811TvocSensor.

◆ start()

error::KallistoDetailedResult start ( std::map< std::string, const void *>  parameters,
InternalSensorEventListener  internal_listener 
)
protectedvirtual

Called when the sensor should be enabled and start reporting data.

See also
registerListener for parameter informations.
Parameters
parametersMap of abstract parameters. The map follows a key/value structure where the key determines how the object should be parsed.
internal_listenerAll sensor events should be sent to this listener.
Returns
A detailed result.

Implements SensorImpl.

◆ stop()

error::KallistoDetailedResult stop ( bool  link_loss)
protectedvirtual

Called when the sensor should be disabled and stop reporting data.

Parameters
link_lossTrue if the device is in link loss and there is no BLE connection. Should only clear data in this case. If it is false, BLE communication can be conducted to disable the sensor in the peripheral side.
Returns
A detailed result.

Implements SensorImpl.

◆ update()

error::KallistoDetailedResult update ( std::map< std::string, const void *>  parameters)
protectedvirtual

Called when when the sensor is already enabled and should update its' configurations.

See also
registerListener for parameter informations.
Parameters
parametersMap of abstract parameters. The map follows a key/value structure where the key determines how the object should be parsed.
Returns
A detailed result.

Implements SensorImpl.

Field Documentation

◆ m_configuration_char_uuid

std::string m_configuration_char_uuid
protected

◆ m_data_char_uuid

std::string m_data_char_uuid
protected

◆ m_delay

std::chrono::microseconds m_delay
protected

◆ m_listener

InternalSensorEventListener m_listener
protected

◆ m_service_uuid

std::string m_service_uuid
protected

The documentation for this class was generated from the following file: