-
Notifications
You must be signed in to change notification settings - Fork 37
/
Definitions.h
74 lines (61 loc) · 1.44 KB
/
Definitions.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/*
* MYSBootloader 1.3.0-rc.1
* OTA RF24 bootloader for MySensors: https://www.mysensors.org
* Based on MySensors library 2.2
* Developed and maintained by tekka 2018
*/
#ifndef Definitions_H
#define Definitions_H
#define FIRMWARE_BLOCK_SIZE (16)
#define EEPROM_SIZE 1024 // 1024 bytes for ATMEGA328
#define false (0)
#define true (1)
typedef uint8_t bool;
typedef enum {
BL_INIT,
BL_READ_CONFIG,
BL_FIND_PARENTS,
BL_CHECK_ID,
BL_CONFIGRUATION,
BL_INIT_UPDATE,
BL_DO_UPDATE,
BL_VALIDATE_OTA,
BL_RUN,
BL_EXIT
} SM_BL_STATE;
typedef struct {
union {
uint16_t type;
uint16_t bl_command;
} type_command;
union {
uint16_t version;
uint16_t bl_data;
} version_data;
uint16_t blocks;
uint16_t crc;
} __attribute__((packed)) nodeFirmwareConfig_t;
typedef struct {
uint16_t type;
uint16_t version;
uint16_t blocks;
uint16_t crc;
uint16_t BLVersion;
} __attribute__((packed)) requestFirmwareConfig_t;
typedef struct {
uint16_t type;
uint16_t version;
uint16_t block;
} __attribute__((packed)) requestFirmwareBlock_t;
typedef struct {
uint16_t type;
uint16_t version;
uint16_t block;
uint8_t data[FIRMWARE_BLOCK_SIZE];
} __attribute__((packed)) responseFirmwareBlock_t;
typedef struct {
uint8_t nodeId; // Current node id
uint8_t parentNodeId; // Where this node sends its messages
uint8_t distance; // This nodes distance to sensor net gateway (number of hops)
} __attribute__((packed)) nodeConfig_t;
#endif // Definitions_H