18
18
#include <stddef.h>
19
19
20
20
/******************************************************************************
21
- * TYPEDEF
21
+ * DEFINE
22
22
******************************************************************************/
23
23
24
- enum CommandId : uint16_t {
24
+ #define THING_ID_SIZE 37
25
+ #define SHA256_SIZE 32
26
+ #define URL_SIZE 256
27
+ #define ID_SIZE 16
28
+ #define MAX_LIB_VERSION_SIZE 10
29
+
30
+ /******************************************************************************
31
+ TYPEDEF
32
+ ******************************************************************************/
33
+
34
+ enum CommandId : uint32_t {
25
35
26
36
/* Device commands */
27
37
DeviceBeginCmdId ,
@@ -39,6 +49,15 @@ enum CommandId : uint16_t {
39
49
/* Generic commands */
40
50
ResetCmdId ,
41
51
52
+ /* OTA commands */
53
+ OtaBeginUpId ,
54
+ OtaProgressCmdUpId ,
55
+ OtaUpdateCmdDownId ,
56
+
57
+ /* Timezone commands */
58
+ TimezoneCommandUpId ,
59
+ TimezoneCommandDownId ,
60
+
42
61
/* Unknown command id */
43
62
UnknownCmdId
44
63
};
@@ -48,3 +67,83 @@ struct Command {
48
67
};
49
68
50
69
typedef Command Message ;
70
+
71
+ struct ThingGetIdCmdUp {
72
+ Command c ;
73
+ struct {
74
+ char thing_id [THING_ID_SIZE ];
75
+ } params ;
76
+ };
77
+
78
+ struct LastValuesBeginCmd {
79
+ Command c ;
80
+ };
81
+
82
+ struct OtaBeginUp {
83
+ Command c ;
84
+ struct {
85
+ uint8_t sha [SHA256_SIZE ];
86
+ } params ;
87
+ };
88
+
89
+ struct DeviceBeginCmd {
90
+ Command c ;
91
+ struct {
92
+ char lib_version [MAX_LIB_VERSION_SIZE ];
93
+ } params ;
94
+ };
95
+
96
+ struct OtaProgressCmdUp {
97
+ Command c ;
98
+ struct {
99
+ uint8_t id [ID_SIZE ];
100
+ uint8_t state ;
101
+ int32_t state_data ;
102
+ uint64_t time ;
103
+ } params ;
104
+ };
105
+
106
+ struct TimezoneCommandUp {
107
+ Command c ;
108
+ };
109
+
110
+ struct OtaUpdateCmdDown {
111
+ Command c ;
112
+ struct {
113
+ uint8_t id [ID_SIZE ];
114
+ char url [URL_SIZE ];
115
+ uint8_t initialSha256 [SHA256_SIZE ];
116
+ uint8_t finalSha256 [SHA256_SIZE ];
117
+ } params ;
118
+ };
119
+
120
+ struct ThingBeginCmd {
121
+ Command c ;
122
+ struct {
123
+ char thing_id [THING_ID_SIZE ];
124
+ } params ;
125
+ };
126
+
127
+ struct LastValuesUpdateCmd {
128
+ Command c ;
129
+ struct {
130
+ uint8_t * last_values ;
131
+ size_t length ;
132
+ } params ;
133
+ };
134
+
135
+ struct TimezoneCommandDown {
136
+ Command c ;
137
+ struct {
138
+ int32_t offset ;
139
+ uint32_t until ;
140
+ } params ;
141
+ };
142
+
143
+ union CommandDown {
144
+ struct Command c ;
145
+ struct OtaUpdateCmdDown otaUpdateCmdDown ;
146
+ struct ThingBeginCmd thingBeginCmd ;
147
+ struct LastValuesUpdateCmd lastValuesUpdateCmd ;
148
+ struct TimezoneCommandDown timezoneCommandDown ;
149
+ };
0 commit comments