1 #ifndef __AVR_SETTINGS_H__
2 #define __AVR_SETTINGS_H__
8 typedef uint16_t settings_key_t;
10 #define SETTINGS_KEY_EUI64 'E'*256+'8'
11 #define SETTINGS_KEY_EUI48 'E'*256+'6'
12 #define SETTINGS_KEY_CHANNEL 'C'*256+'H'
13 #define SETTINGS_KEY_TXPOWER 'T'*256+'P'
14 #define SETTINGS_KEY_PAN_ID 'P'*256+'N'
15 #define SETTINGS_KEY_PAN_ADDR 'P'*256+'A'
16 #define SETTINGS_KEY_AES128KEY 'S'*256+'K'
17 #define SETTINGS_KEY_AES128ENABLED 'S'*256+'E'
21 SETTINGS_STATUS_INVALID_ARGUMENT,
22 SETTINGS_STATUS_NOT_FOUND,
23 SETTINGS_STATUS_OUT_OF_SPACE,
24 SETTINGS_STATUS_UNIMPLEMENTED,
25 SETTINGS_STATUS_FAILURE,
29 #define SETTINGS_LAST_INDEX (0xFF)
31 #define SETTINGS_INVALID_KEY (0x00)
33 #define SETTINGS_MAX_VALUE_SIZE (0x3FFF) // 16383 bytes
35 extern settings_status_t settings_get(settings_key_t key,uint8_t index,
unsigned char* value,
size_t* value_size);
36 extern settings_status_t settings_add(settings_key_t key,
const unsigned char* value,
size_t value_size);
37 extern bool settings_check(settings_key_t key,uint8_t index);
38 extern void settings_wipe(
void);
40 extern settings_status_t settings_set(settings_key_t key,
const unsigned char* value,
size_t value_size);
41 extern settings_status_t settings_delete(settings_key_t key,uint8_t index);
47 settings_get_uint8(settings_key_t key,uint8_t index) {
49 size_t sizeof_uint8 =
sizeof(uint8_t);
50 settings_get(key,index,(
unsigned char*)&ret,&sizeof_uint8);
54 static inline settings_status_t
55 settings_add_uint8(settings_key_t key,uint8_t value) {
56 return settings_add(key,(
const unsigned char*)&value,
sizeof(uint8_t));
59 static inline settings_status_t
60 settings_set_uint8(settings_key_t key,uint8_t value) {
61 return settings_set(key,(
const unsigned char*)&value,
sizeof(uint8_t));
64 static inline uint16_t
65 settings_get_uint16(settings_key_t key,uint8_t index) {
67 size_t sizeof_uint16 =
sizeof(uint16_t);
68 settings_get(key,index,(
unsigned char*)&ret,&sizeof_uint16);
72 static inline settings_status_t
73 settings_add_uint16(settings_key_t key,uint16_t value) {
74 return settings_add(key,(
const unsigned char*)&value,
sizeof(uint16_t));
77 static inline settings_status_t
78 settings_set_uint16(settings_key_t key,uint16_t value) {
79 return settings_set(key,(
const unsigned char*)&value,
sizeof(uint16_t));
82 static inline uint32_t
83 settings_get_uint32(settings_key_t key,uint8_t index) {
85 size_t sizeof_uint32 =
sizeof(uint32_t);
86 settings_get(key,index,(
unsigned char*)&ret,&sizeof_uint32);
90 static inline settings_status_t
91 settings_add_uint32(settings_key_t key,uint32_t value) {
92 return settings_add(key,(
const unsigned char*)&value,
sizeof(uint32_t));
95 static inline settings_status_t
96 settings_set_uint32(settings_key_t key,uint32_t value) {
97 return settings_set(key,(
const unsigned char*)&value,
sizeof(uint32_t));
100 static inline uint64_t
101 settings_get_uint64(settings_key_t key,uint8_t index) {
103 size_t sizeof_uint64 =
sizeof(uint64_t);
104 settings_get(key,index,(
unsigned char*)&ret,&sizeof_uint64);
108 static inline settings_status_t
109 settings_add_uint64(settings_key_t key,uint64_t value) {
110 return settings_add(key,(
const unsigned char*)&value,
sizeof(uint64_t));
113 static inline settings_status_t
114 settings_set_uint64(settings_key_t key,uint64_t value) {
115 return settings_set(key,(
const unsigned char*)&value,
sizeof(uint64_t));