From aecef283807d5e5fb0e88bbf4dba41b25bd75cc4 Mon Sep 17 00:00:00 2001 From: StevenCellist Date: Thu, 10 Oct 2024 15:33:19 +0200 Subject: [PATCH] [LoRaWAN] Move templates to .h to prevent linker errors --- src/protocols/LoRaWAN/LoRaWAN.cpp | 26 -------------------------- src/protocols/LoRaWAN/LoRaWAN.h | 26 ++++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/src/protocols/LoRaWAN/LoRaWAN.cpp b/src/protocols/LoRaWAN/LoRaWAN.cpp index 5e994c672..418fd263d 100644 --- a/src/protocols/LoRaWAN/LoRaWAN.cpp +++ b/src/protocols/LoRaWAN/LoRaWAN.cpp @@ -3390,30 +3390,4 @@ uint16_t LoRaWANNode::checkSum16(const uint8_t *key, uint16_t keyLen) { return(checkSum); } -template -T LoRaWANNode::ntoh(uint8_t* buff, size_t size) { - uint8_t* buffPtr = buff; - size_t targetSize = sizeof(T); - if(size != 0) { - targetSize = size; - } - T res = 0; - for(size_t i = 0; i < targetSize; i++) { - res |= (uint32_t)(*(buffPtr++)) << 8*i; - } - return(res); -} - -template -void LoRaWANNode::hton(uint8_t* buff, T val, size_t size) { - uint8_t* buffPtr = buff; - size_t targetSize = sizeof(T); - if(size != 0) { - targetSize = size; - } - for(size_t i = 0; i < targetSize; i++) { - *(buffPtr++) = val >> 8*i; - } -} - #endif diff --git a/src/protocols/LoRaWAN/LoRaWAN.h b/src/protocols/LoRaWAN/LoRaWAN.h index 6ff198dfe..da00dcfe2 100644 --- a/src/protocols/LoRaWAN/LoRaWAN.h +++ b/src/protocols/LoRaWAN/LoRaWAN.h @@ -1127,4 +1127,30 @@ class LoRaWANNode { static void hton(uint8_t* buff, T val, size_t size = 0); }; +template +T LoRaWANNode::ntoh(uint8_t* buff, size_t size) { + uint8_t* buffPtr = buff; + size_t targetSize = sizeof(T); + if(size != 0) { + targetSize = size; + } + T res = 0; + for(size_t i = 0; i < targetSize; i++) { + res |= (uint32_t)(*(buffPtr++)) << 8*i; + } + return(res); +} + +template +void LoRaWANNode::hton(uint8_t* buff, T val, size_t size) { + uint8_t* buffPtr = buff; + size_t targetSize = sizeof(T); + if(size != 0) { + targetSize = size; + } + for(size_t i = 0; i < targetSize; i++) { + *(buffPtr++) = val >> 8*i; + } +} + #endif