Skip to content

Commit 3e281fa

Browse files
Extend Commands.h to include new Command protocol model
1 parent 8a14fcb commit 3e281fa

File tree

1 file changed

+101
-2
lines changed

1 file changed

+101
-2
lines changed

src/message/Commands.h

+101-2
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,20 @@
1818
#include <stddef.h>
1919

2020
/******************************************************************************
21-
* TYPEDEF
21+
* DEFINE
2222
******************************************************************************/
2323

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 {
2535

2636
/* Device commands */
2737
DeviceBeginCmdId,
@@ -39,6 +49,15 @@ enum CommandId : uint16_t {
3949
/* Generic commands */
4050
ResetCmdId,
4151

52+
/* OTA commands */
53+
OtaBeginUpId,
54+
OtaProgressCmdUpId,
55+
OtaUpdateCmdDownId,
56+
57+
/* Timezone commands */
58+
TimezoneCommandUpId,
59+
TimezoneCommandDownId,
60+
4261
/* Unknown command id */
4362
UnknownCmdId
4463
};
@@ -48,3 +67,83 @@ struct Command {
4867
};
4968

5069
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

Comments
 (0)