@@ -266,7 +266,7 @@ class RFM9x:
266
266
# at least as large as the FIFO on the chip (256 bytes)! Keep this on the
267
267
# class level to ensure only one copy ever exists (with the trade-off that
268
268
# this is NOT re-entrant or thread safe code by design).
269
- _BUFFER = bytearray (256 )
269
+ _BUFFER = bytearray (10 )
270
270
271
271
class _RegisterBits :
272
272
# Class to simplify access to the many configuration bits avaialable
@@ -334,7 +334,7 @@ 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 = 10000000 ):
337
+ high_power = True , baudrate = 1000000 ):
338
338
self .high_power = high_power
339
339
# Device support SPI mode 0 (polarity & phase = 0) up to a max of 10mhz.
340
340
self ._device = spi_device .SPIDevice (spi , cs , baudrate = baudrate ,
@@ -532,7 +532,7 @@ def rssi(self):
532
532
# Remember in LoRa mode the payload register changes function to RSSI!
533
533
return self ._read_u8 (_RH_RF95_REG_1A_PKT_RSSI_VALUE ) - 137
534
534
535
- def send (self , data , timeout_s = 1. ):
535
+ def send (self , data , timeout_s = 1. ):
536
536
"""Send a string of data using the transmitter. You can only send 252
537
537
bytes at a time (limited by chip's FIFO size and appended headers). Note
538
538
this appends a 4 byte header to be compatible with the RadioHead library.
@@ -605,12 +605,11 @@ def receive(self, timeout_s=0.5, keep_listening=True):
605
605
# Reset the fifo read ptr to the beginning of the packet.
606
606
current_addr = self ._read_u8 (_RH_RF95_REG_10_FIFO_RX_CURRENT_ADDR )
607
607
self ._write_u8 (_RH_RF95_REG_0D_FIFO_ADDR_PTR , current_addr )
608
- # Read the first 4 bytes to grab the header.
609
- self ._read_into (_RH_RF95_REG_00_FIFO , self ._BUFFER , length = 4 )
610
- length -= 4
611
- # Next read the remaining data into a result packet buffer.
612
608
packet = bytearray (length )
609
+ # Read the packet.
613
610
self ._read_into (_RH_RF95_REG_00_FIFO , packet )
611
+ # strip off the header
612
+ packet = packet [4 :]
614
613
# Listen again if necessary and return the result packet.
615
614
if keep_listening :
616
615
self .listen ()
0 commit comments