Sensor API
The following sensor functionality is provided:
- Start and stop sensor
- Set and unset notification of the sensor data change
- Get current sensor data
For more information about how to use Sensor API, see Device Sensors Guide.
Since: 2.3
Table of Contents
- 1. Type Definitions
- 1.1. MagneticSensorAccuracy
- 1.2. ProximityState
- 1.3. SensorType
- 2. Interfaces
- 2.1. SensorServiceManagerObject
- 2.2. SensorService
- 2.3. Sensor
- 2.4. HRMRawSensor
- 2.5. LightSensor
- 2.6. MagneticSensor
- 2.7. PressureSensor
- 2.8. ProximitySensor
- 2.9. UltravioletSensor
- 2.10. SensorData
- 2.11. SensorHRMRawData
- 2.12. SensorLightData
- 2.13. SensorMagneticData
- 2.14. SensorPressureData
- 2.15. SensorProximityData
- 2.16. SensorUltravioletData
- 2.17. SensorDataSuccessCallback
- 3. Related Feature
- 4. Full WebIDL
Summary of Interfaces and Methods
1. Type Definitions
1.1. MagneticSensorAccuracy
enum MagneticSensorAccuracy { "ACCURACY_UNDEFINED", "ACCURACY_BAD", "ACCURACY_NORMAL", "ACCURACY_GOOD", "ACCURACY_VERYGOOD" };
Since: 2.3
- ACCURACY_UNDEFINED - Corresponds to undefined magnetic sensor accuracy.
- ACCURACY_BAD - Corresponds to bad magnetic sensor accuracy.
- ACCURACY_NORMAL - Corresponds to normal magnetic sensor accuracy.
- ACCURACY_GOOD - Corresponds to good magnetic sensor accuracy.
- ACCURACY_VERYGOOD - Corresponds to very good magnetic sensor accuracy.
1.2. ProximityState
enum ProximityState { "FAR", "NEAR" };
Since: 2.3
- FAR - Corresponds to far proximity state.
- NEAR - corresponds to near proximity state.
1.3. SensorType
enum SensorType { "HRM_RAW", "LIGHT", "MAGNETIC", "PRESSURE", "PROXIMITY", "ULTRAVIOLET" };
Since: 2.3
The sensor types defined by this enumerator are:
- HRM_RAW - HRM sensor
- LIGHT - Light sensor
- MAGNETIC - Magnetic sensor
- PRESSURE - Pressure sensor
- PROXIMITY - Proximity sensor
- ULTRAVIOLET - Ultraviolet sensor
Remark: HRM_RAW is supported since Tizen 2.3.1
2. Interfaces
2.1. SensorServiceManagerObject
[NoInterfaceObject] interface SensorServiceManagerObject { readonly attribute SensorService sensorservice; };
Tizen implements SensorServiceManagerObject;
Since: 2.3
Attributes
-
readonly
SensorService sensorserviceObject representing a sensor service.
Since: 2.3
2.2. SensorService
[NoInterfaceObject] interface SensorService { Sensor getDefaultSensor(SensorType type) raises(WebAPIException); SensorType[] getAvailableSensors() raises(WebAPIException); };
Since: 2.3
Methods
-
getDefaultSensor
-
Gets the default sensor of the device for the given sensor type.
Sensor getDefaultSensor(SensorType type);
Since: 2.3
The supported sensor types are hardware-dependent.
To check if the given type is supported or not, System Info API can be used.-
HRM_RAW - HRM_RAW is supported, if at least one HRM LED sensor type is supported:
tizen.systeminfo.getCapability("http://tizen.org/feature/sensor.heart_rate_monitor.led_green"),
tizen.systeminfo.getCapability("http://tizen.org/feature/sensor.heart_rate_monitor.led_ir"),
tizen.systeminfo.getCapability("http://tizen.org/feature/sensor.heart_rate_monitor.led_red") - LIGHT - tizen.systeminfo.getCapability("http://tizen.org/feature/sensor.photometer")
- MAGNETIC - tizen.systeminfo.getCapability("http://tizen.org/feature/sensor.magnetometer")
- PRESSURE - tizen.systeminfo.getCapability("http://tizen.org/feature/sensor.barometer")
- PROXIMITY - tizen.systeminfo.getCapability("http://tizen.org/feature/sensor.proximity")
- ULTRAVIOLET - tizen.systeminfo.getCapability("http://tizen.org/feature/sensor.ultraviolet")
Parameters:
-
type:
Sensor type to access.
- Conditional privilege: For using HRM_RAW value, privilege http://tizen.org/privilege/healthinfo (public level) is needed since Tizen 2.3.1.
Return value:
-
Sensor:
Default sensor object.
Exceptions:
- WebAPIException
with error type TypeMismatchError, if any input parameter is not compatible with the expected type for that parameter.
with error type UnknownError, if accessing a given sensor type fails because of an unknown error.
with error type NotSupportedError, if the given type is not supported on the device.
with error type SecurityError, this error is only thrown for HRM_RAW sensor type when an application does not have http://tizen.org/privilege/healthinfo privilege in config.xml.
Code example:
var proximityCapability = tizen.systeminfo.getCapability("http://tizen.org/feature/sensor.proximity"); if (proximityCapability === true) { /* Device supports proximity sensor and you can get proximity sensor's data. */ var proximitySensor = tizen.sensorservice.getDefaultSensor("PROXIMITY"); } else { /* If tizen.sensorservice.getDefaultSensor("PROXIMITY") is used, NotSupportedError is thrown. */ console.log("Proximity sensor is not supported on this device"); }
-
HRM_RAW - HRM_RAW is supported, if at least one HRM LED sensor type is supported:
-
getAvailableSensors
-
Gets the available sensor types.
SensorType[] getAvailableSensors();
Since: 2.3
Return value:
-
SensorType[]:
All available sensor types.
Exceptions:
- WebAPIException
with error type UnknownError, if getting available sensor type fails because of an unknown error.
Code example:
var sensorCapabilities = tizen.sensorservice.getAvailableSensors(); console.log("Capable sensor: " + sensorCapabilities[0]);
- WebAPIException
2.3. Sensor
[NoInterfaceObject] interface Sensor { readonly attribute SensorType sensorType; void start(SuccessCallback successCallback, optional ErrorCallback? errorCallback) raises(WebAPIException); void stop() raises(WebAPIException); void setChangeListener(SensorDataSuccessCallback successCallback) raises(WebAPIException); void unsetChangeListener() raises(WebAPIException); };
Since: 2.3
Attributes
-
readonly
SensorType sensorTypeSensor type to monitor the changes.
Since: 2.3
Methods
-
start
-
Starts the sensor.
void start(SuccessCallback successCallback, optional ErrorCallback? errorCallback);
Since: 2.3
The SuccessCallback will be invoked when the first event from the sensor is fired.
The ErrorCallback method is launched with these error types:
- NotSupportedError - if the sensor is not supported on the device.
- UnknownError - if starting the sensor fails because of an unknown error.
Parameters:
- successCallback: Callback method to be invoked when sensor has been successfully started.
- errorCallback [optional] [nullable]: Callback method to be invoked when an error occurs.
Exceptions:
- WebAPIException
with error type TypeMismatchError, if any input parameter is not compatible with the expected type for that parameter.
Code example:
var proximitySensor = tizen.sensorservice.getDefaultSensor("PROXIMITY"); function onsuccessCB() { console.log("The proximity sensor started successfully"); } proximitySensor.start(onsuccessCB);
-
stop
-
Stops the sensor.
void stop();
Since: 2.3
Exceptions:
- WebAPIException
with error type UnknownError, if stopping the sensor fails because of an unknown error.
Code example:
var proximitySensor = tizen.sensorservice.getDefaultSensor("PROXIMITY"); function onsuccessCB() { console.log("Proximity sensor start"); proximitySensor.stop(); } proximitySensor.start(onsuccessCB);
- WebAPIException
-
setChangeListener
-
Registers a listener to retrieve sensor data periodically.
void setChangeListener(SensorDataSuccessCallback successCallback);
Since: 2.3
Note that the setChangeListener() method only registers the listener. The start() method must be called to turn on the sensor, or the sensor data will not change.
Remark: The specified interval is only a suggested interval between sensor measurements. You will get at least one sensor measurement within the interval you specify, but the actual interval between sensor measurements can be affected by other applications and the system. To reduce the system overhead, it is recommended to set the longest interval that you can, because the system usually chooses the shortest interval among all intervals specified.
Parameters:
- successCallback: Callback method to be invoked periodically.
Exceptions:
- WebAPIException
with error type TypeMismatchError, if any input parameter is not compatible with the expected type for that parameter.
with error type UnknownError, if registering the listener fails because of an unknown error.
with error type NotSupportedError, if the batchLatency is not supported on the sensor hardware.
with error type InvalidValuesError, if any of the input parameters contain an invalid value.
Code example:
var lightSensor = tizen.sensorservice.getDefaultSensor("LIGHT"); function onsuccessCB() { console.log("Light sensor start"); } function onchangedCB(sensorData) { console.log("Light level: " + sensorData.lightLevel); } lightSensor.setChangeListener(onchangedCB); lightSensor.start(onsuccessCB);
-
unsetChangeListener
-
Unregisters the sensor data change listener.
void unsetChangeListener();
Since: 2.3
Calling this function has no effect if listener is not set.
Exceptions:
- WebAPIException
with error type UnknownError, if unregistering the listener fails because of an unknown error.
Code example:
var proximitySensor = tizen.sensorservice.getDefaultSensor("PROXIMITY"); function onchangedCB(sensorData) { console.log("Proximity distance: " + sensorData.proximityState); } proximitySensor.setChangeListener(onchangedCB); proximitySensor.unsetChangeListener();
- WebAPIException
2.4. HRMRawSensor
[NoInterfaceObject] interface HRMRawSensor : Sensor { void getHRMRawSensorData(SensorDataSuccessCallback successCallback, optional ErrorCallback? errorCallback) raises(WebAPIException); };
Since: 2.3.1
Methods
-
getHRMRawSensorData
-
Gets the current sensor data.
void getHRMRawSensorData(SensorDataSuccessCallback successCallback, optional ErrorCallback? errorCallback);
Since: 2.3.1
Note that before calling the getHRMRawSensorData() method, the start() method should be called to turn on the sensor.
The ErrorCallback method is launched with these error types:
- ServiceNotAvailableError : If the getHRMRawSensorData method is called without calling the start method.
- UnknownError : An unknown error has occurred.
Privilege level: public
Privilege: http://tizen.org/privilege/healthinfo
Parameters:
- successCallback: Callback method to be invoked when the sensor data has been read.
- errorCallback [optional] [nullable]: Callback method to be invoked when an error occurs.
Exceptions:
- WebAPIException
with error type TypeMismatchError, if any input parameter is not compatible with the expected type for that parameter.
with error type UnknownError, if retrieving the sensor data fails because of an unknown error.
with error type SecurityError, if the application does not have the privilege to use this function.
Code example:
var HRMrawsensor = tizen.sensorservice.getDefaultSensor("HRM_RAW"); function onGetSuccessCB(sensorData) { console.log("HRMRaw light intensity: " + sensorData.lightIntensity); } function onerrorCB(error) { console.log("Error occurred"); } function onsuccessCB() { console.log("HRMRaw sensor start"); HRMrawsensor.getHRMRawSensorData(onGetSuccessCB, onerrorCB); } HRMrawsensor.start(onsuccessCB);
2.5. LightSensor
[NoInterfaceObject] interface LightSensor : Sensor { void getLightSensorData(SensorDataSuccessCallback successCallback, optional ErrorCallback? errorCallback) raises(WebAPIException); };
Since: 2.3
Methods
-
getLightSensorData
-
Gets the current sensor data.
void getLightSensorData(SensorDataSuccessCallback successCallback, optional ErrorCallback? errorCallback);
Since: 2.3
Note that before calling the getLightSensorData() method, the start() method should be called to turn on the sensor.
The ErrorCallback method is launched with these error types:
- ServiceNotAvailableError : If the getLightSensorData() method is called without first calling the start() method
- UnknownError : An unknown error has occurred
Parameters:
- successCallback: Callback method to be invoked when the sensor data has been read.
- errorCallback [optional] [nullable]: Callback method to be invoked when an error occurs.
Exceptions:
- WebAPIException
with error type TypeMismatchError, if any input parameter is not compatible with the expected type for that parameter.
Code example:
var lightSensor = tizen.sensorservice.getDefaultSensor("LIGHT"); function onGetSuccessCB(sensorData) { console.log("Light level: " + sensorData.lightLevel); } function onerrorCB(error) { console.log("Error occurred"); } function onsuccessCB() { console.log("Sensor start"); lightSensor.getLightSensorData(onGetSuccessCB, onerrorCB); } lightSensor.start(onsuccessCB);
2.6. MagneticSensor
[NoInterfaceObject] interface MagneticSensor : Sensor { void getMagneticSensorData(SensorDataSuccessCallback successCallback, optional ErrorCallback? errorCallback) raises(WebAPIException); };
Since: 2.3
Methods
-
getMagneticSensorData
-
Gets the current sensor data.
void getMagneticSensorData(SensorDataSuccessCallback successCallback, optional ErrorCallback? errorCallback);
Since: 2.3
Note that before calling the getMagneticSensorData() method, the start() method should be called to turn on the sensor.
The ErrorCallback method is launched with these error types:
- ServiceNotAvailableError : If the getMagneticSensorData() method is called without first calling the start() method
- UnknownError : An unknown error has occurred
Parameters:
- successCallback: Callback method to be invoked when the sensor data has been read.
- errorCallback [optional] [nullable]: Callback method to be invoked when an error occurs.
Exceptions:
- WebAPIException
with error type TypeMismatchError, if any input parameter is not compatible with the expected type for that parameter.
Code example:
var magneticSensor = tizen.sensorservice.getDefaultSensor("MAGNETIC"); function onGetSuccessCB(sensorData) { console.log("Magnetic field of the X axis: " + sensorData.x); console.log("Magnetic field of the Y axis: " + sensorData.y); console.log("Magnetic field of the Z axis: " + sensorData.z); } function onerrorCB(error) { console.log("Error occurred"); } function onsuccessCB() { console.log("Sensor start"); magneticSensor.getMagneticSensorData(onGetSuccessCB, onerrorCB); } magneticSensor.start(onsuccessCB);
2.7. PressureSensor
[NoInterfaceObject] interface PressureSensor : Sensor { void getPressureSensorData(SensorDataSuccessCallback successCallback, optional ErrorCallback? errorCallback) raises(WebAPIException); };
Since: 2.3
Methods
-
getPressureSensorData
-
Gets the current sensor data.
void getPressureSensorData(SensorDataSuccessCallback successCallback, optional ErrorCallback? errorCallback);
Since: 2.3
Note that the start() method should be called before calling the getPressureSensorData() method to turn on the sensor.
The ErrorCallback method is launched with these error types:
- ServiceNotAvailableError : If the getPressureSensorData() method is called without first calling the start() method
- UnknownError : An unknown error has occurred
Parameters:
- successCallback: Callback method to be invoked when the sensor data has been read.
- errorCallback [optional] [nullable]: Callback method to be invoked when an error occurs.
Exceptions:
- WebAPIException
with error type TypeMismatchError, if any input parameter is not compatible with the expected type for that parameter.
Code example:
var pressureSensor = tizen.sensorservice.getDefaultSensor("PRESSURE"); function onGetSuccessCB(sensorData) { console.log("Pressure: " + sensorData.pressure); } function onerrorCB(error) { console.log("Error occurred"); } function onsuccessCB() { console.log("Sensor start"); pressureSensor.getPressureSensorData(onGetSuccessCB, onerrorCB); } pressureSensor.start(onsuccessCB);
2.8. ProximitySensor
[NoInterfaceObject] interface ProximitySensor : Sensor { void getProximitySensorData(SensorDataSuccessCallback successCallback, optional ErrorCallback? errorCallback) raises(WebAPIException); };
Since: 2.3
Methods
-
getProximitySensorData
-
Gets the current sensor data.
void getProximitySensorData(SensorDataSuccessCallback successCallback, optional ErrorCallback? errorCallback);
Since: 2.3
Note that before calling the getProximitySensorData() method, the start() method should be called to turn on the sensor.
The ErrorCallback method is launched with these error types:
- ServiceNotAvailableError : If the getProximitySensorData() method is called without first calling the start() method
- UnknownError : An unknown error has occurred
Parameters:
- successCallback: Callback method to be invoked when the sensor data has been read.
- errorCallback [optional] [nullable]: Callback method to be invoked when an error occurs.
Exceptions:
- WebAPIException
with error type TypeMismatchError, if any input parameter is not compatible with the expected type for that parameter.
Code example:
var proximitySensor = tizen.sensorservice.getDefaultSensor("PROXIMITY"); function onGetSuccessCB(sensorData) { console.log("Proximity state: " + sensorData.proximityState); } function onerrorCB(error) { console.log("Error occurred"); } function onsuccessCB() { console.log("Proximity sensor start"); proximitySensor.getProximitySensorData(onGetSuccessCB, onerrorCB); } proximitySensor.start(onsuccessCB);
2.9. UltravioletSensor
[NoInterfaceObject] interface UltravioletSensor : Sensor { void getUltravioletSensorData(SensorDataSuccessCallback successCallback, optional ErrorCallback? errorCallback) raises(WebAPIException); };
Since: 2.3
Methods
-
getUltravioletSensorData
-
Gets the current sensor data.
void getUltravioletSensorData(SensorDataSuccessCallback successCallback, optional ErrorCallback? errorCallback);
Since: 2.3
Note that before calling the getUltravioletSensorData() method, the start() method should be called to turn on the sensor.
The ErrorCallback method is launched with these error types:
- ServiceNotAvailableError : If the getUltravioletSensorData() method is called without first calling the start() method
- UnknownError : An unknown error has occurred
Parameters:
- successCallback: Callback method to be invoked when the sensor data has been read.
- errorCallback [optional] [nullable]: Callback method to be invoked when an error occurs.
Exceptions:
- WebAPIException
with error type TypeMismatchError, if any input parameter is not compatible with the expected type for that parameter.
Code example:
var ultravioletSensor = tizen.sensorservice.getDefaultSensor("ULTRAVIOLET"); function onGetSuccessCB(sensorData) { console.log("Ultraviolet level: " + sensorData.ultravioletLevel); } function onerrorCB(error) { console.log("Error occurred"); } function onsuccessCB() { console.log("Ultraviolet sensor start"); ultravioletSensor.getUltravioletSensorData(onGetSuccessCB, onerrorCB); } ultravioletSensor.start(onsuccessCB);
2.10. SensorData
[NoInterfaceObject] interface SensorData { };
Since: 2.3
2.11. SensorHRMRawData
[NoInterfaceObject] interface SensorHRMRawData : SensorData { readonly attribute DOMString lightType; readonly attribute unsigned long lightIntensity; };
Since: 2.3.1
Attributes
-
readonly
DOMString lightTypeHRM sensor light type.
The following values are supported:
- LED_IR - The infrared spectrum
- LED_RED - The red light spectrum
- LED_GREEN - The green light spectrum
Since: 2.3.1
-
readonly
unsigned long lightIntensityHRM sensor light intensity measures the light intensity that is reflected from a blood vessel. The changes in the reported value represent blood volume changes in the microvascular bed of the tissue, and can be used to estimate heart rate.
Since: 2.3.1
2.12. SensorLightData
[NoInterfaceObject] interface SensorLightData : SensorData { readonly attribute double lightLevel; };
Since: 2.3
Attributes
-
readonly
double lightLevelAmbient light level in lux.
Since: 2.3
2.13. SensorMagneticData
[NoInterfaceObject] interface SensorMagneticData : SensorData { readonly attribute double x; readonly attribute double y; readonly attribute double z; readonly attribute MagneticSensorAccuracy accuracy; };
Since: 2.3
Attributes
-
readonly
double xAmbient magnetic field of the X axis in microtesla (µT).
Since: 2.3
-
readonly
double yAmbient magnetic field of the Y axis in microtesla (µT).
Since: 2.3
-
readonly
double zAmbient magnetic field of the Z axis in microtesla (µT).
Since: 2.3
-
readonly
MagneticSensorAccuracy accuracyAccuracy of magnetic sensor data.
For increasing the accuracy, wave the device around in the air in figure-eight patterns.
Since: 2.3
2.14. SensorPressureData
[NoInterfaceObject] interface SensorPressureData : SensorData { readonly attribute double pressure; };
Since: 2.3
Attributes
-
readonly
double pressurePressure in hectopascal (hPa).
Since: 2.3
2.15. SensorProximityData
[NoInterfaceObject] interface SensorProximityData : SensorData { readonly attribute ProximityState proximityState; };
Since: 2.3
Attributes
-
readonly
ProximityState proximityStateProximity state.
Since: 2.3
2.16. SensorUltravioletData
[NoInterfaceObject] interface SensorUltravioletData : SensorData { readonly attribute long ultravioletLevel; };
Since: 2.3
Attributes
-
readonly
long ultravioletLevelUltraviolet index.
The ultraviolet index is an international standard measurement of the strength of ultraviolet radiation from the sun. The ultravioletLevel ranges from 0 to 15.
Since: 2.3
2.17. SensorDataSuccessCallback
[Callback=FunctionOnly, NoInterfaceObject] interface SensorDataSuccessCallback { void onsuccess(optional SensorData? sensorData); };
Since: 2.3
Methods
-
onsuccess
-
Called periodically.
void onsuccess(optional SensorData? sensorData);
Since: 2.3
Parameters:
- sensorData [optional] [nullable]: Current sensor data.
3. Related Feature
To guarantee that the Heart Rate Monitor application runs on a device with a heart rate monitor, declare the following feature requirements in the config file:
To guarantee that the light sensor application runs on a device with a photometer (light) sensor, declare the following feature requirement in the config file:
To guarantee that the magnetic sensor application runs on a device with a magnetic sensor, declare the following feature requirement in the config file:
To guarantee that the barometer(pressure) sensor application runs on a device with a barometric (pressure) sensor, declare the following feature requirement in the config file:
To guarantee that the proximity sensor application runs on a device with a proximity sensor, declare the following feature requirement in the config file:
To guarantee that the UV sensor application runs on a device with a UV sensor, declare the following feature requirement in the config file:
4. Full WebIDL
module Sensor { enum MagneticSensorAccuracy { "ACCURACY_UNDEFINED", "ACCURACY_BAD", "ACCURACY_NORMAL", "ACCURACY_GOOD", "ACCURACY_VERYGOOD" }; enum ProximityState { "FAR", "NEAR" }; enum SensorType { "HRM_RAW", "LIGHT", "MAGNETIC", "PRESSURE", "PROXIMITY", "ULTRAVIOLET" }; Tizen implements SensorServiceManagerObject; [NoInterfaceObject] interface SensorServiceManagerObject { readonly attribute SensorService sensorservice; }; [NoInterfaceObject] interface SensorService { Sensor getDefaultSensor(SensorType type) raises(WebAPIException); SensorType[] getAvailableSensors() raises(WebAPIException); }; [NoInterfaceObject] interface Sensor { readonly attribute SensorType sensorType; void start(SuccessCallback successCallback, optional ErrorCallback? errorCallback) raises(WebAPIException); void stop() raises(WebAPIException); void setChangeListener(SensorDataSuccessCallback successCallback) raises(WebAPIException); void unsetChangeListener() raises(WebAPIException); }; [NoInterfaceObject] interface HRMRawSensor : Sensor { void getHRMRawSensorData(SensorDataSuccessCallback successCallback, optional ErrorCallback? errorCallback) raises(WebAPIException); }; [NoInterfaceObject] interface LightSensor : Sensor { void getLightSensorData(SensorDataSuccessCallback successCallback, optional ErrorCallback? errorCallback) raises(WebAPIException); }; [NoInterfaceObject] interface MagneticSensor : Sensor { void getMagneticSensorData(SensorDataSuccessCallback successCallback, optional ErrorCallback? errorCallback) raises(WebAPIException); }; [NoInterfaceObject] interface PressureSensor : Sensor { void getPressureSensorData(SensorDataSuccessCallback successCallback, optional ErrorCallback? errorCallback) raises(WebAPIException); }; [NoInterfaceObject] interface ProximitySensor : Sensor { void getProximitySensorData(SensorDataSuccessCallback successCallback, optional ErrorCallback? errorCallback) raises(WebAPIException); }; [NoInterfaceObject] interface UltravioletSensor : Sensor { void getUltravioletSensorData(SensorDataSuccessCallback successCallback, optional ErrorCallback? errorCallback) raises(WebAPIException); }; [NoInterfaceObject] interface SensorData { }; [NoInterfaceObject] interface SensorHRMRawData : SensorData { readonly attribute DOMString lightType; readonly attribute unsigned long lightIntensity; }; [NoInterfaceObject] interface SensorLightData : SensorData { readonly attribute double lightLevel; }; [NoInterfaceObject] interface SensorMagneticData : SensorData { readonly attribute double x; readonly attribute double y; readonly attribute double z; readonly attribute MagneticSensorAccuracy accuracy; }; [NoInterfaceObject] interface SensorPressureData : SensorData { readonly attribute double pressure; }; [NoInterfaceObject] interface SensorProximityData : SensorData { readonly attribute ProximityState proximityState; }; [NoInterfaceObject] interface SensorUltravioletData : SensorData { readonly attribute long ultravioletLevel; }; [Callback=FunctionOnly, NoInterfaceObject] interface SensorDataSuccessCallback { void onsuccess(optional SensorData? sensorData); }; };