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

#include <sensor_impl.hpp>

Inheritance diagram for SensorImpl:
Collaboration diagram for SensorImpl:

Public Member Functions

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
 

Static Public Member Functions

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)
 

Protected Member Functions

virtual error::KallistoDetailedResult start (std::map< std::string, const void *> parameters, InternalSensorEventListener internal_listener)=0
 
virtual error::KallistoDetailedResult update (std::map< std::string, const void *> parameters)=0
 
virtual std::map< std::string, const void * > getParameters ()=0
 
virtual error::KallistoDetailedResult stop (bool link_loss)=0
 
 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 Attributes

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 }
 

Detailed Description

Class representing a sensor implementation.

Constructor & Destructor Documentation

◆ SensorImpl() [1/2]

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

Constructor.

◆ ~SensorImpl()

virtual ~SensorImpl ( )
virtual

Destructor.

◆ SensorImpl() [2/2]

SensorImpl ( SensorImpl const &  )
delete

Remove copy and move.

Member Function Documentation

◆ generateHandle()

static unsigned int generateHandle ( )
static

Generate sensor handle.

◆ getEnabled()

bool getEnabled ( )

Checks if this sensor is enabled.

Returns
true
if this sensor is enabled.

◆ getIdFromManufacturerData()

static unsigned char getIdFromManufacturerData ( unsigned char  byte)
static

Parses a manufacturer data byte and returns the contained sensor id.

Parameters
byte
Returns
The parsed sensor id.

◆ getParameters()

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

Get the current configured parameters.

Returns
The current configured parameter map.

Implemented in BatteryChargingSensor, BatterySocSensor, RssiSensor, and KallistoSensor.

◆ getTypeFromManufacturerData()

static unsigned char getTypeFromManufacturerData ( unsigned char  byte)
static

Parses a manufacturer data byte and returns the contained sensor type.

Parameters
byte
Returns
The parsed sensor type.

◆ KEY_DELAY()

static const std::string& KEY_DELAY ( )
static
Returns
The string key for the delay parameter. The object with this key should be parsed as an std::chrono::microseconds.

◆ onLinkLoss()

void onLinkLoss ( )

Called when the device that contains this sensor enters in Link Loss mode.

The sensor should save the current state.

◆ onLinkRecovered()

error::KallistoDetailedResult onLinkRecovered ( )

Called when the device that contains this sensor recovers from Link Loss mode.

The sensor should restore the state saved in onLinkLoss(). For example, if it was enabled, it should start reporting data at the rate previously configured.

Returns
A detailed result.

◆ registerListener()

error::KallistoDetailedResult registerListener ( std::map< std::string, const void *>  parameters,
SensorEventListener listener 
)

Called when a client registers to receive sensor data.

The available parameters are:

  • KEY_DELAY() - the object should be parsed as an integer where the sensor delay is passed in microseconds;
Parameters
parametersMap of abstract parameters. The map follows a key/value structure where the key determines how the object should be parsed.
listenerThe sensor event listener.
Returns
A detailed result.

◆ start()

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

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.

Implemented in BatteryChargingSensor, BatterySocSensor, RssiSensor, and KallistoSensor.

◆ stop()

virtual error::KallistoDetailedResult stop ( bool  link_loss)
protectedpure virtual

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.

Implemented in BatteryChargingSensor, BatterySocSensor, RssiSensor, and KallistoSensor.

◆ unregisterListener()

error::KallistoDetailedResult unregisterListener ( SensorEventListener listener)

Called when a client unregisters for sensor events.

Parameters
listenerThe sensor event listener used with registerListener call.
Returns
A detailed result.

◆ update()

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

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.

Implemented in BatteryChargingSensor, BatterySocSensor, RssiSensor, and KallistoSensor.

Field Documentation

◆ m_bluetooth_dispatcher

bluetooth::BluetoothDispatcher& m_bluetooth_dispatcher
protected

◆ m_link_loss

bool m_link_loss
protected

◆ m_sensor_synchronizer

TimeSynchronizer* m_sensor_synchronizer
protected

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