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

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

Issue 2865263002: Move //device/generic_sensor to be part of the internal implementation of the Device Service. (Closed)
Patch Set: code rebase Created 3 years, 7 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 // When adding new sensor type, update the documentation of sensor data values
9 // in SensorReading struct at sensor_reading.h file.
10 enum SensorType {
11 FIRST = 1,
12 AMBIENT_LIGHT = FIRST,
13 PROXIMITY,
14 ACCELEROMETER,
15 LINEAR_ACCELERATION,
16 GYROSCOPE,
17 MAGNETOMETER,
18 PRESSURE,
19 ABSOLUTE_ORIENTATION,
20 RELATIVE_ORIENTATION,
21 LAST = RELATIVE_ORIENTATION // Note: LAST is also equal to the types count.
22 };
23
24 // Reporting mode supported by the Sensor.
25 // ON_CHANGE - client will be notified through OnSensorReadingChanged() signal
26 // whenever sensor reading is changed.
27 // CONTINUOUS - sensor will continuously update its reading with frequency
28 // specified in SensorConfiguration.frequency.
29 // OnSensorReadingChanged() signal is not sent to the client for
30 // sensors with CONTINUOUS reporting mode.
31 enum ReportingMode {
32 ON_CHANGE,
33 CONTINUOUS
34 };
35
36 struct SensorConfiguration {
37 // Maximum allowed frequency is 60 Hz.
38 const double kMaxAllowedFrequency = 60.0;
39
40 // Requested frequency in Hz.
41 double frequency;
42 // TODO(shalamov): Add map<string, union> for sensor specific configuration.
43 };
44
45 // Interface for controlling the Sensor.
46 interface Sensor {
47
48 // Requests sensor to provide its default configuration.
49 GetDefaultConfiguration() => (SensorConfiguration configuration);
50
51 // Requests sensor to start reading sensor data with specified
52 // SensorConfiguration.
53 // Sensor holds the list of added configurations and it always polls
54 // the platform (and updates the shared buffer) at the maxiumum frequency
55 // among the obtained from the stored configurations, so that all clients
56 // can have sensor data in time.
57 // Returns 'true' if |configuration| was successfully added.
58 // Returns 'false' if |configuration| could not be added (is invalid
59 // or not supported).
60 AddConfiguration(SensorConfiguration configuration) => (bool success);
61
62 // Requests sensor to stop reading sensor data for specified
63 // SensorConfiguration.
64 // This call excludes |configuration| from the Sensor's list making it
65 // reconsider the the shared buffer udpate frequency. If there are no
66 // configurations left in the Sensor's configuration list it stops polling
67 // sensor data from the platform and update the shared buffer.
68 // Returns 'true' if |configuration| was successfully removed;
69 // returns 'false' if |configuration| could not be removed due to an error
70 // (e.g. |configuration| is not present in the Sensor's list).
71 RemoveConfiguration(SensorConfiguration configuration) => (bool success);
72
73 // Temporary suppresses sensor reading changes notification and deactivates
74 // all the previously added configurations for current instance.
75 Suspend();
76
77 // Resumes previously suspended sensor reading changes notification and
78 // activates all the previously added configurations for current instance.
79 Resume();
80 };
81
82 // Interface that client of the Sensor interface must implement to observe
83 // sensor reading changes and error conditions.
84 interface SensorClient {
85 // Signals SensorClient when there is an error.
86 RaiseError();
87
88 // Signals SensorClient when reading has been changed (only for sensors with
89 // ReportingMode::ON_CHANGE).
90 SensorReadingChanged();
91 };
OLDNEW
« no previous file with comments | « device/generic_sensor/public/interfaces/OWNERS ('k') | device/generic_sensor/public/interfaces/sensor.typemap » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698