Skip to content

Commit 8eb678a

Browse files
committed
Exposed control of CRC checking on inbound.
1 parent ff73d37 commit 8eb678a

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

README.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ the following example:
7171
7272
# Initialze RFM radio with conservative baudrate and default modem config
7373
rfm9x = adafruit_rfm9x.RFM9x(spi, CS, RESET, RADIO_FREQ_MHZ, baudrate=1000000,
74-
signal_bandwidth=125000, coding_rate=5, spreading_factor=7)
74+
signal_bandwidth=125000, coding_rate=5, spreading_factor=7,
75+
enable_crc=False)
7576
7677
See examples/rfm9x_simpletest.py for an expanded demo of the usage.
7778

adafruit_rfm9x.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ def __set__(self, obj, val):
337337

338338
def __init__(self, spi, cs, reset, frequency, *, preamble_length=8,
339339
high_power=True, baudrate=5000000, signal_bandwidth=125000,
340-
coding_rate=5, spreading_factor=7):
340+
coding_rate=5, spreading_factor=7, enable_crc=False):
341341
self.high_power = high_power
342342
# Device support SPI mode 0 (polarity & phase = 0) up to a max of 10mhz.
343343
# Set Default Baudrate to 5MHz to avoid problems
@@ -400,6 +400,10 @@ def __init__(self, spi, cs, reset, frequency, *, preamble_length=8,
400400
((sf << 4) & 0xf0)
401401
)
402402
)
403+
# Optionally enable CRC checking on incoming packets.
404+
if enable_crc:
405+
config = self._read_u8(_RH_RF95_REG_1E_MODEM_CONFIG2) | 0x04
406+
self._write_u8(_RH_RF95_REG_1E_MODEM_CONFIG2, config)
403407
# Note no sync word is set for LoRa mode either!
404408
self._write_u8(_RH_RF95_REG_26_MODEM_CONFIG3, 0x00) # Preamble lsb?
405409
# Set preamble length (default 8 bytes to match radiohead).

0 commit comments

Comments
 (0)