From 09e2cba9099d1b6f3d81371cf42ba066d4b56257 Mon Sep 17 00:00:00 2001 From: Klaus K Wilting Date: Fri, 23 Mar 2018 11:57:19 +0100 Subject: [PATCH] fixed error in DEVEUI parsing --- src/main.cpp | 20 +++++++++++++------- src/main.h | 2 +- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 5c65fc9d..d8edb57d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -82,18 +82,24 @@ void RevBytes(unsigned char* b, size_t c); #endif // VERBOSE // LMIC callback functions -void os_getDevKey (u1_t *buf) { memcpy(buf, APPKEY, 16);} +void os_getDevKey (u1_t *buf) { + memcpy(buf, APPKEY, 16); +} + void os_getArtEui (u1_t *buf) { memcpy(buf, APPEUI, 8); RevBytes(buf, 8); // TTN requires it in LSB First order, so we swap bytes } + void os_getDevEui (u1_t* buf) { - #ifdef DEVEUI - memcpy(buf, DEVEUI, 8); - RevBytes(buf, 8); // TTN requires it in LSB First order, so we swap bytes - #else - gen_lora_deveui(buf); - #endif + int i=0, k=0; + memcpy(buf, DEVEUI, 8); // get fixed DEVEUI from loraconf.h + for (i=0; i<8 ; i++) + k += buf[i]; + if (k) + RevBytes(buf, 8); // use fixed DEVEUI and swap bytes to LSB format + else + gen_lora_deveui(buf); // generate DEVEUI from device's MAC } // LMIC enhanced Pin mapping diff --git a/src/main.h b/src/main.h index 50191325..3f347f48 100644 --- a/src/main.h +++ b/src/main.h @@ -1,5 +1,5 @@ // program version -#define PROGVERSION "1.2.32" // use max 10 chars here! +#define PROGVERSION "1.2.33" // use max 10 chars here! #define PROGNAME "PAXCNT" // Verbose enables serial output