Telematics SDK - API Reference  v1.54.0
Sensor Control

Data Structures

class  telux::sensor::ISensorEventListener
 ISensorEventListener interface is used to receive notifications related to sensor events and configuration updates. More...
 
class  telux::sensor::ISensorClient
 ISensorClient interface is used to access the different services provided by the sensor framework to configure, activate and acquire sensor data. More...
 
class  telux::sensor::ISensorManager
 Sensor Manager class provides APIs to interact with the sensor sub-system and get access to other sensor objects which can be used to configure, activate or get data from the individual sensors available - Gyro, Accelero, etc. More...
 

Typedefs

using telux::sensor::SelfTestResultCallback = std::function< void(telux::common::ErrorCode result)>
 This file hosts the sensor interfaces to configure, activate or get data from the individual sensors available - Gyroscope, Accelerometer, etc. More...
 
using telux::sensor::ISensor = ISensorClient
 

Detailed Description

This section contains APIs related to sensor configuration, sensor control and data acquisition from sensors.


Data Structure Documentation

class telux::sensor::ISensorEventListener

ISensorEventListener interface is used to receive notifications related to sensor events and configuration updates.

The listener method can be invoked from multiple different threads. Client needs to make sure that implementation is thread-safe.

Public Member Functions

virtual void onEvent (std::shared_ptr< std::vector< SensorEvent >> events)
 
virtual void onConfigurationUpdate (SensorConfiguration configuration)
 
virtual ~ISensorEventListener ()
 

Constructor & Destructor Documentation

virtual telux::sensor::ISensorEventListener::~ISensorEventListener ( )
virtual

The destructor for the sensor event listener

Member Function Documentation

virtual void telux::sensor::ISensorEventListener::onEvent ( std::shared_ptr< std::vector< SensorEvent >>  events)
virtual

This function is called to notify about available sensor events. Note the following constraints on this listener API It shall not perform time consuming (compute or I/O intensive) operations on this thread It shall not inovke an sensor APIs on this thread due to the underlying concurrency model

On platforms with Access control enabled, the client needs to have TELUX_SENSOR_DATA_READ permission for this listener API to be invoked.

Parameters
[in]events- List of sensor events
Note
Eval: This is a new API and is being evaluated. It is subject to change and could break backwards compatibility.
virtual void telux::sensor::ISensorEventListener::onConfigurationUpdate ( SensorConfiguration  configuration)
virtual

This function is called to notify any change in the configuration of the ISensorClient object this listener is associated with.

On platforms with Access control enabled, the client needs to have TELUX_SENSOR_DATA_READ permission for this listener API to be invoked.

Parameters
[in]configuration- The new configuration of the sensor client. telux::sensor::SensorConfiguration. Fields that have changed can be identified using the telux::sensor::SensorConfiguration::updateMask and fields that are valid can be identified using telux::sensor::SensorConfiguration::validityMask
Note
Eval: This is a new API and is being evaluated. It is subject to change and could break backwards compatibility.
class telux::sensor::ISensorClient

ISensorClient interface is used to access the different services provided by the sensor framework to configure, activate and acquire sensor data.

Each instance of this class is a unique sensor client to the underlying sensor framework and any number of such clients can exist in a given process. Each of these clients can acquire data from the underlying sensor framework with different configurations.

Public Member Functions

virtual SensorInfo getSensorInfo ()=0
 
virtual telux::common::Status configure (SensorConfiguration configuration)=0
 
virtual SensorConfiguration getConfiguration ()=0
 
virtual telux::common::Status activate ()=0
 
virtual telux::common::Status deactivate ()=0
 
virtual telux::common::Status selfTest (SelfTestType selfTestType, SelfTestResultCallback cb)=0
 
virtual telux::common::Status registerListener (std::weak_ptr< ISensorEventListener > listener)=0
 
virtual telux::common::Status deregisterListener (std::weak_ptr< ISensorEventListener > listener)=0
 
virtual ~ISensorClient ()
 
virtual telux::common::Status enableLowPowerMode ()=0
 
virtual telux::common::Status disableLowPowerMode ()=0
 

Constructor & Destructor Documentation

virtual telux::sensor::ISensorClient::~ISensorClient ( )
virtual

Destructor for ISensorClient.

Internally, the sensor client object is first deactivated and then destroyed.

Member Function Documentation

virtual SensorInfo telux::sensor::ISensorClient::getSensorInfo ( )
pure virtual

Get the information related to sensor

Returns
information retated to sensor - telux::sensor::SensorInfo
Note
Eval: This is a new API and is being evaluated. It is subject to change and could break backwards compatibility.
virtual telux::common::Status telux::sensor::ISensorClient::configure ( SensorConfiguration  configuration)
pure virtual

