-
Notifications
You must be signed in to change notification settings - Fork 1
/
fk-data.proto
309 lines (271 loc) · 5.7 KB
/
fk-data.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
syntax = "proto3";
package fk_data;
option java_package = "org.conservify.fieldkit.data.pb";
option go_package = "gitlab.com/fieldkit/libraries/data-protocol";
message DeviceLocation {
uint32 enabled = 7;
uint32 fix = 1;
int64 time = 2;
float longitude = 3;
float latitude = 4;
float altitude = 5;
repeated float coordinates = 6;
uint32 satellites = 8;
uint32 hdop = 9;
}
message SensorReading {
uint64 reading = 1;
int64 time = 2;
uint32 sensor = 3;
float value = 4;
}
message LoggedReading {
uint32 version = 1;
DeviceLocation location = 2;
SensorReading reading = 3;
}
message SensorAndValue {
uint32 sensor = 1;
oneof calibrated {
bool calibratedNull = 4;
float calibratedValue = 2;
}
oneof uncalibrated {
bool uncalibratedNull = 5;
float uncalibratedValue = 3;
}
// value = 2;
// uncalibrated = 3;
}
message ModuleHeader {
uint32 manufacturer = 1;
uint32 kind = 2;
uint32 version = 3;
}
message ModuleInfo {
uint32 position = 1;
uint32 address = 2;
string name = 3;
ModuleHeader header = 4;
Firmware firmware = 5;
repeated SensorInfo sensors = 6;
bytes id = 7;
uint32 flags = 8;
bytes configuration = 9;
}
message SensorInfo {
uint32 number = 1;
string name = 2;
string unitOfMeasure = 3;
string uncalibratedUnitOfMeasure = 5;
uint32 flags = 4;
}
message Firmware {
string version = 1;
string build = 2;
string number = 3;
uint64 timestamp = 4;
string hash = 5;
}
message Metadata {
bytes deviceId = 1;
int64 time = 2;
string git = 3;
string build = 7;
uint32 resetCause = 4;
repeated SensorInfo sensors = 5;
repeated ModuleInfo modules = 6;
Firmware firmware = 8;
bytes generation = 9;
uint64 record = 10;
}
message Status {
int64 time = 1;
uint32 uptime = 2;
float battery = 3;
uint32 memory = 4;
uint64 busy = 5;
}
message LogMessage {
int64 time = 1;
uint32 uptime = 2;
uint32 level = 3;
string facility = 4;
string message = 5;
}
enum DownloadFlags {
READING_FLAGS_NONE = 0;
READING_FLAGS_NOT_RECORDING = 1;
READING_FLAGS_MANUAL = 2;
}
message SensorGroup {
uint32 module = 1;
int64 time = 3;
repeated SensorAndValue readings = 2;
}
message Readings {
int64 time = 1;
uint64 reading = 2;
uint32 flags = 3;
uint64 meta = 6;
uint32 uptime = 7;
DeviceLocation location = 4;
repeated SensorGroup sensorGroups = 5;
}
message Interval {
uint64 start = 1;
uint64 end = 2;
uint32 interval = 3;
}
message JobSchedule {
bytes cron = 1;
uint32 interval = 2;
uint32 repeated = 3;
uint32 duration = 4;
uint32 jitter = 5;
repeated Interval intervals = 6;
}
message Schedule {
JobSchedule readings = 1;
JobSchedule network = 2;
JobSchedule lora = 3;
JobSchedule gps = 4;
}
message Identity {
string name = 1;
}
enum ConditionFlags {
CONDITION_FLAGS_NONE = 0;
CONDITION_FLAGS_RECORDING = 1;
}
message Condition {
uint32 flags = 1;
uint32 recording = 2;
}
message NetworkInfo {
string ssid = 1;
string password = 2;
bool create = 3;
bool preferred = 4;
}
message WifiTransmission {
string url = 1;
string token = 2;
bool enabled = 3;
}
message TransmissionSettings {
WifiTransmission wifi = 1;
}
message NetworkSettings {
repeated NetworkInfo networks = 1;
}
message LoraSettings {
bytes deviceEui = 1;
bytes appKey = 2;
bytes joinEui = 3;
uint32 frequencyBand = 4;
bytes deviceAddress = 5;
bytes networkSessionKey = 6;
bytes appSessionKey = 7;
uint32 uplinkCounter = 8;
uint32 downlinkCounter = 9;
uint32 rxDelay1 = 10;
uint32 rxDelay2 = 11;
}
enum EventSystem {
EVENT_SYSTEM_NONE = 0;
EVENT_SYSTEM_RESTART = 1;
EVENT_SYSTEM_BATTERY = 2;
EVENT_SYSTEM_MEMORY = 3;
EVENT_SYSTEM_SENSOR = 4;
EVENT_SYSTEM_WIFI = 5;
EVENT_SYSTEM_LORA = 6;
}
enum Severity {
SEVERITY_INFO = 0;
SEVERITY_WARNING = 1;
SEVERITY_ERROR = 2;
}
message EventDetails {
bytes data = 1;
repeated int32 integers = 2;
repeated float reals = 3;
}
message Event {
EventSystem system = 1;
Severity severity = 2;
uint32 code = 3;
uint32 time = 4;
EventDetails details = 5;
bytes debug = 6;
}
message DataRecord {
LoggedReading loggedReading = 1;
Metadata metadata = 2;
LogMessage log = 3;
repeated LogMessage logs = 13;
Status status = 4;
Readings readings = 5;
repeated ModuleInfo modules = 6;
Schedule schedule = 7;
uint64 meta = 8;
Identity identity = 9;
Condition condition = 10;
LoraSettings lora = 11;
NetworkSettings network = 12;
TransmissionSettings transmission = 14;
repeated Event events = 15;
}
enum SignedRecordKind {
SIGNED_RECORD_KIND_NONE = 0;
SIGNED_RECORD_KIND_MODULES = 1;
SIGNED_RECORD_KIND_SCHEDULE = 2;
SIGNED_RECORD_KIND_STATE = 3;
SIGNED_RECORD_KIND_RAW_STATE = 4;
SIGNED_RECORD_KIND_EVENTS = 5;
SIGNED_RECORD_KIND_OTHER = 0xff;
}
message SignedRecord {
SignedRecordKind kind = 1;
int64 time = 2;
bytes data = 3;
bytes hash = 4;
uint64 record = 5;
}
message LoraRecord {
bytes deviceId = 1;
int64 time = 2;
uint64 number = 3;
uint32 module = 4;
uint64 sensor = 5;
repeated float values = 6;
bytes data = 7;
}
enum CurveType {
CURVE_NONE = 0;
CURVE_LINEAR = 1;
CURVE_POWER = 2;
CURVE_LOGARITHMIC = 3;
CURVE_EXPONENTIAL = 4;
}
message CalibrationPoint {
repeated float references = 1;
repeated float uncalibrated = 2;
repeated float factory = 3;
repeated bytes adc = 4;
}
message CalibrationCoefficients {
repeated float values = 1;
}
message Calibration {
CurveType type = 1;
uint32 time = 2;
uint32 kind = 6;
repeated CalibrationPoint points = 3;
CalibrationCoefficients coefficients = 4;
Firmware firmware = 5;
}
message ModuleConfiguration {
Calibration calibration = 1; // DEPRECATED
repeated Calibration calibrations = 2;
}