1// Copyright (C) 2019 The Android Open Source Project
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15namespace chre.power_test;
16
17/// Indicates which of the following messages is being sent to / from the
18/// nanoapp. Use uint as the base type to match the message type in
19/// chreMessageFromHostData.
20enum MessageType : uint {
21  UNSPECIFIED = 0,
22  /// Should be used with TimerMessage
23  TIMER_TEST,
24  /// Should be used with WifiScanMessage
25  WIFI_SCAN_TEST,
26  /// Should be used with GnssLocationMessage
27  GNSS_LOCATION_TEST,
28  /// Should be used with CellQueryMessage
29  CELL_QUERY_TEST,
30  /// Should be used with AudioRequestMessage
31  AUDIO_REQUEST_TEST,
32  /// Should be used with SensorRequestMessage
33  SENSOR_REQUEST_TEST,
34  /// Should be used with BreakItMessage
35  BREAK_IT_TEST,
36  /// Should be used with NanoappResponseMessage
37  NANOAPP_RESPONSE,
38  /// Should be used with GnssMeasurementMessage
39  GNSS_MEASUREMENT_TEST,
40}
41
42/// Represents a message to ask the nanoapp to create a timer that wakes up at
43/// the given interval
44table TimerMessage {
45  enable:bool;
46  wakeup_interval_ns:ulong;
47}
48
49/// All the various WiFi scan types that can be interacted with inside the
50/// nanoapp. The values used here map directly to values from the CHRE API.
51enum WifiScanType : ubyte {
52  ACTIVE = 0,
53  ACTIVE_PLUS_PASSIVE_DFS = 1,
54  PASSIVE = 2,
55  NO_PREFERENCE = 3,
56}
57
58/// All the various WiFi radio chain preferences that can be interacted with
59/// inside the nanoapp. The values used here map directly to values from the
60/// CHRE API.
61enum WifiRadioChain : ubyte {
62  DEFAULT = 0,
63  LOW_LATENCY = 1,
64  LOW_POWER = 2,
65  HIGH_ACCURACY = 3,
66}
67
68/// All the various WiFi channel sets that can be interacted with inside the
69/// nanoapp. The values used here map directly to values from the CHRE API.
70enum WifiChannelSet : ubyte {
71  NON_DFS = 0,
72  ALL = 1,
73}
74
75/// Represents a message to ask the nanoapp to start or stop WiFi scanning and
76/// the scan interval to use if scanning is being started
77table WifiScanMessage {
78  enable:bool;
79  scan_interval_ns:ulong;
80  scan_type:WifiScanType;
81  radio_chain:WifiRadioChain;
82  channel_set:WifiChannelSet;
83}
84
85/// Represents a message to ask the nanoapp to start or stop Gnss location
86/// sampling at the requested interval
87table GnssLocationMessage {
88  enable:bool;
89  scan_interval_millis:uint;
90  min_time_to_next_fix_millis:uint;
91}
92
93/// Represents a message to ask the nanoapp to start or stop querying the cell
94/// modem for the latest cell scan results on the given interval
95table CellQueryMessage {
96  enable:bool;
97  query_interval_ns:ulong;
98}
99
100/// Represents a message to ask the nanoapp to start / stop requesting Audio
101/// data buffered at given interval. Note: If there is more than one audio
102/// source, the nanoapp will only request audio from the first source.
103table AudioRequestMessage {
104  enable:bool;
105  /// The buffer duration is also used as the interval for how often
106  /// the buffer should be delivered to the nanoapp.
107  buffer_duration_ns:ulong;
108}
109
110/// All the various sensors that can be interacted with inside the nanoapp.
111/// The values used here map directly to values from the CHRE API
112enum SensorType : ubyte {
113  UNKNOWN = 0,
114  ACCELEROMETER = 1,
115  INSTANT_MOTION_DETECT = 2,
116  STATIONARY_DETECT = 3,
117  GYROSCOPE = 6,
118  UNCALIBRATED_GYROSCOPE = 7,
119  GEOMAGNETIC_FIELD = 8,
120  UNCALIBRATED_GEOMAGNETIC_FIELD = 9,
121  PRESSURE = 10,
122  LIGHT = 12,
123  PROXIMITY = 13,
124  STEP_DETECT = 23,
125  STEP_COUNTER = 24,
126  UNCALIBRATED_ACCELEROMETER = 55,
127  ACCELEROMETER_TEMPERATURE = 56,
128  GYROSCOPE_TEMPERATURE = 57,
129  GEOMAGNETIC_FIELD_TEMPERATURE = 58,
130}
131
132/// Represents a message to ask the nanoapp to start / stop sampling / batching
133/// a given sensor
134table SensorRequestMessage {
135  enable:bool;
136  sensor:SensorType;
137  sampling_interval_ns:ulong;
138  latency_ns:ulong;
139}
140
141/// Represents a message to enable / disable break-it mode inside the nanoapp.
142/// Break-it mode enables WiFi / GNSS / Cell to be queried every second and
143/// enables all sensors at their fastest sampling rate.
144table BreakItMessage {
145  enable:bool;
146}
147
148/// Indicates whether the nanoapp successfully performed the requested action.
149/// Any failures will be printed to the logs.
150table NanoappResponseMessage {
151  success:bool;
152}
153
154/// Represents a message to ask the nanoapp to start or stop Gnss measurement
155/// sampling at the requested interval
156table GnssMeasurementMessage {
157  enable:bool;
158  min_interval_millis:uint;
159}