From 96a65477101c95594d47a2a571899a2755570a26 Mon Sep 17 00:00:00 2001 From: sh123 Date: Wed, 7 Apr 2021 09:24:22 +0300 Subject: [PATCH] Moved frequency correction minimum delta value to config --- config.h | 3 ++- esp32_loraprs.ino | 5 ++++- loraprs_config.h | 5 ++++- loraprs_service.cpp | 2 +- loraprs_service.h | 2 -- 5 files changed, 11 insertions(+), 6 deletions(-) diff --git a/config.h b/config.h index 6b6196b..9445f71 100644 --- a/config.h +++ b/config.h @@ -39,7 +39,8 @@ #define CFG_WIFI_KEY "" #define CFG_FREQ_CORR false // NB! incoming interrupts may stop working on frequent corrections when enabled - // test with your module before heavy usage +#define CFG_FREQ_CORR_DELTA 1000 // test with your module before heavy usage + #define CFG_PERSISTENT_APRS true #define CFG_DIGIREPEAT false #define CFG_RF_TO_IS true diff --git a/esp32_loraprs.ino b/esp32_loraprs.ino index 896e992..7c5c289 100644 --- a/esp32_loraprs.ino +++ b/esp32_loraprs.ino @@ -52,8 +52,11 @@ void initializeConfig(LoraPrs::Config &cfg) { cfg.WifiSsid = CFG_WIFI_SSID; cfg.WifiKey = CFG_WIFI_KEY; - // configuration flags and features + // frequency correction cfg.EnableAutoFreqCorrection = CFG_FREQ_CORR; // automatic tune to any incoming packet frequency + cfg.AutoFreqCorrectionDeltaHz = CFG_FREQ_CORR_DELTA; + + // configuration flags and features cfg.EnableSignalReport = true; // signal report will be added to the comment sent to aprsis cfg.EnablePersistentAprsConnection = CFG_PERSISTENT_APRS; // keep aprsis connection open, otherwise connect on new data only cfg.EnableRfToIs = CFG_RF_TO_IS; // send data from rf to aprsis diff --git a/loraprs_config.h b/loraprs_config.h index 110a0bf..d575011 100644 --- a/loraprs_config.h +++ b/loraprs_config.h @@ -43,9 +43,12 @@ struct Config String AprsRawBeacon; // aprs string for server beacon, e.g. NOCALL-1>APZMDM,WIDE1-1:!0000.00N/00000.00E#LoRA 433.775MHz/BW125/SF12/CR7/0xf3 int AprsRawBeaconPeriodMinutes; // aprs beacon period + // frequency correction + bool EnableAutoFreqCorrection; // true - correct own frequency based on received packet frequency deviation + int AutoFreqCorrectionDeltaHz; // correct when difference is larger than this value + // aprs logic bool EnableSignalReport; // true - append signal report on server side for the client to be sent to APRS-IS - bool EnableAutoFreqCorrection; // true - correct own frequency based on received packet frequency deviation bool EnablePersistentAprsConnection; // true - keep aprs-is connection active all the time bool EnableRfToIs; // true - enable RF to APRS-IS submission bool EnableIsToRf; // true - enable APRS-IS to RF submission diff --git a/loraprs_service.cpp b/loraprs_service.cpp index 704ac7d..268d7f3 100644 --- a/loraprs_service.cpp +++ b/loraprs_service.cpp @@ -287,7 +287,7 @@ void Service::onRigPacket(void *packet, int packetLength) { long frequencyError = LoRa.packetFrequencyError(); - if (config_.EnableAutoFreqCorrection && abs(frequencyError) > CfgFreqCorrMinHz) { + if (config_.EnableAutoFreqCorrection && abs(frequencyError) > config_.AutoFreqCorrectionDeltaHz) { config_.LoraFreq -= frequencyError; Serial.print("Correcting frequency: "); Serial.println(frequencyError); LoRa.setFrequency(config_.LoraFreq); diff --git a/loraprs_service.h b/loraprs_service.h index 72a20b0..bc50f5d 100644 --- a/loraprs_service.h +++ b/loraprs_service.h @@ -85,8 +85,6 @@ private: const int CfgPollDelayMs = 5; // main loop delay const int CfgWiFiConnRetryMaxTimes = 10; // wifi number of connection retries const int CfgMaxAX25PayloadSize = 512; // maximum ax25 payload size - const int CfgFreqCorrMinHz = 1000; // correct if deviation is larger than this number - // NB! small value causes frequent corrections, which locks LoRa ISR const int CfgMaxAprsInMessageSize = 255; // maximum aprsis to rf message size // csma parameters, overriden with KISS commands