From 5c695fd22324d2650a7cbbd5da8be55eb047e92c Mon Sep 17 00:00:00 2001 From: Manuel Bl <10954524+manuelbl@users.noreply.github.com> Date: Tue, 5 Jan 2021 21:57:11 +0100 Subject: [PATCH] Upgrade to version 3.3 of arduino-lmic --- src/aes/other.c | 4 ++-- src/lmic/config.h | 14 +++++++++++--- src/lmic/lmic.h | 2 +- src/lmic/lorabase.h | 2 +- src/lmic/radio.c | 1 + 5 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/aes/other.c b/src/aes/other.c index 52febdb..7093fb4 100644 --- a/src/aes/other.c +++ b/src/aes/other.c @@ -34,9 +34,9 @@ // This should be defined elsewhere void lmic_aes_encrypt(u1_t *data, u1_t *key); -// global area for passing parameters (aux, key) and for storing round keys +// global area for passing parameters (aux, key) u4_t AESAUX[16/sizeof(u4_t)]; -u4_t AESKEY[11*16/sizeof(u4_t)]; +u4_t AESKEY[16/sizeof(u4_t)]; // Shift the given buffer left one bit static void shift_left(xref2u1_t buf, u1_t len) { diff --git a/src/lmic/config.h b/src/lmic/config.h index 8673b46..abd0538 100644 --- a/src/lmic/config.h +++ b/src/lmic/config.h @@ -187,9 +187,17 @@ #endif // LMIC_ENABLE_long_messages -// LMIC certification requires that this be enabled. -#if !defined(LMIC_ENABLE_long_messages) -# define LMIC_ENABLE_long_messages 1 /* PARAM */ +// LMIC certification requires full-length 255 frames, but to save RAM, +// a shorter maximum can be set. This controls both RX and TX buffers, +// so reducing this by 1 saves 2 bytes of RAM. +#if defined(LMIC_ENABLE_long_messages) && defined(LMIC_MAX_FRAME_LENGTH) +#error "Use only one of LMIC_ENABLE_long_messages or LMIC_MAX_FRAME_LENGTH" +#elif defined(LMIC_ENABLE_long_messages) && LMIC_ENABLE_long_messages == 0 +# define LMIC_MAX_FRAME_LENGTH 64 +#elif !defined(LMIC_MAX_FRAME_LENGTH) +# define LMIC_MAX_FRAME_LENGTH 255 +#elif LMIC_MAX_FRAME_LENGTH > 255 +#error "LMIC_MAX_FRAME_LENGTH cannot be larger than 255" #endif // LMIC_ENABLE_event_logging diff --git a/src/lmic/lmic.h b/src/lmic/lmic.h index 9463fa2..471f1f9 100644 --- a/src/lmic/lmic.h +++ b/src/lmic/lmic.h @@ -105,7 +105,7 @@ extern "C"{ #define ARDUINO_LMIC_VERSION_CALC(major, minor, patch, local) \ ((((major)*UINT32_C(1)) << 24) | (((minor)*UINT32_C(1)) << 16) | (((patch)*UINT32_C(1)) << 8) | (((local)*UINT32_C(1)) << 0)) -#define ARDUINO_LMIC_VERSION ARDUINO_LMIC_VERSION_CALC(3, 2, 0, 0) /* v3.2.0 */ +#define ARDUINO_LMIC_VERSION ARDUINO_LMIC_VERSION_CALC(3, 3, 0, 0) /* v3.3.0 */ #define ARDUINO_LMIC_VERSION_GET_MAJOR(v) \ ((((v)*UINT32_C(1)) >> 24u) & 0xFFu) diff --git a/src/lmic/lorabase.h b/src/lmic/lorabase.h index 93034c0..fc0fd2d 100644 --- a/src/lmic/lorabase.h +++ b/src/lmic/lorabase.h @@ -60,7 +60,7 @@ enum { ILLEGAL_RPS = 0xFF }; // Global maximum frame length enum { STD_PREAMBLE_LEN = 8 }; -enum { MAX_LEN_FRAME = LMIC_ENABLE_long_messages ? 255 : 64 }; +enum { MAX_LEN_FRAME = LMIC_MAX_FRAME_LENGTH }; enum { LEN_DEVNONCE = 2 }; enum { LEN_ARTNONCE = 3 }; enum { LEN_NETID = 3 }; diff --git a/src/lmic/radio.c b/src/lmic/radio.c index 92f69ee..b8f84e8 100644 --- a/src/lmic/radio.c +++ b/src/lmic/radio.c @@ -382,6 +382,7 @@ static void writeReg (u1_t addr, u1_t data ) { hal_spi_write(addr | 0x80, &data, 1); } +// ttn-esp32: it's safer if buffer is static static u1_t reg_value_buf[1]; static u1_t readReg (u1_t addr) {