From 7ed2b17b35c0ef379663dfb1b0be256cdabe7978 Mon Sep 17 00:00:00 2001 From: Scott Powell Date: Fri, 31 Jan 2025 12:46:33 +1100 Subject: [PATCH] * added LLCC68 module support --- src/helpers/CustomLLCC68.h | 16 ++++++++++++++++ src/helpers/CustomLLCC68Wrapper.h | 21 +++++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 src/helpers/CustomLLCC68.h create mode 100644 src/helpers/CustomLLCC68Wrapper.h diff --git a/src/helpers/CustomLLCC68.h b/src/helpers/CustomLLCC68.h new file mode 100644 index 00000000..9d829934 --- /dev/null +++ b/src/helpers/CustomLLCC68.h @@ -0,0 +1,16 @@ +#pragma once + +#include + +#define SX126X_IRQ_HEADER_VALID 0b0000010000 // 4 4 valid LoRa header received + +class CustomLLCC68 : public LLCC68 { + public: + CustomLLCC68(Module *mod) : LLCC68(mod) { } + + bool isReceiving() { + uint16_t irq = getIrqStatus(); + bool hasPreamble = (irq & SX126X_IRQ_HEADER_VALID); + return hasPreamble; + } +}; \ No newline at end of file diff --git a/src/helpers/CustomLLCC68Wrapper.h b/src/helpers/CustomLLCC68Wrapper.h new file mode 100644 index 00000000..5647798c --- /dev/null +++ b/src/helpers/CustomLLCC68Wrapper.h @@ -0,0 +1,21 @@ +#pragma once + +#include "CustomLLCC68.h" +#include "RadioLibWrappers.h" + +class CustomLLCC68Wrapper : public RadioLibWrapper { +public: + CustomLLCC68Wrapper(CustomLLCC68& radio, mesh::MainBoard& board) : RadioLibWrapper(radio, board) { } + bool isReceiving() override { + if (((CustomLLCC68 *)_radio)->isReceiving()) return true; + + idle(); // put sx126x into standby + // do some basic CAD (blocks for ~12780 micros (on SF 10)!) + bool activity = (((CustomLLCC68 *)_radio)->scanChannel() == RADIOLIB_LORA_DETECTED); + idle(); + + return activity; + } + float getLastRSSI() const override { return ((CustomLLCC68 *)_radio)->getRSSI(); } + float getLastSNR() const override { return ((CustomLLCC68 *)_radio)->getSNR(); } +};