Mobile Sensor API Version 1.2

Package javax.microedition.sensor

This package provides the classes and interfaces of the Mobile Sensor API mandatory part.

See:
          Description

Interface Summary
Channel Objects implementing the Channel interface provide information about the channel and maintain conditions for monitoring the data.
ChannelInfo The object implementing this interface provides information about the data properties of the channel.
Condition An application can set conditions to have the data monitored and receive a notification when the data meets the defined condition.
ConditionListener An interface implemented by the application to receive notifications when the monitored data meets the condition defined by the application.
Data This interface represents data values retrieved from one channel of a sensor.
DataAndErrorListener The DataAndErrorListener interface is implemented by the application to receive data and errors from the sensor.
DataListener The DataListener interface is implemented by the application to receive data from the sensor.
SensorConnection The SensorConnection is an abstraction of an actual sensor.
SensorInfo SensorInfo contains a variety of information about the physical sensor.
SensorListener The SensorListener represents a listener that receives notifications when the availability of the sensor changes.
 

Class Summary
LimitCondition LimitCondition is a Condition intended for numeric data to set various kind of conditions.
MeasurementRange This class represents the measurement range of one channel of the sensor.
ObjectCondition The ObjectCondition checks the equality of the set limit to the measured data value.
RangeCondition RangeCondition checks if the measured data value is within the defined range.
SensorManager The SensorManager class is used to find sensors and monitor their availability.
Unit The Unit represents the unit of the measured data values.
 

Package javax.microedition.sensor Description

This package provides the classes and interfaces of the Mobile Sensor API mandatory part.

The main functionality of Mobile Sensor API is to fetch sensor data and monitor it based on set conditions. The appropriate sensor has to be found, or known beforehand, to be able to open the connection. Data can be received once the connection is opened.

An application can search for a desired sensor based on a quantity and a context type. The quantity is the property the sensor is measuring. The context type represents the environment where the measurement is taken, such as "ambient" or "device". The SensorManager acts as a sensor finder. findSensors() methods of SensorManager return an array of matching SensorInfo objects. SensorInfo contains the information of sensor properties such as the model, the vendor, and maximum sampling rate.

The classes and the interfaces of the javax.microedition.sensor package are presented in the following figure.

The class diagram of the sensor package

Figure 1: Class diagram of javax.microedition.sensor package

After selecting the desired sensor based on information in SensorInfo objects, the sensor URL can be retrieved from the SensorInfo object with the getUrl() method. The sensor URL is used to create the SensorConnection via the Connector class. The Connector.open() method returns a SensorConnection instance providing an active connection to the sensor. If the given URL is mapping to multiple sensors then Connector MAY freely decide which matching sensor to use for the returned SensorConnection.

An open SensorConnection instance can be used to receive the measurements. The data can be retrieved either synchronously or asynchronously. Synchronous data retrieval is done by calling the SensorConnection.getData() method. The asynchronous mode requires applications to register as DataListener objects in order to receive dataReceived() notifications of collected data.

If the sensor measures several values simultaneously, values from each channel are stored to separate Data objects. Channels represent different dimensions of the measurement. For example, in 3D acceleration there are three dimensions - axis x, y, and z; these are different channels. However most of the sensors are such that they are measuring just one property, so only one channel is needed. There are two classes, ChannelInfo and Channel related to the channel of the sensor. The ChannelInfo defines the properties of the data, for example, accuracy, a unit, and a scale. The Channel maintains Condition objects attached to one channel of the sensor.

Conditions are used for monitoring the sensor data. The application sets the needed Conditions. There are three alternatives provided in this API: LimitCondition, RangeCondition, and ObjectCondition. When Condition is met, the registered ConditionListener receives conditionMet notification.

An implementation of this API may either contain support for a fixed set of sensors, or be extensible to support new types of sensors. However, the possible extension mechanism to install support for new types of sensors is beyond the scope of this API specification.


Mobile Sensor API Version 1.2

Copyright © 2005-2008 Nokia Corporation. All Rights Reserved.
Java is a trademark of Sun Microsystems, Inc.