From 57fe692f38b66148d39a3a8e5bbfe847215ff81e Mon Sep 17 00:00:00 2001 From: jerryneedell Date: Sun, 18 Jul 2021 12:37:43 -0400 Subject: [PATCH 1/3] enable CRC by default, add crc kwarg to init, update examples to remove explicit crc enable --- adafruit_rfm9x.py | 11 +++++++---- examples/rfm9x_node1.py | 2 -- examples/rfm9x_node1_ack.py | 2 -- examples/rfm9x_node1_bonnet.py | 3 --- examples/rfm9x_node2.py | 2 -- examples/rfm9x_node2_ack.py | 2 -- 6 files changed, 7 insertions(+), 15 deletions(-) diff --git a/adafruit_rfm9x.py b/adafruit_rfm9x.py index 6e223cb..8dfa083 100644 --- a/adafruit_rfm9x.py +++ b/adafruit_rfm9x.py @@ -127,6 +127,7 @@ class RFM9x: - baudrate: Baud rate of the SPI connection, default is 10mhz but you might choose to lower to 1mhz if using long wires or a breadboard. - agc: Boolean to Enable/Disable Automatic Gain Control - Default=False (AGC off) + - agc: Boolean to Enable/Disable Cyclic Redundancy Check - Default=True (CRC Enabled) Remember this library makes a best effort at receiving packets with pure Python code. Trying to receive packets too quickly will result in lost data so limit yourself to simple scenarios of sending and receiving single @@ -230,7 +231,8 @@ def __init__( preamble_length=8, high_power=True, baudrate=5000000, - agc=False + agc=False, + crc=True ): self.high_power = high_power # Device support SPI mode 0 (polarity & phase = 0) up to a max of 10mhz. @@ -273,9 +275,10 @@ def __init__( self.signal_bandwidth = 125000 self.coding_rate = 5 self.spreading_factor = 7 - # Default to disable CRC checking on incoming packets. - self.enable_crc = False - # set AGC - Default = True + # Default to enable CRC checking on incoming packets. + self.enable_crc = crc + # set AGC - Default = False + """CRC Enable state""" self.auto_agc = agc """Automatic Gain Control state""" # Set transmit power to 13 dBm, a safe value any module supports. diff --git a/examples/rfm9x_node1.py b/examples/rfm9x_node1.py index 6107ac4..89d24c5 100644 --- a/examples/rfm9x_node1.py +++ b/examples/rfm9x_node1.py @@ -27,8 +27,6 @@ # Initialze RFM radio rfm9x = adafruit_rfm9x.RFM9x(spi, CS, RESET, RADIO_FREQ_MHZ) -# enable CRC checking -rfm9x.enable_crc = True # set node addresses rfm9x.node = 1 rfm9x.destination = 2 diff --git a/examples/rfm9x_node1_ack.py b/examples/rfm9x_node1_ack.py index 2e30a43..992e6db 100644 --- a/examples/rfm9x_node1_ack.py +++ b/examples/rfm9x_node1_ack.py @@ -27,8 +27,6 @@ # Initialze RFM radio rfm9x = adafruit_rfm9x.RFM9x(spi, CS, RESET, RADIO_FREQ_MHZ) -# enable CRC checking -rfm9x.enable_crc = True # set delay before sending ACK rfm9x.ack_delay = 0.1 # set node addresses diff --git a/examples/rfm9x_node1_bonnet.py b/examples/rfm9x_node1_bonnet.py index ef87c02..b0f9bbb 100644 --- a/examples/rfm9x_node1_bonnet.py +++ b/examples/rfm9x_node1_bonnet.py @@ -66,9 +66,6 @@ display.show() -# enable CRC checking -rfm9x.enable_crc = True - # set node addresses rfm9x.node = 1 rfm9x.destination = 2 diff --git a/examples/rfm9x_node2.py b/examples/rfm9x_node2.py index 9f6d589..f9f7b9a 100644 --- a/examples/rfm9x_node2.py +++ b/examples/rfm9x_node2.py @@ -24,8 +24,6 @@ # Initialze RFM radio rfm9x = adafruit_rfm9x.RFM9x(spi, CS, RESET, RADIO_FREQ_MHZ) -# enable CRC checking -rfm9x.enable_crc = True # set node addresses rfm9x.node = 2 rfm9x.destination = 1 diff --git a/examples/rfm9x_node2_ack.py b/examples/rfm9x_node2_ack.py index 827a872..17c8886 100644 --- a/examples/rfm9x_node2_ack.py +++ b/examples/rfm9x_node2_ack.py @@ -24,8 +24,6 @@ # Initialze RFM radio rfm9x = adafruit_rfm9x.RFM9x(spi, CS, RESET, RADIO_FREQ_MHZ) -# enable CRC checking -rfm9x.enable_crc = True # set delay before transmitting ACK (seconds) rfm9x.ack_delay = 0.1 # set node addresses From 5e6460b417610ad2711761c71c7bf5aa147a3f54 Mon Sep 17 00:00:00 2001 From: jerryneedell Date: Sun, 18 Jul 2021 14:21:15 -0400 Subject: [PATCH 2/3] fix docstring --- adafruit_rfm9x.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adafruit_rfm9x.py b/adafruit_rfm9x.py index 8dfa083..9bb485c 100644 --- a/adafruit_rfm9x.py +++ b/adafruit_rfm9x.py @@ -277,8 +277,8 @@ def __init__( self.spreading_factor = 7 # Default to enable CRC checking on incoming packets. self.enable_crc = crc - # set AGC - Default = False """CRC Enable state""" + # set AGC - Default = False self.auto_agc = agc """Automatic Gain Control state""" # Set transmit power to 13 dBm, a safe value any module supports. From 319c51540a53555e880acb7898eccfdd76c69620 Mon Sep 17 00:00:00 2001 From: jerryneedell Date: Sun, 18 Jul 2021 15:07:27 -0400 Subject: [PATCH 3/3] fix typo in docstring --- adafruit_rfm9x.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adafruit_rfm9x.py b/adafruit_rfm9x.py index 9bb485c..5f42938 100644 --- a/adafruit_rfm9x.py +++ b/adafruit_rfm9x.py @@ -127,7 +127,7 @@ class RFM9x: - baudrate: Baud rate of the SPI connection, default is 10mhz but you might choose to lower to 1mhz if using long wires or a breadboard. - agc: Boolean to Enable/Disable Automatic Gain Control - Default=False (AGC off) - - agc: Boolean to Enable/Disable Cyclic Redundancy Check - Default=True (CRC Enabled) + - crc: Boolean to Enable/Disable Cyclic Redundancy Check - Default=True (CRC Enabled) Remember this library makes a best effort at receiving packets with pure Python code. Trying to receive packets too quickly will result in lost data so limit yourself to simple scenarios of sending and receiving single