From cdb5e5e0fd64e54dba051e97fe0be6a288ae7112 Mon Sep 17 00:00:00 2001 From: DevilBinder <29162669+Devilbinder@users.noreply.github.com> Date: Mon, 20 Jun 2022 22:38:28 +0200 Subject: [PATCH] Add dependency switch macro --- fdrs_sensor.cpp | 6 +++++- fdrs_sensor.h | 8 +++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/fdrs_sensor.cpp b/fdrs_sensor.cpp index 6d7a1a6..d91e200 100644 --- a/fdrs_sensor.cpp +++ b/fdrs_sensor.cpp @@ -138,6 +138,8 @@ void FDRS_EspNow::transmit(DataReading *fdrsData, uint8_t _data_count){ DBG(" ESP-NOW sent."); } +#ifdef USE_LORA + FDRSLoRa::FDRSLoRa(uint8_t gtwy_mac, uint8_t reading_id,uint8_t miso,uint8_t mosi,uint8_t sck, uint8_t ss,uint8_t rst,uint8_t dio0,uint32_t band,uint8_t sf): FDRSBase(gtwy_mac,reading_id), _miso(miso), @@ -184,4 +186,6 @@ void FDRSLoRa::buildPacket(uint8_t* mac, DataReading * packet, uint8_t len) { void FDRSLoRa::transmit(DataReading *fdrsData, uint8_t _data_count){ buildPacket(_gatewayAddress, fdrsData, _data_count); DBG(" LoRa sent."); -} \ No newline at end of file +} + +#endif diff --git a/fdrs_sensor.h b/fdrs_sensor.h index b07923f..51f65be 100644 --- a/fdrs_sensor.h +++ b/fdrs_sensor.h @@ -18,6 +18,7 @@ #include #include #endif + #ifdef USE_LORA #include "LoRa.h" #endif @@ -69,7 +70,6 @@ typedef struct __attribute__((packed)) DataReading { float data; uint16_t id; uint8_t type; - } DataReading; class FDRSBase{ @@ -99,7 +99,9 @@ private: class FDRS_EspNow: public FDRSBase{ public: + FDRS_EspNow(uint8_t gtwy_mac, uint8_t reading_id); + private: uint8_t _gatewayAddress[ESP_GATEWAY_ADDRESS_SIZE]; @@ -110,7 +112,9 @@ private: class FDRSLoRa: public FDRSBase{ public: + FDRSLoRa(uint8_t gtwy_mac, uint8_t reading_id,uint8_t miso,uint8_t mosi,uint8_t sck, uint8_t ss,uint8_t rst,uint8_t dio0,uint32_t band,uint8_t sf); + private: uint8_t _gatewayAddress[LORA_GATEWAY_ADDRESS_SIZE]; @@ -124,8 +128,6 @@ private: uint8_t _sf; void buildPacket(uint8_t* mac, DataReading * packet, uint8_t len); - - void transmit(DataReading *fdrsData, uint8_t _data_count) override; void init(void) override;