-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrpcdef.h
398 lines (364 loc) · 11.7 KB
/
rpcdef.h
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
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
#ifndef __RPCDEF_H__
#define __RPCDEF_H__
#include <stdint.h>
#define RPC_LONGLEN 35
#define RPC_SHORTLEN 5
typedef uint8_t UINT8;
typedef uint16_t UINT16;
typedef uint64_t UINT64;
typedef int8_t INT8;
typedef int16_t INT16;
typedef int64_t INT64;
typedef int64_t DATETIME;
typedef uint8_t RPCBOOL;
typedef int32_t INT32;
typedef uint32_t UINT32;
//////////////////////////////////////// Rpc Definitions ///////////////////////////////////
typedef enum
{
void_void = 1,
UINT8_void = 2,
UINT16_void = 3,
UINT32_void = 4,
UINT64_void = 5,
INT8_void = 6,
INT16_void = 7,
INT32_void = 8,
INT64_void = 9,
BOOL_void = 10,
DATETIME_void = 11,
BYTEARRAY_void = 12,
FLOAT_void = 13,
void_BYTEARRAY = 14,
void_UINT16 = 15,
void_FLOAT = 16,
BOOL_DATETIME = 17,
BYTEARRAY_UINT16 = 18,
void_UINT8 = 19,
void_UINT32 = 20,
void_BOOL = 21,
void_UINT8_FLOAT = 22,
FLOAT_UINT8 = 23,
UINT16_BYTEARRAY = 24,
UINT16_BYTEARRAY_BOOL = 25,
BYTEARRAY_BYTEARRAY = 26,
void_UINT8_BYTEARRAY = 27,
BYTEARRAY_UINT32 = 28,
BYTEARRAY_UINT32_UINT32 = 29,
void_UINT32_BYTEARRAY = 30,
BYTEARRAY_UINT8 = 31
}rpcSignature_t;
// List of standart rpc supported ids
typedef enum
{
RPC_GET_DEVICE_IDS = 0,
RPC_GET_DEVICE_ID = 1,
RPC_SET_DEVICE_DATE_TIME = 6,
RPC_GET_DEVICE_DATE_TIME = 7,
RPC_FACTORY_RESET = 8,
RPC_POWER_OFF = 9,
RPC_GET_POWER_STATUS = 11,
RPC_DIR_LIST_START = 12,
RPC_DIR_LIST_NEXT_GET = 13,
RPC_DIR_DELETE = 14,
RPC_FILE_DELETE = 15,
RPC_FS_FREE_SPACE_GET = 16,
RPC_FILE_READ_START = 17,
RPC_FILE_READ_NEXT = 18,
RPC_FIND_ME = 20,
RPC_GET_SOFTWARE_INFO = 21,
RPC_GET_MODERN_FIRMWARE_ID = 22
}rpcStandartId_t;
// Supported meteo ids
typedef enum
{
RPC_SET_OPERATION_MODE = 2056,
RPC_GET_OPERATION_MODE = 2057,
RPC_GET_LIVE_DATA = 2058,
RPC_GET_FLAGS = 3001,
RPC_SET_RH_HEATER_STATE = 3011,
RPC_SET_ALLOW_CHARGING = 2067,
} rpcMeteoId;
// Ekologger Ids
typedef enum
{
RPC_GET_SENSORS_PRESENCE = 2060,
RPC_SET_ACTIVE_PROBE = 2068,
RPC_GET_ACTIVE_PROBE = 2069,
RPC_GET_PROBE_SERIAL = 2088,
RPC_SET_DEVICE_SETTINGS = 2090,
RPC_GET_DEVICE_SETTINGS = 2091,
RPC_SAVE_LIVEDATA = 2092,
RPC_GET_DISPLAY_CONTRAST = 2093,
RPC_SET_DISPLAY_CONTRAST = 2094
}rpcEkologgerId;
typedef enum
{
RPC_SUCCESS = 0,
RPC_UNKNOWN_ID = 1,
RPC_BAD_STACK = 2,
RPC_TIMEOUT = 3,
RPC_STACK_OVERFLOW = 4,
RPC_UNKNOWN_SIGNATURE = 5,
RPC_BAD_SIGNATURE = 6,
RPC_ID_MISSMATCH = 7,
RPC_COMM_ERROR = 8,
RPC_BUSY_NO_DATA = 9,
RPC_PARAM_ERROR_0 = 10,
RPC_PARAM_ERROR_1 = 11,
RPC_PARAM_ERROR_2 = 12,
RPC_PARAM_ERROR_3 = 13,
RPC_PARAM_ERROR_4 = 14,
RPC_PARAM_ERROR_5 = 15
} RpcStatus_t;
#pragma pack(push, 1)
typedef struct
{
uint8_t ver_major;
uint8_t ver_minor;
} FirmwareId_t;
typedef struct s_OldDeviceId
{
uint16_t type;
uint16_t year;
uint16_t number;
FirmwareId_t FirmwareId;
} OldDeviceId_t;
typedef struct s_ModernDeviceId
{
uint16_t type;
uint16_t year;
uint16_t number;
FirmwareId_t FirmwareId;
} ModernDeviceId_t;
#pragma pack(pop)
typedef enum e_DeviceType
{
DEVICE_EKOLOGGER = 11,
} DeviceType_t;
typedef enum
{
RPC_METEO_IDLE = 1, // all sensors are off
RPC_METEO_LIVE_LIMITED = 2, // all sensors are on except wind velocity sensor
RPC_METEO_LIVE_UNLIMITED = 3 // all sensors are on
} MeteoMode_t; // Each probe has its own meteo mode
typedef union u_SensorPresence
{
uint8_t byte;
struct
{
uint8_t block_this_probe : 1; // 1 - probe was blocked
// 1 - present, 0 - not present
uint8_t probe : 1; // probe / temperature sensor
uint8_t rh : 1; // humidity sensor
uint8_t p : 1; // pressure sensor
uint8_t v : 1; // Adc / wind velocity sensor
} bits;
} SensorPresence_t; // each probe has its own SensorPresence
typedef union
{
#pragma pack(push, 1)
struct
{
uint32_t ta_rh : 1; // bit 0 - no Temperature sensor or Humidity sensor
uint32_t v : 1; // bit 1 - no wind velocity sensor
uint32_t eeprom : 1; // bit 2 - no eeprom
uint32_t calibration : 1; // bit 3 - EEPROM does not have at least one calibration
uint32_t wdt : 1; // bit 4 - Wdt reset occured
uint32_t battery : 1; // bit 5 - battery voltage went beyond 4.2-2.7v
uint32_t resistor : 1; // bit 6 - not used
uint32_t blackglobe : 1; // bit 7 - no black sphere
uint32_t p : 1; // bit 8 - no pressure sensor
uint32_t cal_vc : 1; // bit 9 - calibration error of wind velocity sensor
uint32_t cal_reserved : 1; // bit 10 - reserved
uint32_t cal_ta : 1; // bit 11 - calibration error of Air temperature sensor
uint32_t cal_rh : 1; // bit 12 - calibration error of humidity sensor
uint32_t cal_p : 1; // bit 13 - calibration error of pressure sensor
uint32_t cal_tg : 1; // bit 14 - calibration error of temperature inside black sphere - reserved
} bv;
#pragma pack(pop)
uint32_t b;
} MeteoErrors_t;
typedef union u_derivatives
{
// bits set to -1 - param is decreasing, 1 param is increasing, 0 - param has not changed, but has not reached stable state yet, 2 - param is stable
uint32_t dword;
struct
{
int32_t ta : 2; // Air temperature
int32_t rh : 2; // Relative humidity
int32_t td : 2; // Dew point
int32_t tw : 2; // wet bulb temperature
int32_t u : 2; // wind velocity
int32_t tg : 2; // Temperature inside black sphere
int32_t wbgt : 2; // 11 - Wet-Bulb Globe Temperature
int32_t wbgts : 2; // 11 - is decreasing , 01 - is increasing , 00 - is stable, 10 - reserved
int32_t tr : 2; // 11 - is decreasing , 01 - is increasing , 00 - is stable, 10 - reserved
int32_t w : 2; // 11 - is decreasing , 01 - is increasing , 00 - is stable, 10 - reserved
int32_t p : 2; // 11 - pressure is decreasing , 01 - pressure is increasing , 00 - pressure is stable, 10 - reserved
int32_t to : 2; // 11 - Resulting temperature is decreasing , 01 - Resulting temperature is increasing , 00 - Resulting temperature is stable, 10 - reserved
int32_t reserved_area : 8;
} bits;
} derivatives_t;
#pragma pack(push, 1)
typedef struct
{
// timestap in ms
int64_t ts;
struct
{
// Flag indication (1 - is error)
union
{
uint32_t dwordval;
struct
{
uint32_t ta : 1; // 1 - temp error
uint32_t rh : 1; // 1 - humidity error
uint32_t td : 1; // 1 - error when calculating td
uint32_t tw : 1; // 1 - error when calculating tw
uint32_t u : 1; // 1 - no wind velocity sensor
uint32_t tg : 1; // 1 - no black sphere
uint32_t wbgt : 1; // 1 - error when calculating wbgt index
uint32_t wbgts : 1; // 1 - error when calculating wbgts index
uint32_t tr : 1; // 1 - error when calculating tr
uint32_t w : 1; // 1 - error when calculating w
uint32_t p : 1; // 1 - pressure error
uint32_t to : 1; // 1 - error when calculating to
uint32_t reserved_area : 15; // reserved for future use
uint32_t rh_heater : 1; // 1 - humidity sensor heater is on, all indications may be distorted
} bitval;
} state;
// timer (in seconds) of wind velocity sensor heating:
// 255 in RPC_METEO_IDLE, RPC_METEO_LIMITED modes
// 0..10 in RPC_METEO_UNLIMITED mode indicates
// number of seconds left until the end of the wind
// velocity sensor warm-up
uint8_t heater_timer;
// timer (in seconds) of air temperature averaging (reserved)
uint32_t ta_mean_timer;
// timer (in seconds) of wind speed averaging (reserved)
uint32_t u_mean_timer;
} flags;
struct
{
// Air temperature
float ta;
// Relative humidity
float rh;
// Dew point
float td;
// wet bulb temperature
float tw;
// Wind velocity
float u;
// Temperature inside black sphere
float tg;
// Wet-Bulb Globe Temperature
float wbgt;
// Wet-Bulb Globe Temperature taking into account solar load
float wbgts;
// radiation temperature at blowing speeds less than 1 m/s
float tr;
// thermal radiation density
float w;
// Pressure
float p;
// Resulting temperature
float to;
// reserved
float reserved1;
float reserved2;
} data;
// Indication flags
derivatives_t derivatives;
} MeteoLiveData_t;
typedef struct
{
uint32_t old_value; // reserved
uint32_t new_value;
uint64_t change_date; // reserved
} CrcInfo_t;
typedef struct
{
char software_name[64];
char software_id[32];
CrcInfo_t FirmwareCrc; // reserved
CrcInfo_t CalibrationCrc; // Calibration crc
uint8_t reserved[64];
} SoftwareInfo_t;
#pragma pack(1)
typedef struct
{
uint16_t min_code; // minimal state
uint16_t cur_code; // current state
uint16_t max_code; // max state
union
{
uint8_t byteval;
struct
{
uint8_t battery_attached : 1;
uint8_t aux_power : 1;
uint8_t reserved : 1;
uint8_t charging : 1;
uint8_t reserved2 : 3;
uint8_t fast_charging : 1;
} bitval;
} flags;
} PowerStatus_t;
typedef union
{
uint32_t dword;
struct
{
uint32_t logging_enabled : 1; // logger 1 - on | 0 - off | default - 0
uint32_t logging_interval : 17; // logger interval in seconds from 1 to 86400 | default - 5
uint32_t reserved : 11; // reserved for future use
uint32_t display_sleep : 1; // 1 - Sets display off timeout to 10 seconds | 0 - display is always on | default - 0
uint32_t heater_enabled_1 : 1; // 1 - enable wind velocity sensor on probe 1 | default - 0
uint32_t heater_enabled_2 : 1; // 1 - enable wind velocity sensor on probe 2 | default - 0
} bits;
} DeviceSettings_t;
#define RPC_FNAME_LEN_MAX 12
typedef struct
{
uint16_t result; // result code
uint32_t file_size; // file size in bytes
int64_t ts;
uint8_t f_attrs; // fatfs file attributes
uint8_t fname[RPC_FNAME_LEN_MAX + 1]; // file / folder name as null terminated ascii string
} FsItem_t;
typedef struct
{
uint16_t result; // result code
uint32_t chunks; // chunks count in file
} FsItemReadRequest_t;
typedef enum e_FsMemoryUnits
{
BYTES = 0,
KBYTES = 1,
MBYTES = 2,
GBYTES = 3
} FsMemoryUnits_t;
typedef struct s_FsMemSpaceInfo
{
uint16_t count;
uint16_t frac;
uint8_t unit;
uint8_t dummy; // reserved
} FsMemSpaceInfo_t;
typedef struct s_FsInfo
{
uint16_t result;
FsMemSpaceInfo_t total;
FsMemSpaceInfo_t free;
} FsInfo_t;
typedef struct
{
uint32_t number;
uint16_t year;
bool invalid;
} ProbeSerial_t;
#pragma pack(pop)
#endif