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,76 @@ struct Command {
48
67
};
49
68
50
69
typedef Command Message ;
70
+
71
+ struct LastValuesBeginCmd {
72
+ Command c ;
73
+ };
74
+
75
+ struct OtaBeginUp {
76
+ Command c ;
77
+ struct {
78
+ uint8_t sha [SHA256_SIZE ];
79
+ } params ;
80
+ };
81
+
82
+ struct DeviceBeginCmd {
83
+ Command c ;
84
+ struct {
85
+ char lib_version [MAX_LIB_VERSION_SIZE ];
86
+ } params ;
87
+ };
88
+
89
+ struct OtaProgressCmdUp {
90
+ Command c ;
91
+ struct {
92
+ uint8_t id [ID_SIZE ];
93
+ uint8_t state ;
94
+ int32_t state_data ;
95
+ uint64_t time ;
96
+ } params ;
97
+ };
98
+
99
+ struct TimezoneCommandUp {
100
+ Command c ;
101
+ };
102
+
103
+ struct OtaUpdateCmdDown {
104
+ Command c ;
105
+ struct {
106
+ uint8_t id [ID_SIZE ];
107
+ char url [URL_SIZE ];
108
+ uint8_t initialSha256 [SHA256_SIZE ];
109
+ uint8_t finalSha256 [SHA256_SIZE ];
110
+ } params ;
111
+ };
112
+
113
+ struct ThingBeginCmd {
114
+ Command c ;
115
+ struct {
116
+ char thing_id [THING_ID_SIZE ];
117
+ } params ;
118
+ };
119
+
120
+ struct LastValuesUpdateCmd {
121
+ Command c ;
122
+ struct {
123
+ uint8_t * last_values ;
124
+ size_t length ;
125
+ } params ;
126
+ };
127
+
128
+ struct TimezoneCommandDown {
129
+ Command c ;
130
+ struct {
131
+ int32_t offset ;
132
+ uint32_t until ;
133
+ } params ;
134
+ };
135
+
136
+ union CommandDown {
137
+ struct Command c ;
138
+ struct OtaUpdateCmdDown otaUpdateCmdDown ;
139
+ struct ThingBeginCmd thingBeginCmd ;
140
+ struct LastValuesUpdateCmd lastValuesUpdateCmd ;
141
+ struct TimezoneCommandDown timezoneCommandDown ;
142
+ };
0 commit comments