To receive data measurements in a MIDlet, you need to identify
the correct sensor and open a connection to that sensor. Sensors are
identified by their URL, which starts with the sensor:
prefix. A sensor connection is opened with the javax.microedition.io.Connector.open
method.
Figure: Opening a sensor connection
An opened sensor can function in two modes:
In synchronous mode, the MIDlet polls the sensor with the SensorConnection.getData
method to receive
the requested data at the necessary intervals.
In asynchronous mode, the MIDlet listens to DataListener.dataReceived
notifications
from the sensor. Listening can start either when the sensor connection
is opened or only when certain preset conditions are met.
After using a sensor, you need to close its sensor connection.
Figure: Lifecycle for an asynchronous sensor connection
For more details, see the following sections: