Skip to content

Commit baf00ac

Browse files
Extend Commands.h to include new Command protocol model
1 parent d530c8b commit baf00ac

File tree

1 file changed

+122
-0
lines changed

1 file changed

+122
-0
lines changed

src/message/Commands.h

+122
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,33 @@
1717
#include <stdint.h>
1818
#include <stddef.h>
1919

20+
<<<<<<< HEAD
2021
/******************************************************************************
2122
* TYPEDEF
2223
******************************************************************************/
2324

2425
enum CommandId : uint16_t {
26+
=======
27+
#if __cplusplus >= 201402L // Cpp14
28+
#include <algorithm>
29+
#endif // __cplusplus
30+
31+
/******************************************************************************
32+
* DEFINE
33+
******************************************************************************/
34+
35+
#define THING_ID_SIZE 37
36+
#define SHA256_SIZE 32
37+
#define URL_SIZE 256
38+
#define ID_SIZE 16
39+
#define MAX_LIB_VERSION_SIZE 10
40+
41+
/******************************************************************************
42+
TYPEDEF
43+
******************************************************************************/
44+
45+
enum CommandID: uint32_t {
46+
>>>>>>> 9d4009fa (Extend Commands.h to include new Command protocol model)
2547

2648
/* Device commands */
2749
DeviceBeginCmdId,
@@ -39,12 +61,112 @@ enum CommandId : uint16_t {
3961
/* Generic commands */
4062
ResetCmdId,
4163

64+
<<<<<<< HEAD
65+
=======
66+
/* OTA commands */
67+
OtaBeginUpId,
68+
OtaProgressCmdUpId,
69+
OtaUpdateCmdDownId,
70+
71+
/* Timezone commands */
72+
TimezoneCommandUpId,
73+
TimezoneCommandDownId,
74+
75+
>>>>>>> 9d4009fa (Extend Commands.h to include new Command protocol model)
4276
/* Unknown command id */
4377
UnknownCmdId
4478
};
4579

4680
struct Command {
81+
<<<<<<< HEAD
4782
CommandId id;
4883
};
4984

5085
typedef Command Message;
86+
=======
87+
CommandID id;
88+
};
89+
90+
typedef Command Message;
91+
92+
struct ThingGetIdCmdUp {
93+
Command c;
94+
struct {
95+
char thing_id[THING_ID_SIZE];
96+
} params;
97+
};
98+
99+
struct ThingGetLastValueCmdUp {
100+
Command c;
101+
};
102+
103+
struct OtaBeginUp {
104+
Command c;
105+
struct {
106+
uint8_t sha [SHA256_SIZE];
107+
} params;
108+
};
109+
110+
struct DeviceBeginCmdUp {
111+
Command c;
112+
struct {
113+
char lib_version[MAX_LIB_VERSION_SIZE];
114+
} params;
115+
};
116+
117+
struct OtaProgressCmdUp {
118+
Command c;
119+
struct {
120+
uint8_t id[ID_SIZE];
121+
uint8_t state;
122+
int32_t state_data;
123+
uint64_t time;
124+
} params;
125+
};
126+
127+
struct TimezoneCommandUp {
128+
Command c;
129+
};
130+
131+
struct OtaUpdateCmdDown {
132+
Command c;
133+
struct {
134+
uint8_t id[ID_SIZE];
135+
char url[URL_SIZE];
136+
uint8_t initialSha256[SHA256_SIZE];
137+
uint8_t finalSha256[SHA256_SIZE];
138+
} params;
139+
};
140+
141+
struct ThingGetIdCmdDown {
142+
Command c;
143+
struct {
144+
char thing_id[THING_ID_SIZE];
145+
} params;
146+
};
147+
148+
struct ThingGetLastValueCmdDown {
149+
Command c;
150+
struct {
151+
uint8_t * last_values;
152+
size_t length;
153+
} params;
154+
};
155+
156+
struct TimezoneCommandDown{
157+
Command c;
158+
struct {
159+
int32_t offset;
160+
uint32_t until;
161+
} params;
162+
};
163+
164+
union CommandDown {
165+
struct Command c;
166+
struct OtaUpdateCmdDown otaUpdateCmdDown;
167+
struct ThingGetIdCmdDown thingGetIdCmdDown;
168+
struct ThingGetLastValueCmdDown thingGetLastValueCmdDown;
169+
struct TimezoneCommandDown timezoneCommandDown;
170+
};
171+
172+
>>>>>>> 9d4009fa (Extend Commands.h to include new Command protocol model)

0 commit comments

Comments
 (0)