Chromium Code Reviews| Index: device/generic_sensor/public/interfaces/sensor.mojom |
| diff --git a/device/generic_sensor/public/interfaces/sensor.mojom b/device/generic_sensor/public/interfaces/sensor.mojom |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..8d39646ce90b0509553aa8b391354739c857102a |
| --- /dev/null |
| +++ b/device/generic_sensor/public/interfaces/sensor.mojom |
| @@ -0,0 +1,70 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +module device.mojom; |
| + |
| +// Types of supported sensors |
| +enum SensorType { |
| + FIRST = 1, |
| + AMBIENT_LIGHT = FIRST, |
| + PROXIMITY, |
| + ACCELEROMETER, |
|
timvolodine
2016/08/18 22:52:14
maybe distinguish accelerometer with including/exc
Mikhail
2016/08/19 09:29:55
yeah, this list will be updated when implementatio
|
| + GYROSCOPE, |
| + PRESSURE, |
| + LAST = PRESSURE // Note: LAST is also equal to the types count. |
| +}; |
| + |
| +// Reporting mode supported by the Sensor. |
| +// ON_CHANGE - client will be notified through OnSensorReadingChanged() signal |
| +// whenever sensor reading is changed. |
| +// CONTINUOUS - sensor will continuously update its reading with frequency |
| +// specified in SensorConfiguration.frequency. |
| +// OnSensorReadingChanged() signal is not sent to the client for |
| +// sensors with CONTINUOUS reporting mode. |
| +enum ReportingMode { |
| + ON_CHANGE, |
| + CONTINUOUS |
| +}; |
| + |
| +struct SensorConfiguration { |
| + // Requested frequency in Hz (max is 60 Hz). |
| + double frequency; |
| + // TODO(shalamov): Add map<string, union> for sensor specific configuration. |
| +}; |
| + |
| +// Interface for controlling the Sensor. |
| +interface Sensor { |
| + // Requests sensor to start reading sensor data with specified |
| + // SensorConfiguration. |
| + // Sensor holds the list of added configurations and it always polls |
| + // the platform (and updates the shared buffer) at the maxiumum frequency |
| + // among the obtained from the stored configurations, so that all clients |
| + // can have sensor data in time. |
| + AddConfiguration(SensorConfiguration configuration) => (bool success); |
|
timvolodine
2016/08/18 22:52:14
maybe mention that this can fail if the config is
Mikhail
2016/08/19 09:29:55
Done.
|
| + |
| + // Requests sensor to stop reading sensor data for specified |
| + // SensorConfiguration. |
| + // This call excludes |configuration| from the Sensor's list making it |
| + // reconsider the the shared buffer udpate frequency. If there are no |
| + // configurations left in the Sensor's configuration list it stops polling |
| + // sensor data from the platform and update the shared buffer. |
| + RemoveConfiguration(SensorConfiguration configuration) => (bool success); |
|
timvolodine
2016/08/18 22:52:14
not sure if a return value (=> bool success) is us
Mikhail
2016/08/19 09:29:55
Go to 'errored' state.
|
| + |
| + // Temporary suppresses sensor reading changes notification. |
| + SuspendNotification(); |
|
timvolodine
2016/08/18 22:52:14
maybe just "Suspend()"? I understand this will sto
Mikhail
2016/08/19 09:29:55
Agree 'Suspend' is better as this call would affec
|
| + |
| + // Resumes previously suspended sensor reading changes notification. |
| + ResumeNotification(); |
| +}; |
| + |
| +// Interface that client of the Sensor interface must implement to observe |
| +// sensor reading changes and error conditions. |
| +interface SensorClient { |
| + // Signals SensorClient when there is an error. |
| + RaiseError(); |
| + |
| + // Signals SensorClient when reading has been changed (only for sensors with |
| + // ReportingMode::ON_CHANGE). |
| + SensorReadingChanged(); |
| +}; |