-
Notifications
You must be signed in to change notification settings - Fork 0
/
measurement.proto
45 lines (37 loc) · 1.58 KB
/
measurement.proto
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
syntax = "proto3";
package measurement;
option go_package = "github.com/mtraver/environmental-sensor/measurementpb";
import "google/protobuf/descriptor.proto";
import "google/protobuf/empty.proto";
import "google/protobuf/timestamp.proto";
import "google/protobuf/wrappers.proto";
message MeasurementOptions {
string metric = 1;
string unit = 2;
}
extend google.protobuf.FieldOptions {
string regex = 50000;
MeasurementOptions measurement_options = 50001;
}
message Measurement {
string device_id = 1 [(regex) = "^[a-z][a-z0-9+.%~_-]{2,254}$"];
google.protobuf.Timestamp timestamp = 2;
google.protobuf.FloatValue temp = 3 [(measurement_options).metric = "temp", (measurement_options).unit = "°C"];
google.protobuf.FloatValue pm25 = 5 [(measurement_options).metric = "PM2.5", (measurement_options).unit = "μg/m³"];
google.protobuf.FloatValue pm10 = 6 [(measurement_options).metric = "PM10", (measurement_options).unit = "μg/m³"];
google.protobuf.FloatValue rh = 7 [(measurement_options).metric = "RH", (measurement_options).unit = "%"];
// This field should only be set when the measurement is not uploaded
// immediately after it is taken, e.g. if the network goes down and
// measurements are stored locally before upload is attempted again later.
google.protobuf.Timestamp upload_timestamp = 4;
}
service MeasurementService {
rpc GetDevices(google.protobuf.Empty) returns (GetDevicesResponse) {}
rpc GetLatest(GetLatestRequest) returns (Measurement) {}
}
message GetDevicesResponse {
repeated string device_id = 1;
}
message GetLatestRequest {
string device_id = 1;
}