if prefs file open fails, don't try other operations
This commit is contained in:
parent
5a11a7a880
commit
e84a840190
11
main/ttn.ino
11
main/ttn.ino
@ -176,12 +176,13 @@ void onEvent(ev_t event) {
|
||||
Serial.println();
|
||||
|
||||
Preferences p;
|
||||
p.begin("lora", false);
|
||||
if(p.begin("lora", false)) {
|
||||
p.putUInt("netId", netid);
|
||||
p.putUInt("devAddr", devaddr);
|
||||
p.putBytes("nwkKey", nwkKey, sizeof(nwkKey));
|
||||
p.putBytes("artKey", artKey, sizeof(artKey));
|
||||
p.end();
|
||||
}
|
||||
break; }
|
||||
case EV_TXCOMPLETE:
|
||||
Serial.println(F("EV_TXCOMPLETE (inc. RX win. wait)"));
|
||||
@ -226,11 +227,12 @@ void ttn_response(uint8_t * buffer, size_t len) {
|
||||
static void initCount() {
|
||||
if(count == 0) {
|
||||
Preferences p;
|
||||
p.begin("lora", true);
|
||||
if(p.begin("lora", true)) {
|
||||
count = p.getUInt("count", 0);
|
||||
p.end();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool ttn_setup() {
|
||||
@ -326,7 +328,7 @@ void ttn_join() {
|
||||
#endif
|
||||
|
||||
Preferences p;
|
||||
p.begin("lora", true);
|
||||
p.begin("lora", true); // we intentionally ignore failure here
|
||||
uint32_t netId = p.getUInt("netId", UINT32_MAX);
|
||||
uint32_t devAddr = p.getUInt("devAddr", UINT32_MAX);
|
||||
uint8_t nwkKey[16], artKey[16];
|
||||
@ -377,11 +379,12 @@ static void ttn_set_cnt() {
|
||||
lastWriteMsec = now;
|
||||
|
||||
Preferences p;
|
||||
p.begin("lora", false);
|
||||
if(p.begin("lora", false)) {
|
||||
p.putUInt("count", count);
|
||||
p.end();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ttn_send(uint8_t * data, uint8_t data_size, uint8_t port, bool confirmed){
|
||||
ttn_set_cnt(); // we are about to send using the current packet count
|
||||
|
Loading…
Reference in New Issue
Block a user