27
27
adapted from the Radiohead library RF95 code from:
28
28
http: www.airspayce.com/mikem/arduino/RadioHead/
29
29
30
- * Author(s): Tony DiCola
30
+ * Author(s): Tony DiCola, Jerry Needell
31
31
"""
32
32
import time
33
33
import digitalio
@@ -334,9 +334,10 @@ def __set__(self, obj, val):
334
334
rx_done = _RegisterBits (_RH_RF95_REG_12_IRQ_FLAGS , offset = 6 , bits = 1 )
335
335
336
336
def __init__ (self , spi , cs , reset , frequency , * , preamble_length = 8 ,
337
- high_power = True , baudrate = 1000000 ):
337
+ high_power = True , baudrate = 5000000 ):
338
338
self .high_power = high_power
339
339
# Device support SPI mode 0 (polarity & phase = 0) up to a max of 10mhz.
340
+ # Set Default Baudrate to 5MHz to avoid problems
340
341
self ._device = spi_device .SPIDevice (spi , cs , baudrate = baudrate ,
341
342
polarity = 0 , phase = 0 )
342
343
# Setup reset as a digital input (default state for reset line according
@@ -361,8 +362,9 @@ def __init__(self, spi, cs, reset, frequency, *, preamble_length=8,
361
362
raise RuntimeError ('Failed to configure radio for LoRa mode, check wiring!' )
362
363
except OSError :
363
364
raise RuntimeError ('Failed to communicate with radio, check wiring!' )
364
- # clear default setting ofr access to LF registers
365
- self .low_frequency_mode = 0
365
+ # clear default setting for access to LF registers if frquency > 525MHz
366
+ if frequency > 525 :
367
+ self .low_frequency_mode = 0
366
368
# Setup entire 256 byte FIFO
367
369
self ._write_u8 (_RH_RF95_REG_0E_FIFO_TX_BASE_ADDR , 0x00 )
368
370
self ._write_u8 (_RH_RF95_REG_0F_FIFO_RX_BASE_ADDR , 0x00 )
@@ -532,10 +534,11 @@ def rssi(self):
532
534
# Remember in LoRa mode the payload register changes function to RSSI!
533
535
return self ._read_u8 (_RH_RF95_REG_1A_PKT_RSSI_VALUE ) - 137
534
536
535
- def send (self , data , timeout_s = 1 . ):
537
+ def send (self , data , timeout_s = 2 . ):
536
538
"""Send a string of data using the transmitter. You can only send 252
537
539
bytes at a time (limited by chip's FIFO size and appended headers). Note
538
540
this appends a 4 byte header to be compatible with the RadioHead library.
541
+ The timeout is just to prevent a hang (arbitrarily set to 2 Seconds).
539
542
"""
540
543
# Disable pylint warning to not use length as a check for zero.
541
544
# This is a puzzling warning as the below code is clearly the most
0 commit comments