Modern Apps git
git clone https://git.maproj.org/Modern-Apps.git
translate ▾

Modern-Apps.git / auto / protocol / src / main / proto / gal / sensors.proto

sensors.proto296 lines · 9.8 KiBRaw
1// Google Automotive Link sensor channel (service 7, SENSOR_SOURCE): the car
2// streams readings, the phone subscribes.
3//
4// Direction (auto/docs/FINDINGS.md section 2, the `rvb` endpoint): phone ->
5// HU SensorRequest (0x8001, `xnu` {1 sensor_type, 2 min_update_period},
6// synchronous with a 2000 ms timeout, -1 unsubscribes); HU -> phone
7// SensorResponse (0x8002, `xnv`), SensorBatch (0x8003, `xnr`) and SensorError
8// (0x8004, `xns`). 0x8004 here is SensorError, NOT MediaAck: scope every
9// parse by channel id (VideoSinkChannel and InputChannel already do; the 0x04
10// CONTROL frame flag never enters routing -- HANDOFF.md section 9).
11//
12// Provenance: the 26 sensor-type names and their order come from the APK's
13// `xny` enum via the `rvb.j()` dumper (FINDINGS.md section 2), numbered
14// 1-based in that order. The `xnu` field numbers (1, 2) are from the
15// teardown; every other field number below is MA sender-defined -- the
16// teardown never recovered the `xnv`/`xnr`/`xns` layouts. Exact-bytes tests
17// pin OUR numbering so an accidental renumber fails here, not at a DHU that
18// silently ignores us. If the teardown ever recovers those layouts, re-pin
19// this file against them like gal/input.proto.
20//
21// Stub phase (Phase 5): the phone subscribes to LOCATION, NIGHT_MODE, SPEED
22// and DRIVING_STATUS_DATA only -- parked, night-follows-phone, last-known
23// location, speed 0 -- and observes whatever batches come back. Full live
24// values (phone GPS feed, maps wiring) land with Phase 6 maps-dev through
25// the SensorChannel onValues seam.
26
27syntax = "proto2";
28
29package gal;
30
31option java_package = "com.vayunmathur.auto.protocol.gal";
32option java_multiple_files = true;
33
34// `xny`, in dumper order. Names are the FINDINGS.md names, not aasdk's.
35enum SensorType {
36 LOCATION = 1;
37 COMPASS = 2;
38 SPEED = 3;
39 RPM = 4;
40 ODOMETER = 5;
41 FUEL = 6;
42 PARKING_BRAKE = 7;
43 GEAR = 8;
44 OBDII_DIAGNOSTIC_CODE = 9;
45 NIGHT_MODE = 10;
46 ENVIRONMENT_DATA = 11;
47 HVAC_DATA = 12;
48 DRIVING_STATUS_DATA = 13;
49 DEAD_RECKONING_DATA = 14;
50 PASSENGER_DATA = 15;
51 DOOR_DATA = 16;
52 LIGHT_DATA = 17;
53 TIRE_PRESSURE_DATA = 18;
54 ACCELEROMETER_DATA = 19;
55 GYROSCOPE_DATA = 20;
56 GPS_SATELLITE_DATA = 21;
57 TOLL_CARD = 22;
58 VEHICLE_ENERGY_MODEL_DATA = 23;
59 TRAILER_DATA = 24;
60 RAW_VEHICLE_ENERGY_MODEL = 25;
61 RAW_EV_TRIP_SETTINGS = 26;
62}
63
64// 0x8001, phone -> HU: subscribe. `xnu` fields 1-2, from the teardown.
65// Field 2 is always written (gearhead's `jcd.s` unconditionally sets it;
66// mined call sites pass 0 = fastest rate); -1 unsubscribes (see
67// GalMessage.Sensor.UNSUBSCRIBE_PERIOD).
68message SensorRequest {
69 required SensorType sensor_type = 1;
70 optional int64 min_update_period_ms = 2;
71}
72
73// 0x8002, HU -> phone: subscription answer. Teardown-exact `xnv`/`xow`:
74// a single field, the `xls` status (0 = STATUS_SUCCESS, negative = per-type
75// refusal, e.g. -9 STATUS_INVALID_SENSOR). There is NO sensor-type echo --
76// gearhead's subscribe is synchronous (`jcd.s` waits on a semaphore per
77// call), so the answer needs no attribution. Our batched subscribes match
78// answers FIFO in send order (verified: the DHU answers in subscribe order).
79message SensorResponse {
80 optional int32 status = 1;
81}
82
83// 0x8003, HU -> phone: streamed readings. MA sender-defined, same caveat.
84message SensorBatch {
85 repeated SensorEvent events = 1;
86}
87
88// One reading. The declared type attributes the event; the payload present
89// carries the value. An event with no payload is counted but changes no
90// value -- the owner keeps its last-known rather than clobbering it.
91//
92// Envelope numbers (2-25) are MA sender-defined, continuing the existing
93// sequence. The payload INNER layouts below are teardown-exact where noted
94// (`dump_protos.py` over the `xnr` field classes): numbers, wire types and
95// cardinality recovered, names `fieldN` per the repo convention for
96// unrecovered names (see gal/input.proto). Two types carry no payload:
97// VEHICLE_ENERGY_MODEL_DATA(23) (`xgu` decodes as a proto3 single-message
98// anomaly, not a usable reading layout) and TRAILER_DATA(24) (`xon`
99// descriptor is empty) -- both fold to last-known with MISSING-payload
100// comments in SensorSnapshot.withEvents, never invented bytes.
101message SensorEvent {
102 required SensorType sensor_type = 1;
103 optional LocationReading location = 2;
104 optional CompassReading compass = 3;
105 optional SpeedReading speed = 4;
106 optional NightReading night = 5;
107 optional DrivingStatusReading driving_status = 6;
108 optional RpmReading rpm = 7;
109 optional OdometerReading odometer = 8;
110 optional FuelReading fuel = 9;
111 optional ParkingBrakeReading parking_brake = 10;
112 optional GearReading gear = 11;
113 optional ObdiiReading obdii = 12;
114 optional EnvironmentReading environment = 13;
115 optional HvacReading hvac = 14;
116 optional DeadReckoningReading dead_reckoning = 15;
117 optional PassengerReading passenger = 16;
118 optional DoorReading door = 17;
119 optional LightReading light = 18;
120 optional TirePressureReading tire_pressure = 19;
121 optional AccelerometerReading accelerometer = 20;
122 optional GyroscopeReading gyroscope = 21;
123 optional GpsSatelliteReading gps_satellite = 22;
124 optional TollCardReading toll_card = 23;
125 optional RawVehicleEnergyReading raw_vehicle_energy = 24;
126 optional RawEvTripReading raw_ev_trip = 25;
127}
128
129message LocationReading {
130 optional int64 latitude_e7 = 1;
131 optional int64 longitude_e7 = 2;
132 optional int32 accuracy_m = 3;
133 optional int64 timestamp_ms = 4;
134}
135
136message CompassReading {
137 optional int32 heading_deg = 1;
138}
139
140message SpeedReading {
141 optional double speed_mps = 1;
142}
143
144message NightReading {
145 optional bool is_night = 1;
146}
147
148message DrivingStatusReading {
149 optional bool parked = 1;
150}
151
152// RPM(4) body (`xnq`), from the teardown: required int32 field 1.
153message RpmReading {
154 required int32 field1 = 1;
155}
156
157// ODOMETER(5) body (`xlu`), from the teardown: required int32 field 1,
158// optional int32 field 2.
159message OdometerReading {
160 required int32 field1 = 1;
161 optional int32 field2 = 2;
162}
163
164// FUEL(6) body (`xjj`), from the teardown: three optional int32 fields.
165message FuelReading {
166 optional int32 field1 = 1;
167 optional int32 field2 = 2;
168 optional int32 field3 = 3;
169}
170
171// PARKING_BRAKE(7) body (`xly`), from the teardown: required bool field 1.
172message ParkingBrakeReading {
173 required bool field1 = 1;
174}
175
176// GEAR(8) body (`xjl`), from the teardown: required enum field 1. The enum
177// type itself is unidentified, so int32 here -- identical varint encoding on
178// the wire -- rather than an invented enum.
179message GearReading {
180 required int32 field1 = 1;
181}
182
183// OBDII_DIAGNOSTIC_CODE(9) body (`xjb`), from the teardown: optional bytes
184// field 1 (raw diagnostic payload).
185message ObdiiReading {
186 optional bytes field1 = 1;
187}
188
189// ENVIRONMENT_DATA(11) body (`xjg`), from the teardown: three optional
190// int32 fields.
191message EnvironmentReading {
192 optional int32 field1 = 1;
193 optional int32 field2 = 2;
194 optional int32 field3 = 3;
195}
196
197// HVAC_DATA(12) body (`xjr`), from the teardown: two optional int32 fields.
198message HvacReading {
199 optional int32 field1 = 1;
200 optional int32 field2 = 2;
201}
202
203// DEAD_RECKONING_DATA(14) body (`xja`), from the teardown: optional int32
204// field 1, repeated (unpacked) int32 field 2.
205message DeadReckoningReading {
206 optional int32 field1 = 1;
207 repeated int32 field2 = 2;
208}
209
210// PASSENGER_DATA(15) body (`xlz`), from the teardown: optional bool field 1.
211message PassengerReading {
212 optional bool field1 = 1;
213}
214
215// DOOR_DATA(16) body (`xjd`), from the teardown: two optional bools plus a
216// repeated bool field 3 (per-door states).
217message DoorReading {
218 optional bool field1 = 1;
219 optional bool field2 = 2;
220 repeated bool field3 = 3;
221}
222
223// LIGHT_DATA(17) body (`xkg`), from the teardown: two optional enums plus an
224// optional bool. Both enum types are unidentified, so int32 -- identical
225// varint encoding -- rather than invented enums.
226message LightReading {
227 optional int32 field1 = 1;
228 optional int32 field2 = 2;
229 optional bool field3 = 3;
230}
231
232// TIRE_PRESSURE_DATA(18) body (`xoj`), from the teardown: repeated
233// (unpacked) int32 field 1, one entry per wheel.
234message TirePressureReading {
235 repeated int32 field1 = 1;
236}
237
238// ACCELEROMETER_DATA(19) body (`xgy`), from the teardown: three optional
239// int32 fields (x/y/z axes).
240message AccelerometerReading {
241 optional int32 field1 = 1;
242 optional int32 field2 = 2;
243 optional int32 field3 = 3;
244}
245
246// GYROSCOPE_DATA(20) body (`xjp`), from the teardown: three optional int32
247// fields (x/y/z axes).
248message GyroscopeReading {
249 optional int32 field1 = 1;
250 optional int32 field2 = 2;
251 optional int32 field3 = 3;
252}
253
254// One satellite fix inside a GPS_SATELLITE_DATA body (`xjn`), from the
255// teardown: required int32 fields 1-2, required bool field 3, optional
256// int32 fields 4-5.
257message GpsSatelliteEntry {
258 required int32 field1 = 1;
259 required int32 field2 = 2;
260 required bool field3 = 3;
261 optional int32 field4 = 4;
262 optional int32 field5 = 5;
263}
264
265// GPS_SATELLITE_DATA(21) body (`xjo`), from the teardown: required int32
266// field 1, optional int32 field 2, repeated `xjn` entries field 3.
267message GpsSatelliteReading {
268 required int32 field1 = 1;
269 optional int32 field2 = 2;
270 repeated GpsSatelliteEntry field3 = 3;
271}
272
273// TOLL_CARD(22) body (`xok`), from the teardown: required bool field 1.
274message TollCardReading {
275 required bool field1 = 1;
276}
277
278// RAW_VEHICLE_ENERGY_MODEL(25) body (`xnk`), from the teardown: optional
279// bytes field 1 (opaque model blob).
280message RawVehicleEnergyReading {
281 optional bytes field1 = 1;
282}
283
284// RAW_EV_TRIP_SETTINGS(26) body (`xni`), from the teardown: optional bytes
285// field 1 (opaque settings blob).
286message RawEvTripReading {
287 optional bytes field1 = 1;
288}
289
290// 0x8004, HU -> phone: a subscription or stream failure. MA sender-defined,
291// same caveat as SensorResponse. Observed, never fatal -- the bring-up and
292// video carry on.
293message SensorError {
294 required SensorType sensor_type = 1;
295 optional int32 status = 2;
296}