From 894e9122521655856276b6c477f6b2bd8c65623c Mon Sep 17 00:00:00 2001 From: Federico Maggi Date: Thu, 1 Dec 2022 13:24:42 +0100 Subject: [PATCH 1/2] [RF69] Fixed setPromiscuousMode(false) corner case Signed-off-by: Federico Maggi --- src/modules/RF69/RF69.cpp | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/modules/RF69/RF69.cpp b/src/modules/RF69/RF69.cpp index 5cfd833a..bb9bd1be 100644 --- a/src/modules/RF69/RF69.cpp +++ b/src/modules/RF69/RF69.cpp @@ -801,15 +801,8 @@ int16_t RF69::enableSyncWordFiltering(uint8_t maxErrBits) { } int16_t RF69::disableSyncWordFiltering() { - // disable preamble detection and generation - int16_t state = _mod->SPIsetRegValue(RADIOLIB_RF69_REG_PREAMBLE_LSB, 0, 7, 0); - state |= _mod->SPIsetRegValue(RADIOLIB_RF69_REG_PREAMBLE_MSB, 0, 7, 0); - RADIOLIB_ASSERT(state); - // disable sync word detection and generation - state = _mod->SPIsetRegValue(RADIOLIB_RF69_REG_SYNC_CONFIG, RADIOLIB_RF69_SYNC_OFF | RADIOLIB_RF69_FIFO_FILL_CONDITION, 7, 6); - - return(state); + return(_mod->SPIsetRegValue(RADIOLIB_RF69_REG_SYNC_CONFIG, RADIOLIB_RF69_SYNC_OFF | RADIOLIB_RF69_FIFO_FILL_CONDITION, 7, 6)); } int16_t RF69::enableContinuousModeBitSync() { @@ -846,14 +839,22 @@ int16_t RF69::setPromiscuousMode(bool promiscuous) { } if (promiscuous == true) { - // disable preamble and sync word filtering and insertion + // disable preamble detection and generation + state = setPreambleLength(0); + RADIOLIB_ASSERT(state); + + // disable sync word filtering and insertion state = disableSyncWordFiltering(); RADIOLIB_ASSERT(state); // disable CRC filtering state = setCrcFiltering(false); } else { - // enable preamble and sync word filtering and insertion + // enable preamble detection and generation + state = setPreambleLength(RADIOLIB_RF69_DEFAULT_PREAMBLELEN); + RADIOLIB_ASSERT(state); + + // enable sync word filtering and insertion state = enableSyncWordFiltering(); RADIOLIB_ASSERT(state); From 09669eeb268ea17703ffe77cda54f3074e97986c Mon Sep 17 00:00:00 2001 From: Federico Maggi Date: Thu, 1 Dec 2022 13:32:47 +0100 Subject: [PATCH 2/2] [CC1101] Fix `setPromiscuousMode(false)` bug Signed-off-by: Federico Maggi --- src/modules/CC1101/CC1101.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/modules/CC1101/CC1101.cpp b/src/modules/CC1101/CC1101.cpp index dc994bae..f943a470 100644 --- a/src/modules/CC1101/CC1101.cpp +++ b/src/modules/CC1101/CC1101.cpp @@ -824,14 +824,21 @@ int16_t CC1101::setPromiscuousMode(bool promiscuous) { } if (promiscuous == true) { - // disable preamble and sync word filtering and insertion + // disable preamble detection and generation + state = setPreambleLength(0); + RADIOLIB_ASSERT(state); + + // disable sync word filtering and insertion state = disableSyncWordFiltering(); RADIOLIB_ASSERT(state); // disable CRC filtering state = setCrcFiltering(false); } else { - // enable preamble and sync word filtering and insertion + state = setPreambleLength(RADIOLIB_CC1101_DEFAULT_PREAMBLELEN); + RADIOLIB_ASSERT(state); + + // enable sync word filtering and insertion state = enableSyncWordFiltering(); RADIOLIB_ASSERT(state);