Configure the sensor client with desired sampling rate and batch count. Any change in sampling rate or batch count of the sensor will be notified via telux::sensor::ISensorEventListener::onConfigurationUpdate.

In case a sensor client needs to be reconfigured after having been activated, the client should be deactivated, configured and activated again as a part of the reconfiguration process.

It is always recommended that configuration of a client is done before activating it. If a client is activated without configuration, the client is configured with a default configuration and activated. The default configuration would have the sampling rate set to minimum sampling rate supported telux::sensor::SensorInfo::samplingRates and the batch count set to maximum batch count supported telux::sensor::SensorInfo::maxBatchCountSupported

On platforms with Access control enabled, Caller needs to have TELUX_SENSOR_DATA_READ permission to invoke this API successfully.

Parameters
[in]configuration- The desired configuration for the client telux::sensor::SensorConfiguration. Ensure the required validity mask telux::sensor::SensorConfiguration::validityMask is set for the configuration.
Returns
status of configuration request - telux::common::Status
Note
Eval: This is a new API and is being evaluated. It is subject to change and could break backwards compatibility.
virtual SensorConfiguration telux::sensor::ISensorClient::getConfiguration ( )
pure virtual

Get the current configuration of this sensor client

On platforms with Access control enabled, Caller needs to have TELUX_SENSOR_DATA_READ permission to invoke this API successfully.

Returns
the current configuration of the client. telux::sensor::SensorConfiguration::validityMask should be checked to know which of the fields in the returned configuration is valid.
Note
Eval: This is a new API and is being evaluated. It is subject to change and could break backwards compatibility.
virtual telux::common::Status telux::sensor::ISensorClient::activate ( )
pure virtual

Activate the sensor client. Once activated, any available sensor event will be notified via telux::sensor::ISensorEventListener::onEvent

It is always recommended that configuration of a client is done before activating it. If a client is activated without configuration, the client is configured with the default configuration and activated. The default configuration would have the sampling rate set to minimum sampling rate supported telux::sensor::SensorInfo::samplingRates and the batch count set to maximum batch count supported telux::sensor::SensorInfo::maxBatchCountSupported. Activating an already activated sensor would result in the API returning telux::common::Status::SUCCESS.

Activating this sensor client would not impact other inactive sensor clients.

On platforms with Access control enabled, Caller needs to have TELUX_SENSOR_DATA_READ permission to invoke this API successfully.

Returns
status of activation request - telux::common::Status
Note
Eval: This is a new API and is being evaluated. It is subject to change and could break backwards compatibility.
virtual telux::common::Status telux::sensor::ISensorClient::deactivate ( )
pure virtual

Deactivate the sensor client. Once deactivated, no further sensor events will be notified via telux::sensor::ISensorEventListener::onEvent. Deactivating an already inactive sensor would result in the API returning telux::common::Status::SUCCESS.

Deactivating this sensor client would not impact other active sensor clients.

On platforms with Access control enabled, Caller needs to have TELUX_SENSOR_DATA_READ permission to invoke this API successfully.

Returns
status of deactivation request - telux::common::Status
Note
Eval: This is a new API and is being evaluated. It is subject to change and could break backwards compatibility.
virtual telux::common::Status telux::sensor::ISensorClient::selfTest ( SelfTestType  selfTestType,
SelfTestResultCallback  cb 
)
pure virtual

Initiate self test on this sensor

If there are active data acquisition sessions corresponding to this sensor, these will be paused and the self test is initiated. Once the self test is complete the sensor data sessions will be restored.

On platforms with Access control enabled, Caller needs to have TELUX_SENSOR_PRIVILEGED_OPS permission to invoke this API successfully.

Parameters
[in]selfTestType- The type of self test to be performed - telux::sensor::SelfTestType
[in]cb- Callback to get the result of the self test initiated
Returns
status of the request - telux::common::Status. Note that the result of the self test done by the sensor is provided via the callback - telux::sensor::SelfTestResultCallback
Note
Eval: This is a new API and is being evaluated. It is subject to change and could break backwards compatibility.
virtual telux::common::Status telux::sensor::ISensorClient::registerListener ( std::weak_ptr< ISensorEventListener listener)
pure virtual

Register a listener for sensor related events

Returns
status of registration request - telux::common::Status
Note
Eval: This is a new API and is being evaluated. It is subject to change and could break backwards compatibility.
virtual telux::common::Status telux::sensor::ISensorClient::deregisterListener ( std::weak_ptr< ISensorEventListener listener)
pure virtual

Deregister a sensor event listener

