-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconfig.ino
40 lines (29 loc) · 899 Bytes
/
config.ino
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
#include "all_headers.h"
#include <Preferences.h>
#define PREF_NAME_SPACE "LORA_RELAY" // Max 15 chars
#define STR(x) #x
static Preferences pref;
// ----------------------------------------------------------------------------
void config_setup() {
config_load(R_NODE_ID);
}
// ----------------------------------------------------------------------------
void config_save(pref_reg_t reg) {
pref.begin(PREF_NAME_SPACE, false);
switch (reg) {
case R_NODE_ID:
pref.putUShort(STR(R_NODE_ID), getAddress());
break;
}
pref.end();
}
// ----------------------------------------------------------------------------
void config_load(pref_reg_t reg) {
pref.begin(PREF_NAME_SPACE, true);
switch (reg) {
case R_NODE_ID:
setAddress(pref.getUShort(STR(R_NODE_ID), getAddress()));
break;
}
pref.end();
}