|
16 | 16 |
|
17 | 17 | #include <stdint.h> |
18 | 18 | #include <stddef.h> |
| 19 | +#include <Arduino_CBOR.h> // FIXME maybe include only message.h |
19 | 20 |
|
20 | 21 | /****************************************************************************** |
21 | 22 | * DEFINE |
22 | 23 | ******************************************************************************/ |
23 | 24 |
|
| 25 | + |
| 26 | +// FIXME make this constants into an enum |
| 27 | +// TODO remove provisioning constants |
24 | 28 | #define THING_ID_SIZE 37 |
25 | 29 | #define SHA256_SIZE 32 |
26 | 30 | #define URL_SIZE 256 |
|
47 | 51 | TYPEDEF |
48 | 52 | ******************************************************************************/ |
49 | 53 |
|
50 | | -enum CommandId: uint32_t { |
| 54 | +enum CommandId: MessageId { |
51 | 55 |
|
52 | 56 | /* Device commands */ |
53 | 57 | DeviceBeginCmdId, |
@@ -77,29 +81,9 @@ enum CommandId: uint32_t { |
77 | 81 |
|
78 | 82 | /* Unknown command id */ |
79 | 83 | UnknownCmdId, |
80 | | - |
81 | | - /* Provisioning commands*/ |
82 | | - ProvisioningStatus, |
83 | | - ProvisioningListWifiNetworks, |
84 | | - ProvisioningUniqueHardwareId, |
85 | | - ProvisioningBLEMacAddress, |
86 | | - ProvisioningJWT, |
87 | | - ProvisioningTimestamp, |
88 | | - ProvisioningCommands, |
89 | | - ProvisioningWifiConfig, |
90 | | - ProvisioningLoRaConfig, |
91 | | - ProvisioningGSMConfig, |
92 | | - ProvisioningNBIOTConfig, |
93 | | - ProvisioningCATM1Config, |
94 | | - ProvisioningEthernetConfig, |
95 | | - ProvisioningCellularConfig, |
96 | 84 | }; |
97 | 85 |
|
98 | | -struct Command { |
99 | | - CommandId id; |
100 | | -}; |
101 | | - |
102 | | -typedef Command Message; |
| 86 | +typedef Message Command; |
103 | 87 |
|
104 | 88 | struct DeviceBeginCmd { |
105 | 89 | Command c; |
@@ -180,139 +164,11 @@ struct TimezoneCommandDown { |
180 | 164 | } params; |
181 | 165 | }; |
182 | 166 |
|
183 | | -struct ProvisioningStatusMessage { |
184 | | - Command c; |
185 | | - struct { |
186 | | - int16_t status; |
187 | | - } params; |
188 | | -}; |
189 | | - |
190 | | -struct WiFiNetwork { |
191 | | - char *SSID; |
192 | | - int *RSSI; |
193 | | -}; |
194 | | - |
195 | | -struct ProvisioningListWifiNetworksMessage { |
196 | | - Command c; |
197 | | - struct { |
198 | | - WiFiNetwork discoveredWifiNetworks[MAX_WIFI_NETWORKS]; |
199 | | - uint8_t numDiscoveredWiFiNetworks = 0; |
200 | | - } params; |
201 | | -}; |
202 | | - |
203 | | -struct ProvisioningUniqueHardwareIdMessage { |
204 | | - Command c; |
205 | | - struct { |
206 | | - char uniqueHardwareId[UHWID_SIZE]; //The payload is an array of char with a maximum length of 32, not null terminated. It's not a string. |
207 | | - } params; |
208 | | -}; |
209 | | - |
210 | | -struct ProvisioningJWTMessage { |
211 | | - Command c; |
212 | | - struct { |
213 | | - char jwt[PROVISIONING_JWT_SIZE]; //The payload is an array of char with a maximum length of 268, not null terminated. It's not a string. |
214 | | - } params; |
215 | | -}; |
216 | | - |
217 | | -struct ProvisioningBLEMacAddressMessage { |
218 | | - Command c; |
219 | | - struct { |
220 | | - uint8_t macAddress[BLE_MAC_ADDRESS_SIZE]; |
221 | | - } params; |
222 | | -}; |
223 | | - |
224 | | -struct ProvisioningTimestampMessage { |
225 | | - Command c; |
226 | | - struct { |
227 | | - uint64_t timestamp; |
228 | | - } params; |
229 | | -}; |
230 | | - |
231 | | -struct ProvisioningCommandsMessage { |
232 | | - Command c; |
233 | | - struct { |
234 | | - uint8_t cmd; |
235 | | - } params; |
236 | | -}; |
237 | | - |
238 | | -struct ProvisioningWifiConfigMessage { |
239 | | - Command c; |
240 | | - struct { |
241 | | - char ssid[WIFI_SSID_SIZE]; |
242 | | - char pwd[WIFI_PWD_SIZE]; |
243 | | - } params; |
244 | | -}; |
245 | | - |
246 | | -struct ProvisioningLoRaConfigMessage { |
247 | | - Command c; |
248 | | - struct { |
249 | | - char appeui[LORA_APPEUI_SIZE]; |
250 | | - char appkey[LORA_APPKEY_SIZE]; |
251 | | - uint8_t band; |
252 | | - char channelMask[LORA_CHANNEL_MASK_SIZE]; |
253 | | - char deviceClass[LORA_DEVICE_CLASS_SIZE]; |
254 | | - } params; |
255 | | -}; |
256 | | - |
257 | | -struct ProvisioningCATM1ConfigMessage { |
258 | | - Command c; |
259 | | - struct { |
260 | | - char pin[PIN_SIZE]; |
261 | | - char apn[APN_SIZE]; |
262 | | - char login[LOGIN_SIZE]; |
263 | | - char pass[PASS_SIZE]; |
264 | | - uint32_t band[BAND_SIZE]; |
265 | | - } params; |
266 | | -}; |
267 | | - |
268 | | -struct ProvisioningIPStruct{ |
269 | | - enum IPType { |
270 | | - IPV4, |
271 | | - IPV6 |
272 | | - }; |
273 | | - IPType type; |
274 | | - uint8_t ip[MAX_IP_SIZE]; |
275 | | -}; |
276 | | - |
277 | | -struct ProvisioningEthernetConfigMessage { |
278 | | - Command c; |
279 | | - struct { |
280 | | - ProvisioningIPStruct ip; |
281 | | - ProvisioningIPStruct dns; |
282 | | - ProvisioningIPStruct gateway; |
283 | | - ProvisioningIPStruct netmask; |
284 | | - unsigned long timeout; |
285 | | - unsigned long response_timeout; |
286 | | - } params; |
287 | | -}; |
288 | | - |
289 | | - |
290 | | -struct ProvisioningCellularConfigMessage { |
291 | | - Command c; |
292 | | - struct { |
293 | | - char pin[PIN_SIZE]; |
294 | | - char apn[APN_SIZE]; |
295 | | - char login[LOGIN_SIZE]; |
296 | | - char pass[PASS_SIZE]; |
297 | | - } params; |
298 | | -}; |
299 | | - |
300 | 167 | union CommandDown { |
301 | | - struct Command c; |
| 168 | + Command c; |
302 | 169 | struct OtaUpdateCmdDown otaUpdateCmdDown; |
303 | 170 | struct ThingUpdateCmd thingUpdateCmd; |
304 | 171 | struct ThingDetachCmd thingDetachCmd; |
305 | 172 | struct LastValuesUpdateCmd lastValuesUpdateCmd; |
306 | 173 | struct TimezoneCommandDown timezoneCommandDown; |
307 | 174 | }; |
308 | | - |
309 | | -union ProvisioningCommandDown { |
310 | | - struct Command c; |
311 | | - struct ProvisioningTimestampMessage provisioningTimestamp; |
312 | | - struct ProvisioningCommandsMessage provisioningCommands; |
313 | | - struct ProvisioningWifiConfigMessage provisioningWifiConfig; |
314 | | - struct ProvisioningLoRaConfigMessage provisioningLoRaConfig; |
315 | | - struct ProvisioningCATM1ConfigMessage provisioningCATM1Config; |
316 | | - struct ProvisioningEthernetConfigMessage provisioningEthernetConfig; |
317 | | - struct ProvisioningCellularConfigMessage provisioningCellularConfig; |
318 | | -}; |
0 commit comments