From 00fc7cd5b9bbc5b2ac6698bf3c95f4f0a4d1d4a0 Mon Sep 17 00:00:00 2001 From: jgromes Date: Mon, 14 Nov 2022 21:18:42 +0100 Subject: [PATCH] [Pager] Added optional custom frequnecy shift --- src/protocols/Pager/Pager.cpp | 7 ++++--- src/protocols/Pager/Pager.h | 3 ++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/protocols/Pager/Pager.cpp b/src/protocols/Pager/Pager.cpp index 59af5d1d..73d0ef5d 100644 --- a/src/protocols/Pager/Pager.cpp +++ b/src/protocols/Pager/Pager.cpp @@ -19,7 +19,7 @@ PagerClient::PagerClient(PhysicalLayer* phy) { _readBitInstance = _phy; } -int16_t PagerClient::begin(float base, uint16_t speed) { +int16_t PagerClient::begin(float base, uint16_t speed, uint16_t shift) { // calculate duration of 1 bit in us _speed = (float)speed/1000.0f; _bitDuration = (uint32_t)1000000/speed; @@ -32,7 +32,8 @@ int16_t PagerClient::begin(float base, uint16_t speed) { uint16_t step = round(_phy->getFreqStep()); // calculate raw frequency shift - _shift = RADIOLIB_PAGER_FREQ_SHIFT_HZ/step; + _shiftHz = shift; + _shift = _shiftHz/step; // initialize BCH encoder encoderInit(); @@ -226,7 +227,7 @@ int16_t PagerClient::startReceive(RADIOLIB_PIN_TYPE pin, uint32_t addr, uint32_t RADIOLIB_ASSERT(state); // set frequency deviation to 4.5 khz - state = _phy->setFrequencyDeviation((float)RADIOLIB_PAGER_FREQ_SHIFT_HZ / 1000.0f); + state = _phy->setFrequencyDeviation((float)_shiftHz / 1000.0f); RADIOLIB_ASSERT(state); // now set up the direct mode reception diff --git a/src/protocols/Pager/Pager.h b/src/protocols/Pager/Pager.h index 357e08a2..21a71eb8 100644 --- a/src/protocols/Pager/Pager.h +++ b/src/protocols/Pager/Pager.h @@ -86,7 +86,7 @@ class PagerClient { \returns \ref status_codes */ - int16_t begin(float base, uint16_t speed); + int16_t begin(float base, uint16_t speed, uint16_t shift = RADIOLIB_PAGER_FREQ_SHIFT_HZ); /*! \brief Method to send a tone-only alert to a destination pager. @@ -192,6 +192,7 @@ class PagerClient { float _speed; uint32_t _baseRaw; uint16_t _shift; + uint16_t _shiftHz; uint16_t _bitDuration; uint32_t _readBatchPos; uint32_t _filterAddr;