From 7d0b3c66409a9bf051e958610b63ca1af5269fc4 Mon Sep 17 00:00:00 2001 From: Crsarmv7l <85343771+Crsarmv7l@users.noreply.github.com> Date: Tue, 26 Mar 2024 19:22:53 -0400 Subject: [PATCH 01/13] getFrequency implementation --- src/modules/CC1101/CC1101.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/modules/CC1101/CC1101.h b/src/modules/CC1101/CC1101.h index bb9791167..513dbe4db 100644 --- a/src/modules/CC1101/CC1101.h +++ b/src/modules/CC1101/CC1101.h @@ -730,6 +730,12 @@ class CC1101: public PhysicalLayer { */ int16_t setFrequency(float freq); + /*! + \brief gets carrier frequency. + \returns the freq currently set + */ + float getFrequency(); + /*! \brief Sets bit rate. Allowed values range from 0.025 to 600.0 kbps. \param br Bit rate to be set in kbps. From 40af21cab87d5f74fdeccbf61bcf24465f6889fa Mon Sep 17 00:00:00 2001 From: Crsarmv7l <85343771+Crsarmv7l@users.noreply.github.com> Date: Tue, 26 Mar 2024 19:26:07 -0400 Subject: [PATCH 02/13] getFrequency Method --- src/modules/CC1101/CC1101.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/modules/CC1101/CC1101.cpp b/src/modules/CC1101/CC1101.cpp index 16bd25ee5..6f8afae7e 100644 --- a/src/modules/CC1101/CC1101.cpp +++ b/src/modules/CC1101/CC1101.cpp @@ -422,6 +422,11 @@ int16_t CC1101::readData(uint8_t* data, size_t len) { return(state); } +float CC1101::getFrequency() { + // Get currently set Frequency + return (this->frequency); +} + int16_t CC1101::setFrequency(float freq) { // check allowed frequency range if(!(((freq > 300.0) && (freq < 348.0)) || From 294577cc6e235aafaed49f422e479daf7dc70c3d Mon Sep 17 00:00:00 2001 From: Crsarmv7l <85343771+Crsarmv7l@users.noreply.github.com> Date: Wed, 27 Mar 2024 00:09:44 -0400 Subject: [PATCH 03/13] Get bitrate method --- src/modules/CC1101/CC1101.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/modules/CC1101/CC1101.cpp b/src/modules/CC1101/CC1101.cpp index 6f8afae7e..476854287 100644 --- a/src/modules/CC1101/CC1101.cpp +++ b/src/modules/CC1101/CC1101.cpp @@ -473,6 +473,11 @@ int16_t CC1101::setBitRate(float br) { return(state); } +float CC1101::getBitRate() { + // Get currently set Bit rate + return (this->bitRate); +} + int16_t CC1101::setRxBandwidth(float rxBw) { RADIOLIB_CHECK_RANGE(rxBw, 58.0, 812.0, RADIOLIB_ERR_INVALID_RX_BANDWIDTH); From 8dd4f631553c1941d0a8b040f231231088c4794f Mon Sep 17 00:00:00 2001 From: Crsarmv7l <85343771+Crsarmv7l@users.noreply.github.com> Date: Wed, 27 Mar 2024 00:12:40 -0400 Subject: [PATCH 04/13] getBitRate --- src/modules/CC1101/CC1101.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/modules/CC1101/CC1101.h b/src/modules/CC1101/CC1101.h index 513dbe4db..4b9a3f903 100644 --- a/src/modules/CC1101/CC1101.h +++ b/src/modules/CC1101/CC1101.h @@ -732,7 +732,7 @@ class CC1101: public PhysicalLayer { /*! \brief gets carrier frequency. - \returns the freq currently set + \returns the freq currently set in Mhz */ float getFrequency(); @@ -743,6 +743,13 @@ class CC1101: public PhysicalLayer { */ int16_t setBitRate(float br); + /*! + \brief gets the currently set bit rate. + \returns the bit rate in kbps + */ + float getBitRate(); + + /*! \brief Sets receiver bandwidth. Allowed values are 58, 68, 81, 102, 116, 135, 162, 203, 232, 270, 325, 406, 464, 541, 650 and 812 kHz. From 025f5cfb65a376d84cb0acadd47740b20d903cbf Mon Sep 17 00:00:00 2001 From: Crsarmv7l <85343771+Crsarmv7l@users.noreply.github.com> Date: Wed, 27 Mar 2024 01:30:28 -0400 Subject: [PATCH 05/13] CalcRxBandwidth() method --- src/modules/CC1101/CC1101.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/modules/CC1101/CC1101.cpp b/src/modules/CC1101/CC1101.cpp index 476854287..7374d6be8 100644 --- a/src/modules/CC1101/CC1101.cpp +++ b/src/modules/CC1101/CC1101.cpp @@ -499,6 +499,25 @@ int16_t CC1101::setRxBandwidth(float rxBw) { return(RADIOLIB_ERR_INVALID_RX_BANDWIDTH); } +int16_t CC1101::CalcRxBandwidth() { + // Uncertainty ~ +/- 40ppm for a cheap CC1101 + // Uncertainty * 2 for both transmitter and receiver + float uncertainty = (getFrequency() * 40 * 2); + uncertainty = (uncertainty/1000); //Since bitrate is in khz + float minbw = (getBitRate() + uncertainty); + + int possibles[16] = {58, 68, 81, 102, 116, 135, 162, 203, 232, 270, 325, 406, 464, 541, 650, 812}; + + for (int i = 0; i < 16; i++) { + if (possibles[i] > minbw) { + int16_t state = setRxBandwidth(possibles[i]); + return(state); + break; + } + } + + } + int16_t CC1101::setFrequencyDeviation(float freqDev) { // set frequency deviation to lowest available setting (required for digimodes) float newFreqDev = freqDev; From 9e079c85c09688e22f04800ec391d2c3c845ea70 Mon Sep 17 00:00:00 2001 From: Crsarmv7l <85343771+Crsarmv7l@users.noreply.github.com> Date: Wed, 27 Mar 2024 01:34:35 -0400 Subject: [PATCH 06/13] CalcRxBandwidth(); --- src/modules/CC1101/CC1101.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/modules/CC1101/CC1101.h b/src/modules/CC1101/CC1101.h index 4b9a3f903..dabc1a2a3 100644 --- a/src/modules/CC1101/CC1101.h +++ b/src/modules/CC1101/CC1101.h @@ -758,6 +758,14 @@ class CC1101: public PhysicalLayer { */ int16_t setRxBandwidth(float rxBw); + /*! + \brief calculates and sets Rx bandwidth based on the freq, baud and freq uncertainty. + \Reimplement of atlas0fd00m (RfCat) CalculatePktChanBw function. + \Modified for worse ppm with the CC1101, and adjusted for the supportted CC1101 bw. + \returns \ref status_codes + */ + int16_t CalcRxBandwidth(); + /*! \brief Sets frequency deviation. Allowed values range from 1.587 to 380.8 kHz. \param freqDev Frequency deviation to be set in kHz. From 00a22fc38c315db20b89324a90d0a6ee96bf05e3 Mon Sep 17 00:00:00 2001 From: Crsarmv7l <85343771+Crsarmv7l@users.noreply.github.com> Date: Wed, 27 Mar 2024 08:26:54 -0400 Subject: [PATCH 07/13] Fix Notes --- src/modules/CC1101/CC1101.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/modules/CC1101/CC1101.cpp b/src/modules/CC1101/CC1101.cpp index 7374d6be8..3463d15f5 100644 --- a/src/modules/CC1101/CC1101.cpp +++ b/src/modules/CC1101/CC1101.cpp @@ -503,7 +503,7 @@ int16_t CC1101::CalcRxBandwidth() { // Uncertainty ~ +/- 40ppm for a cheap CC1101 // Uncertainty * 2 for both transmitter and receiver float uncertainty = (getFrequency() * 40 * 2); - uncertainty = (uncertainty/1000); //Since bitrate is in khz + uncertainty = (uncertainty/1000); //Since bitrate is in kBit float minbw = (getBitRate() + uncertainty); int possibles[16] = {58, 68, 81, 102, 116, 135, 162, 203, 232, 270, 325, 406, 464, 541, 650, 812}; From c40da39a4533f964fd5e05c93d189ff1722e686d Mon Sep 17 00:00:00 2001 From: Crsarmv7l <85343771+Crsarmv7l@users.noreply.github.com> Date: Wed, 27 Mar 2024 17:30:58 -0400 Subject: [PATCH 08/13] Changes for pull --- src/modules/CC1101/CC1101.cpp | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/src/modules/CC1101/CC1101.cpp b/src/modules/CC1101/CC1101.cpp index 3463d15f5..b6e8b7553 100644 --- a/src/modules/CC1101/CC1101.cpp +++ b/src/modules/CC1101/CC1101.cpp @@ -422,11 +422,6 @@ int16_t CC1101::readData(uint8_t* data, size_t len) { return(state); } -float CC1101::getFrequency() { - // Get currently set Frequency - return (this->frequency); -} - int16_t CC1101::setFrequency(float freq) { // check allowed frequency range if(!(((freq > 300.0) && (freq < 348.0)) || @@ -473,11 +468,6 @@ int16_t CC1101::setBitRate(float br) { return(state); } -float CC1101::getBitRate() { - // Get currently set Bit rate - return (this->bitRate); -} - int16_t CC1101::setRxBandwidth(float rxBw) { RADIOLIB_CHECK_RANGE(rxBw, 58.0, 812.0, RADIOLIB_ERR_INVALID_RX_BANDWIDTH); @@ -499,12 +489,12 @@ int16_t CC1101::setRxBandwidth(float rxBw) { return(RADIOLIB_ERR_INVALID_RX_BANDWIDTH); } -int16_t CC1101::CalcRxBandwidth() { +int16_t CC1101::autoSetRxBandwidth() { // Uncertainty ~ +/- 40ppm for a cheap CC1101 // Uncertainty * 2 for both transmitter and receiver - float uncertainty = (getFrequency() * 40 * 2); + float uncertainty = (this->frequency) * 40 * 2); uncertainty = (uncertainty/1000); //Since bitrate is in kBit - float minbw = (getBitRate() + uncertainty); + float minbw = (this->bitRate) + uncertainty); int possibles[16] = {58, 68, 81, 102, 116, 135, 162, 203, 232, 270, 325, 406, 464, 541, 650, 812}; @@ -512,10 +502,9 @@ int16_t CC1101::CalcRxBandwidth() { if (possibles[i] > minbw) { int16_t state = setRxBandwidth(possibles[i]); return(state); - break; } } - + return(RADIOLIB_ERR_UNKNOWN); } int16_t CC1101::setFrequencyDeviation(float freqDev) { From 49e140b4453bbda12504c697902b10c41d63bfb5 Mon Sep 17 00:00:00 2001 From: Crsarmv7l <85343771+Crsarmv7l@users.noreply.github.com> Date: Wed, 27 Mar 2024 17:37:10 -0400 Subject: [PATCH 09/13] Changes for pull 2 --- src/modules/CC1101/CC1101.h | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/src/modules/CC1101/CC1101.h b/src/modules/CC1101/CC1101.h index dabc1a2a3..69b8e4eb2 100644 --- a/src/modules/CC1101/CC1101.h +++ b/src/modules/CC1101/CC1101.h @@ -730,12 +730,6 @@ class CC1101: public PhysicalLayer { */ int16_t setFrequency(float freq); - /*! - \brief gets carrier frequency. - \returns the freq currently set in Mhz - */ - float getFrequency(); - /*! \brief Sets bit rate. Allowed values range from 0.025 to 600.0 kbps. \param br Bit rate to be set in kbps. @@ -743,13 +737,6 @@ class CC1101: public PhysicalLayer { */ int16_t setBitRate(float br); - /*! - \brief gets the currently set bit rate. - \returns the bit rate in kbps - */ - float getBitRate(); - - /*! \brief Sets receiver bandwidth. Allowed values are 58, 68, 81, 102, 116, 135, 162, 203, 232, 270, 325, 406, 464, 541, 650 and 812 kHz. @@ -760,11 +747,11 @@ class CC1101: public PhysicalLayer { /*! \brief calculates and sets Rx bandwidth based on the freq, baud and freq uncertainty. - \Reimplement of atlas0fd00m (RfCat) CalculatePktChanBw function. - \Modified for worse ppm with the CC1101, and adjusted for the supportted CC1101 bw. + Reimplement of atlas0fd00m's (RfCat) CalculatePktChanBw function. + Modified for worse ppm with the CC1101, and adjusted for the supportted CC1101 bw. \returns \ref status_codes */ - int16_t CalcRxBandwidth(); + int16_t autoSetRxBandwidth(); /*! \brief Sets frequency deviation. Allowed values range from 1.587 to 380.8 kHz. From e5353a368057ce0fc0748630bf7ed6691eedbbca Mon Sep 17 00:00:00 2001 From: Crsarmv7l <85343771+Crsarmv7l@users.noreply.github.com> Date: Wed, 27 Mar 2024 17:38:33 -0400 Subject: [PATCH 10/13] Update keywords.txt --- keywords.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/keywords.txt b/keywords.txt index 48efe6325..967753c9f 100644 --- a/keywords.txt +++ b/keywords.txt @@ -134,6 +134,7 @@ getSNR KEYWORD2 getDataRate KEYWORD2 setBitRate KEYWORD2 setRxBandwidth KEYWORD2 +autoSetRxBandwidth KEYWORD2 setAFCBandwidth KEYWORD2 setAFC KEYWORD2 setAFCAGCTrigger KEYWORD2 @@ -436,4 +437,4 @@ RADIOLIB_ERR_N_FCNT_DOWN_INVALID LITERAL1 RADIOLIB_ERR_A_FCNT_DOWN_INVALID LITERAL1 RADIOLIB_ERR_DATA_RATE_INVALID LITERAL1 RADIOLIB_ERR_DWELL_TIME_EXCEEDED LITERAL1 -RADIOLIB_ERR_CHECKSUM_MISMATCH LITERAL1 \ No newline at end of file +RADIOLIB_ERR_CHECKSUM_MISMATCH LITERAL1 From 310dfc924265f5b14131737ba59c62eaac1ac1f3 Mon Sep 17 00:00:00 2001 From: Crsarmv7l <85343771+Crsarmv7l@users.noreply.github.com> Date: Thu, 28 Mar 2024 13:14:17 -0400 Subject: [PATCH 11/13] Revert to hopefully bring in current --- keywords.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/keywords.txt b/keywords.txt index 967753c9f..43eb68ff0 100644 --- a/keywords.txt +++ b/keywords.txt @@ -134,7 +134,6 @@ getSNR KEYWORD2 getDataRate KEYWORD2 setBitRate KEYWORD2 setRxBandwidth KEYWORD2 -autoSetRxBandwidth KEYWORD2 setAFCBandwidth KEYWORD2 setAFC KEYWORD2 setAFCAGCTrigger KEYWORD2 From fb35416b346e0a759d2c50cb0f94bf2e36746ce1 Mon Sep 17 00:00:00 2001 From: Crsarmv7l <85343771+Crsarmv7l@users.noreply.github.com> Date: Thu, 28 Mar 2024 13:19:18 -0400 Subject: [PATCH 12/13] Fix () --- src/modules/CC1101/CC1101.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modules/CC1101/CC1101.cpp b/src/modules/CC1101/CC1101.cpp index b6e8b7553..2965a343a 100644 --- a/src/modules/CC1101/CC1101.cpp +++ b/src/modules/CC1101/CC1101.cpp @@ -492,9 +492,9 @@ int16_t CC1101::setRxBandwidth(float rxBw) { int16_t CC1101::autoSetRxBandwidth() { // Uncertainty ~ +/- 40ppm for a cheap CC1101 // Uncertainty * 2 for both transmitter and receiver - float uncertainty = (this->frequency) * 40 * 2); + float uncertainty = ((this->frequency) * 40 * 2); uncertainty = (uncertainty/1000); //Since bitrate is in kBit - float minbw = (this->bitRate) + uncertainty); + float minbw = ((this->bitRate) + uncertainty); int possibles[16] = {58, 68, 81, 102, 116, 135, 162, 203, 232, 270, 325, 406, 464, 541, 650, 812}; From 7f49e69959aecd45cd045f2dbb570a641de0789f Mon Sep 17 00:00:00 2001 From: Crsarmv7l <85343771+Crsarmv7l@users.noreply.github.com> Date: Thu, 28 Mar 2024 13:29:38 -0400 Subject: [PATCH 13/13] Re add --- keywords.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/keywords.txt b/keywords.txt index 43eb68ff0..d9d595072 100644 --- a/keywords.txt +++ b/keywords.txt @@ -134,6 +134,7 @@ getSNR KEYWORD2 getDataRate KEYWORD2 setBitRate KEYWORD2 setRxBandwidth KEYWORD2 +autoSetRxBandwidth KEYWORD2 setAFCBandwidth KEYWORD2 setAFC KEYWORD2 setAFCAGCTrigger KEYWORD2 @@ -437,3 +438,4 @@ RADIOLIB_ERR_A_FCNT_DOWN_INVALID LITERAL1 RADIOLIB_ERR_DATA_RATE_INVALID LITERAL1 RADIOLIB_ERR_DWELL_TIME_EXCEEDED LITERAL1 RADIOLIB_ERR_CHECKSUM_MISMATCH LITERAL1 +RADIOLIB_LORAWAN_NO_DOWNLINK LITERAL1