-
Notifications
You must be signed in to change notification settings - Fork 51
/
config.h
45 lines (35 loc) · 1.24 KB
/
config.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
#ifndef CONFIG_H
#define CONFIG_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdlib.h>
#include <stdbool.h>
#include <cmp/cmp.h>
typedef struct {
uint8_t ID; /**< Node ID */
char board_name[64 + 1]; /**< Node human readable name, eg: 'arms.left.shoulder'. */
char device_class[64 + 1]; /**< Node device class example : 'CVRA.motorboard.v1'*/
uint32_t application_crc;
uint32_t application_size;
uint32_t update_count;
} bootloader_config_t;
/** Returns true if the given config page is valid. */
bool config_is_valid(void* page, size_t page_size);
/** Serializes the configuration to the buffer.
*
* It must be done on a RAM buffer because we will modify it non sequentially, to add CRC.
*/
void config_write(void* buffer, bootloader_config_t* config, size_t buffer_size);
/** Serializes the config into a messagepack map. */
void config_write_messagepack(cmp_ctx_t* context, bootloader_config_t* config);
bootloader_config_t config_read(void* buffer, size_t buffer_size);
/** Updates the config from the keys found in the messagepack map.
*
* @note Keys not in the MessagePack map are left unchanged.
*/
void config_update_from_serialized(bootloader_config_t* config, cmp_ctx_t* context);
#ifdef __cplusplus
}
#endif
#endif