Returns
status of deregistration request - telux::common::Status
Note
Eval: This is a new API and is being evaluated. It is subject to change and could break backwards compatibility.
virtual telux::common::Status telux::sensor::ISensorClient::enableLowPowerMode ( )
pure virtual

Deprecated APIs Request the sensor to operate in low power mode. The sensor should be in deactivated state to exercise this API. The success of this request depends on the capabilities of the underlying hardware.

Returns
status of request - telux::common::Status
Deprecated
This API is no longer supported.
virtual telux::common::Status telux::sensor::ISensorClient::disableLowPowerMode ( )
pure virtual

Request the sensor to exit low power mode. The sensor should be in deactivated state to exercise this API. The success of this request depends on the capabilities of the underlying hardware.

Returns
status of request - telux::common::Status
Deprecated
This API is no longer supported.
class telux::sensor::ISensorManager

Sensor Manager class provides APIs to interact with the sensor sub-system and get access to other sensor objects which can be used to configure, activate or get data from the individual sensors available - Gyro, Accelero, etc.

Public Member Functions

virtual telux::common::ServiceStatus getServiceStatus ()=0
 
virtual telux::common::Status getAvailableSensorInfo (std::vector< SensorInfo > &info)=0
 
virtual telux::common::Status getSensor (std::shared_ptr< ISensorClient > &sensor, std::string name)=0
 
virtual telux::common::Status getSensorClient (std::shared_ptr< ISensorClient > &sensor, std::string name)=0
 
virtual ~ISensorManager ()
 

Constructor & Destructor Documentation

virtual telux::sensor::ISensorManager::~ISensorManager ( )
virtual

Destructor for ISensorManager

Member Function Documentation

virtual telux::common::ServiceStatus telux::sensor::ISensorManager::getServiceStatus ( )
pure virtual

Checks the status of sensor sub-system and returns the result.

Returns
the status of sensor sub-system status telux::common::ServiceStatus
virtual telux::common::Status telux::sensor::ISensorManager::getAvailableSensorInfo ( std::vector< SensorInfo > &  info)
pure virtual

Get information related to the sensors available in the system.

Parameters
[out]infoList of information on sensors available in the system telux::sensor::SensorInfo
Returns
status of the request telux::common::Status
virtual telux::common::Status telux::sensor::ISensorManager::getSensor ( std::shared_ptr< ISensorClient > &  sensor,
std::string  name 
)
pure virtual

Get an instance of ISensorClient to interact with the underlying sensor. The provided instance is not a singleton. Everytime this method is called a new sensor object is created. It is the caller's responsibility to manage the object's lifetime. Every instance of the sensor returned acts as new client and can configure the underlying sensor with it's own configuration and it's own callbacks for telux::sensor::SensorEvent and configuration update among other events telux::sensor::ISensorEventListener.

Parameters
[out]sensor- An instance of telux::sensor::ISensorClient to interact with the underlying sensor is provided as a result of the method If the initialization of the sensor and underlying system fails, sensor is set to nullptr
[in]name- The unique name of the sensor telux::sensor::SensorInfo::name that was provided in the list of sensor information by telux::sensor::ISensorManager::getAvailableSensorInfo
Returns
Status of request telux::common::Status
Deprecated
Use getSensorClient API.
virtual telux::common::Status telux::sensor::ISensorManager::getSensorClient ( std::shared_ptr< ISensorClient > &  sensor,
std::string  name 
)
pure virtual

Get an instance of ISensorClient to interact with the underlying sensor. The provided instance is not a singleton. Everytime this method is called a new sensor object is created. It is the caller's responsibility to manage the object's lifetime. Every instance of the sensor returned acts as new client and can configure the underlying sensor with it's own configuration and it's own callbacks for telux::sensor::SensorEvent and configuration update among other events telux::sensor::ISensorEventListener.

Parameters
[out]sensor- An instance of telux::sensor::ISensorClient to interact with the underlying sensor is provided as a result of the method If the initialization of the sensor and underlying system fails, sensor is set to nullptr
[in]name- The unique name of the sensor telux::sensor::SensorInfo::name that was provided in the list of sensor information by telux::sensor::ISensorManager::getAvailableSensorInfo
Returns
Status of request telux::common::Status
Note
Eval: This is a new API and is being evaluated. It is subject to change and could break backwards compatibility.

Typedef Documentation

using telux::sensor::SelfTestResultCallback = typedef std::function<void(telux::common::ErrorCode result)>

This file hosts the sensor interfaces to configure, activate or get data from the individual sensors available - Gyroscope, Accelerometer, etc.

This function is invoked when a result for a self-test initiated using telux::sensor::ISensorClient::selfTest is available.

Parameters
[in]resultThe result of the self test - telux::common::ErrorCode
using telux::sensor::ISensor = typedef ISensorClient