From 81df3fbede15b8140cecaf91024517145a740dcf Mon Sep 17 00:00:00 2001 From: Peter Buchegger Date: Sun, 19 Jul 2020 21:09:06 +0200 Subject: [PATCH] add LoRa_APRS Lib --- platformio.ini | 5 +-- src/LoRa_APRS.cpp | 82 ----------------------------------------------- src/LoRa_APRS.h | 39 ---------------------- 3 files changed, 3 insertions(+), 123 deletions(-) delete mode 100644 src/LoRa_APRS.cpp delete mode 100644 src/LoRa_APRS.h diff --git a/platformio.ini b/platformio.ini index e10e4ce..d858ac2 100644 --- a/platformio.ini +++ b/platformio.ini @@ -9,10 +9,11 @@ monitor_speed = 115200 lib_deps = Adafruit GFX Library@1.7.5 Adafruit SSD1306 - LoRa APRS-Decoder-Lib - NTPClient APRS-IS-Lib + LoRa + LoRa-APRS-Lib + NTPClient AXP202X_Library check_tool = cppcheck check_flags = diff --git a/src/LoRa_APRS.cpp b/src/LoRa_APRS.cpp deleted file mode 100644 index 12918bb..0000000 --- a/src/LoRa_APRS.cpp +++ /dev/null @@ -1,82 +0,0 @@ -#include - -LoRa_APRS::LoRa_APRS() - : rx_frequency(LORA_RX_FREQUENCY), tx_frequency(LORA_TX_FREQUENCY), spreadingfactor(LORA_SPREADING_FACTOR), - signalbandwidth(LORA_SIGNAL_BANDWIDTH), codingrate4(LORA_CODING_RATE4), _LastReceivedMsg(0) -{ - SPI.begin(LORA_SCK, LORA_MISO, LORA_MOSI, LORA_CS); - LoRa.setPins(LORA_CS, LORA_RST, LORA_IRQ); -} - -bool LoRa_APRS::begin() -{ - if (!LoRa.begin(rx_frequency)) - { - return false; - } - LoRa.setSpreadingFactor(spreadingfactor); - LoRa.setSignalBandwidth(signalbandwidth); - LoRa.setCodingRate4(codingrate4); - LoRa.enableCrc(); - return true; -} - -bool LoRa_APRS::hasMessage() -{ - if(!LoRa.parsePacket()) - { - return false; - } - // read header: - char dummy[4]; - LoRa.readBytes(dummy, 3); - if(dummy[0] != '<') - { - // is no APRS message, ignore message - while(LoRa.available()) - { - LoRa.read(); - } - return false; - } - // read APRS data: - String str; - while(LoRa.available()) - { - str += (char)LoRa.read(); - } - _LastReceivedMsg = std::shared_ptr(new APRSMessage()); - _LastReceivedMsg->decode(str); - return true; -} - -std::shared_ptr LoRa_APRS::getMessage() -{ - return _LastReceivedMsg; -} - -int LoRa_APRS::getMessageRssi() -{ - return LoRa.packetRssi(); -} - -float LoRa_APRS::getMessageSnr() -{ - return LoRa.packetSnr(); -} - -// cppcheck-suppress unusedFunction -void LoRa_APRS::sendMessage(const std::shared_ptr msg) -{ - LoRa.setFrequency(tx_frequency); - String data = msg->encode(); - LoRa.beginPacket(); - // Header: - LoRa.write('<'); - LoRa.write(0xFF); - LoRa.write(0x01); - // APRS Data: - LoRa.write((const uint8_t *)data.c_str(), data.length()); - LoRa.endPacket(); - LoRa.setFrequency(rx_frequency); -} diff --git a/src/LoRa_APRS.h b/src/LoRa_APRS.h deleted file mode 100644 index b8ef880..0000000 --- a/src/LoRa_APRS.h +++ /dev/null @@ -1,39 +0,0 @@ -#ifndef LORA_H_ -#define LORA_H_ - -#include -#include -#include -#include - -#define LORA_RX_FREQUENCY (433775000) -#define LORA_TX_FREQUENCY (433900000) -#define LORA_SPREADING_FACTOR (12) -#define LORA_SIGNAL_BANDWIDTH (125E3) -#define LORA_CODING_RATE4 (5) - -class LoRa_APRS -{ -public: - LoRa_APRS(); - bool begin(); - - bool hasMessage(); - std::shared_ptr getMessage(); - int getMessageRssi(); - float getMessageSnr(); - - void sendMessage(const std::shared_ptr msg); - - // settings: - long rx_frequency; - long tx_frequency; - int spreadingfactor; - long signalbandwidth; - int codingrate4; - -private: - std::shared_ptr _LastReceivedMsg; -}; - -#endif