Skip to content

Commit 38507e4

Browse files
splitting Commands definition for utils offload
1 parent 151088c commit 38507e4

File tree

1 file changed

+7
-151
lines changed

1 file changed

+7
-151
lines changed

src/message/Commands.h

Lines changed: 7 additions & 151 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,15 @@
1616

1717
#include <stdint.h>
1818
#include <stddef.h>
19+
#include <Arduino_CBOR.h> // FIXME maybe include only message.h
1920

2021
/******************************************************************************
2122
* DEFINE
2223
******************************************************************************/
2324

25+
26+
// FIXME make this constants into an enum
27+
// TODO remove provisioning constants
2428
#define THING_ID_SIZE 37
2529
#define SHA256_SIZE 32
2630
#define URL_SIZE 256
@@ -47,7 +51,7 @@
4751
TYPEDEF
4852
******************************************************************************/
4953

50-
enum CommandId: uint32_t {
54+
enum CommandId: MessageId {
5155

5256
/* Device commands */
5357
DeviceBeginCmdId,
@@ -77,29 +81,9 @@ enum CommandId: uint32_t {
7781

7882
/* Unknown command id */
7983
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,
9684
};
9785

98-
struct Command {
99-
CommandId id;
100-
};
101-
102-
typedef Command Message;
86+
typedef Message Command;
10387

10488
struct DeviceBeginCmd {
10589
Command c;
@@ -180,139 +164,11 @@ struct TimezoneCommandDown {
180164
} params;
181165
};
182166

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-
300167
union CommandDown {
301-
struct Command c;
168+
Command c;
302169
struct OtaUpdateCmdDown otaUpdateCmdDown;
303170
struct ThingUpdateCmd thingUpdateCmd;
304171
struct ThingDetachCmd thingDetachCmd;
305172
struct LastValuesUpdateCmd lastValuesUpdateCmd;
306173
struct TimezoneCommandDown timezoneCommandDown;
307174
};
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

Comments
 (0)