Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(175)

Side by Side Diff: device/generic_sensor/public/interfaces/sensor.mojom

Issue 2144623003: [sensors] Introduce Generic Sensor API interfaces (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comments from Tim and Ken Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 module device.mojom;
6
7 // Types of supported sensors
8 enum SensorType {
9 FIRST = 1,
10 AMBIENT_LIGHT = FIRST,
11 PROXIMITY,
12 ACCELEROMETER,
13 GYROSCOPE,
14 PRESSURE,
15 LAST = PRESSURE // Note: LAST is also equal to the types count.
16 };
17
18 // Reporting mode supported by the Sensor.
19 // ON_CHANGE - client will be notified through OnSensorReadingChanged() signal
20 // whenever sensor reading is changed.
21 // CONTINUOUS - sensor will continuously update its reading with frequency
22 // specified in SensorConfiguration.frequency.
23 // OnSensorReadingChanged() signal is not sent to the client for
24 // sensors with CONTINUOUS reporting mode.
25 enum ReportingMode {
26 ON_CHANGE,
27 CONTINUOUS
28 };
29
30 struct SensorConfiguration {
31 // Requested frequency in Hz (max is 60 Hz).
32 double frequency;
33 // TODO(shalamov): Add map<string, union> for sensor specific configuration.
34 };
35
36 // Interface for controlling the Sensor.
37 interface Sensor {
38 // Requests sensor to start reading sensor data with specified
39 // SensorConfiguration.
40 // Sensor holds the list of added configurations and it always polls
41 // the platform (and updates the shared buffer) at the maxiumum frequency
42 // among the obtained from the stored configurations, so that all clients
43 // can have sensor data in time.
44 // Returns 'true' if |configuration| was successfully added.
45 // Returns 'false' if |configuration| could not be added (is invalid
46 // or not supported).
47 AddConfiguration(SensorConfiguration configuration) => (bool success);
48
49 // Requests sensor to stop reading sensor data for specified
50 // SensorConfiguration.
51 // This call excludes |configuration| from the Sensor's list making it
52 // reconsider the the shared buffer udpate frequency. If there are no
53 // configurations left in the Sensor's configuration list it stops polling
54 // sensor data from the platform and update the shared buffer.
55 // Returns 'true' if |configuration| was successfully removed;
56 // returns 'false' if |configuration| could not be removed due to an error
57 // (e.g. |configuration| is not present in the Sensor's list).
timvolodine 2016/08/19 16:02:30 nit: |configuration| not present in the list seems
Mikhail 2016/08/19 19:10:02 Agree, but returning extra status will make it saf
58 RemoveConfiguration(SensorConfiguration configuration) => (bool success);
59
60 // Temporary suppresses sensor reading changes notification and deactivates
61 // all the previously added configurations for current instance.
62 Suspend();
63
64 // Resumes previously suspended sensor reading changes notification and
65 // activates all the previously added configurations for current instance.
66 Resume();
67 };
68
69 // Interface that client of the Sensor interface must implement to observe
70 // sensor reading changes and error conditions.
71 interface SensorClient {
72 // Signals SensorClient when there is an error.
73 RaiseError();
74
75 // Signals SensorClient when reading has been changed (only for sensors with
76 // ReportingMode::ON_CHANGE).
77 SensorReadingChanged();
78 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698