SmartEyeglass SDK public class

Sensor

extends java.lang.Object
  1. java.lang.Object
  2. com.sonyericsson.extras.liveware.aef.sensor.Sensor

Class Overview

Sensor API is a part of the Smart Extension APIs.

The Sensor API is used to send accessory sensor data from a host application to an accessory extension.

When a host application registers its capabilities, it will declare if it supports the Sensor API and what sensors it exposes. Extensions can use the Registration API to query host applications for supported sensors.

In order to use this API, an application must have registered itself properly in the registration content provider, see Registration API.

How to register a listener

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_REGISTER_LISTENER_INTENT intent. The Registration 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. When an extension registers a listener it also specifies what sample rate it wants to have.

Some sensors support interrupt mode. They can be configured to only send sensor data when new values are available. The interrupt flag is part of the sensor data registration Intent.

To unregister a listener the extension must send the SENSOR_UNREGISTER_LISTENER_INTENT.

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:

  • Byte 0 - 3 Total length of the data package
  • Byte 4 - 7 Accuracy. For more information see Sensor.SensorAccuracy
  • Byte 8 - 15 Timestamp. The time in nanosecond at which the event happened
  • Byte 16 - 19 Length of sensor values in bytes
  • Byte 20 - nn Sensor values. This should be interpreted as an array of float values, each float value is 4 bytes
The length and contents of the values array depends on which sensor type is being monitored. The data format is identical to a standard Android SensorEvent.

Summary

Nested Classes
interface Sensor.Intents Intents sent between extensions and host applications either using the broadcast queue or Tunnel.
interface Sensor.SensorRates Interface used to define constants for sensor rates.
interface Sensor.SensorAccuracy Interface used to define constants for sensor accuracy.
interface Sensor.SensorInterruptMode Interface used to define constants for sensor interrupt mode.
interface Sensor.SensorApiErrorCodes Interface used to define constants for sensor error codes sent from the host application
Constants
java.lang.String SENSOR_TYPE_ACCELEROMETER Deprecated.
java.lang.String SENSOR_TYPE_LIGHT Deprecated.
Protected Constructors
Sensor()

Constants

public static final java.lang.String SENSOR_TYPE_ACCELEROMETER

Deprecated.

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 TYPE_ACCELEROMETER

See Also

Constant Value: "Accelerometer"

public static final java.lang.String SENSOR_TYPE_LIGHT

Deprecated.

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 TYPE_LIGHT

See Also

Constant Value: "Light"

Protected Constructors

protected Sensor()