6.10.1 FindSensorChannel

FindSensorChannel performs a search operation for sensor channels in a S60 device based on the specified search criteria.

The client application specifies the search parameters and queries to the Sensor services, which returns a list containing channel information matching the search parameters.

The following is an example for using FindSensorChannel:

sensor_handle.call('FindSensorChannel', {'SearchCriterion': u'Orientation'})

The following table summarizes the specification of FindSensorChannel:

Interface ISensor
Description Performs a search operation for sensor channels in an S60 device based on the specified search criteria.
Response Model Synchronous
Pre-condition ISensor interface is loaded.
Post-condition Receives list of sensor channel which can be used to open channels.


Input Parameters

Input parameter is a string that specifies the search criteria for performing the search operation.

Table 6.192: Input parameters for FindSensorChannel
Name Type Range Description
SearchCriterion unicode string All
AccelerometerAxis
AccelerometerDoubleTapping
Orientation
Rotation
Specifies the search criterion.

You can select from the list provided and specify it as an argument.


Output Parameters

Add API which misses out on some mandatory input Output contains ReturnValue. It also contains ErrorCode and an ErrorMessage if the operation fails. ReturnValue is an array of objects, which contains the sensor channel information requested by FindSensorChannel.

Table 6.193: Output parameters for FindSensorChannel
Name Type Range Description
ErrorCode 32 bit int NA Contains the SAPI specific error code when the operation fails.
ErrorMessage string NA Error Description in Engineering English.
ReturnValue Lists of maps. Each map in this document is referred as ChannelInfoMap. For more information, refer table ChannelInfoMap 6.194 ContextType
0: Not defined
1: Ambient sensor. For example, to measure pressure.
2: Gives information on device itself.
3: Measures user initiated stimulus.

Quantity
0: Not defined
10: Acceleration
11: Tapping
12: Orientation
13: Rotation
14: Magnetic
15: Tilt

ReturnValue consists of a list of maps, each map of which holds the key-value pair for each of sensor channel that satisfy the search criterion.



Table 6.194: ChannelInfoMap
Type Name Description
32 bit int ChannelId Unique ID representing the channel.
32 bit int ContextType Defines the context where the channel is available.
32 bit int Quantity Defines the quantity being sensed.
32 bit int ChannelType Defines a unique type ID for each channel.
string Location Location of the sensor related to channel.
string VendorId Vendor ID of the sensor related to channel.
32 bit int DataItemSize Data item size delivered in the channel.
32 bit int ChannelDataTypeId Unique data type identifier for the data being sensed.


Errors

The following table lists the error codes and their values:

Table 6.195: Error codes
Error code value Description
0 Success
1000 Invalid service argument
1002 Bad argument type
1003 Missing argument


Error Messages

The following table lists the error messages and their description:

Table 6.196: Error messages
Error messages Description
Sensors:FindSensorChannel: Search Criterion Missing Indicates that channel search criterion is missing from the input parameter list.
Sensors:FindSensorChannel: Invalid Search Criterion Indicates that the channel search criterion is invalid and does not fall within the specified range of search criterion strings.
Sensors:FindSensorChannel: Channel search param type invalid Indicates that the datatype of the parameter passed for the channel search criterion is invalid.


Example

The following sample code illustrates how to query a list of channel information matching the search parameters:

try:
    result = sensor_handle.call('FindSensorChannel', {'SearchCriterion': u'Orientation'})
    count_items = len(result)
    print count_items
    print "ChannelId : ", result[0]['ChannelId']
    print "ContextType : ", result[0]['ContextType']
    print "Quantity : ", result[0]['Quantity']
    print "ChannelType : ", result[0]['ChannelType']
    print "Location : ", result[0]['Location']
    print "VendorId : ", result[0]['VendorId']
    print "DataItemSize : ", result[0]['DataItemSize']
    print "ChannelDataTypeId : ", result[0]['ChannelDataTypeId']

except scriptext.ScriptextError, err:
    print "Error performing the operation : ", err

See About this document... for information on suggesting changes.