Sensor Channel Declaration

This document provides details about the sensor channel declarations.

Channel type declarations

All the supported sensor channels are declared in the Sensor definitions API headers and classes. For details about the types of Sensor Channels, see Types of Sensor Channels.

The number of implemented channels can vary between products. For information on supported sensor channels on different devices, see Device specifications on Forum Nokia.

Every channel is defined by its unique channel type ID constant and a short description.

For example, a double tapping channel declaration is as shown in the following code snippet:

    /**
    * - Name:          Double tapping event channel type
    * - Type:          Event
    * - Datatype:      TSensrvTappingData
    * - Description:   Double tapping events 
    */
    const TSensrvChannelTypeId KSensrvChannelTypeIdAccelerometerDoubleTappingData = 0x10205081;

Channel data type declarations

Sensor Channels can be classified based on the type of data that they provide. The classification is as follows:
  • Continuous Data Channel: A channel that outputs continuous data at regular intervals. For example, Accelerometer XYZ, Rotation and Magnetometer XYZ.

  • Event Channel: A channel that signals a client when an appropriate event occurs. For example, Single Tap and Double Tap.

  • State channel: A channel that signals a client when its state has changed. For example, Proximity Monitor.

The channel data types are declared in each sensor's header file. For example, a double tapping channel data type declaration is as shown in the following code snippet:

    class TSensrvTappingData 
        {
    public:
        /**
        * Channel data type Id number
        */
        static const TSensrvChannelDataTypeId KDataTypeId = 0x1020507F;
        /**
        * Channel data type enumerations
        */
        enum TSensrvAccelerometerAxisDataIndexes
              {
              iTimeStamp = 0,
              iDirection
              };
            };
    public:
        /**
        * - Item name:   Sampling time.
        * - Item Index:  0
        * - Conditions:  None
        * - Description: Timestamp for a sample.
        */   
        TTime iTimeStamp;    
        /**
        * - Item name:   Tapping direction bitmask
        * - Item Index:  1
        * - Conditions:  Binary
        * - Description: Direction bitmask of the tapping event.
        *                See constant definitions above.
        */
        TUint32 iDirection;
        };

The channel data type ID (for example, TSensrvTappingData::KDataTypeId) is a unique ID for each data type, enabling the separation of data types from each other. The data type ID is used in TSensrvChannelInfo to define the data type used in a channel.

The channel data type index (for example, TSensrvTappingData::iDirection) is used to point to an attribute inside a data type. Attributes of the TSensrvTappingData class are iTimeStamp and iDirection.

The channel data type index is used in:
  • properties (TSensrvProperty) if a property scope is a channel item
  • conditions (CSensrvChannelCondition) to identify which attribute is used as a condition

Channel property declarations

Channel properties are declared in sensrvgeneralproperties.h and sensor specific files. For example, general properties for all channel types are declared in the sensrvgeneralproperties.h file and accelerometer specific properties are declared in the sensrvaccelerometersensor.h file.

Each channel property is defined by its unique property ID constant and a short description. The property type specifies the type of the value the property contains. It can be TInt, TReal or TBuf. Property scope can be defined for a:

  • channel
  • specific attribute inside channel data
  • sensor related to a channel.

For example, accuracy property is declared as shown in the following code snippet:

    /**
    * - Name:         Accuracy of the channel data
    * - Type:         TReal
    * - Scope:        Channel item property
    * - Mandatory:    No
    * - Capability:   None
    * - Description:  Returns the accuracy of this channel of the sensor as a
    *                 percentage of reading (=data value).
    */
    const TSensrvPropertyId KSensrvPropIdChannelAccuracy = 0x000000008;

A mandatory section specifies if the property is required for all channels. Capability section specifies the required capabilities to change value of the property.

The example content of the accuracy property is shown in the following code snippet.

    iPropertyId   = KSensrvPropIdChannelAccuracy
    iItemIndex    = KSensrvItemIndexNone
    iArrayIndex   = ESensrvSingleProperty
    iRealValue    = 10.0
    iReadOnly     = ETrue
    iRealValueMax = n/a
    iRealValueMin = n/a
    iPropertyType = ESensrvRealProperty
    iSecurityInfo = n/a

The array index is explained in Array Properties.