com.sonyericsson.extras.liveware.aef.sensor
Class Sensor

java.lang.Object
  extended by com.sonyericsson.extras.liveware.aef.sensor.Sensor

public class Sensor
extends java.lang.Object

Sensor API is a part of the Smart Extension APIs

Overview

The Sensor API is used to send accessory sensor data from a host application to an accessory extension. The API can be used by any registered extension.

Sensor data is sent over a LocalSocket. In order to start communication the extension should setup a LocalServerSocket android.net.LocalServerSocket in listening mode and send the Sensor.Intents.SENSOR_REGISTER_LISTENER_INTENT intent. The capability API can be used to query the host application for supported sensors. If multiple sensors are used, multiple LocalServerSocket objects must also be used since one sensor is bound to exactly one LocalServerSocket.

Sensor data format

The sensor data is sent from the host application over a LocalSocket and can be accessed through an InputStream. The data has the following format:
  1. Byte 0 - 3 Total length of the data package
  2. Byte 4 - 7 Accuracy. For more information see Sensor.SensorAccuracy
  3. Byte 8 - 15 Timestamp. The time in nanosecond at which the event happened
  4. Byte 16 - 19 Length of sensor values in bytes
  5. Byte 20 - nn Sensor values. This should be interpreted as an array of float values, each float value is 4 bytes long
The length and contents of the values array depends on which sensor type is being monitored.


Nested Class Summary
static interface Sensor.Intents
          Intents sent between Sensor Extensions and Accessory Host Applications
static interface Sensor.SensorAccuracy
          Interface used to define constants for sensor accuracy.
static interface Sensor.SensorApiErrorCodes
          Interface used to define constants for sensor error codes sent from the host application
static interface Sensor.SensorInterruptMode
          Interface used to define constants for sensor interrupt mode.
static interface Sensor.SensorRates
          Interface used to define constants for sensor rates.
 
Field Summary
static java.lang.String SENSOR_TYPE_ACCELEROMETER
          Constant defining the sensor type Accelerometer.
static java.lang.String SENSOR_TYPE_LIGHT
          Constant defining the sensor type Light.
 
Constructor Summary
protected Sensor()
           
 
Method Summary
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SENSOR_TYPE_ACCELEROMETER

public static final java.lang.String SENSOR_TYPE_ACCELEROMETER
Constant defining the sensor type Accelerometer. Sensor data is sent as an array of 3 float values representing the acceleration on the x-axis, y-axis and z-axis respectively. All values are in SI units (m/s^2) For more information about the accelerometer sensor type, see android.hardware.Sensor#TYPE_ACCELEROMETER

See Also:
Constant Field Values

SENSOR_TYPE_LIGHT

public static final java.lang.String SENSOR_TYPE_LIGHT
Constant defining the sensor type Light. Sensor data is sent as one float value representing the light level in SI lux units. For more information about the light sensor type, see android.hardware.Sensor#TYPE_LIGHT

See Also:
Constant Field Values
Constructor Detail

Sensor

protected Sensor()