@@ -352,10 +352,6 @@ def __set__(self, obj, val):
352
352
353
353
dio0_mapping = _RegisterBits (_RH_RF95_REG_40_DIO_MAPPING1 , offset = 6 , bits = 2 )
354
354
355
- tx_done = _RegisterBits (_RH_RF95_REG_12_IRQ_FLAGS , offset = 3 , bits = 1 )
356
-
357
- rx_done = _RegisterBits (_RH_RF95_REG_12_IRQ_FLAGS , offset = 6 , bits = 1 )
358
-
359
355
crc_error = _RegisterBits (_RH_RF95_REG_12_IRQ_FLAGS , offset = 5 , bits = 1 )
360
356
361
357
bw_bins = (7800 , 10400 , 15600 , 20800 , 31250 , 41700 , 62500 , 125000 , 250000 )
@@ -409,8 +405,16 @@ def __init__(
409
405
self .frequency_mhz = frequency
410
406
# Set preamble length (default 8 bytes to match radiohead).
411
407
self .preamble_length = preamble_length
412
- # set radio configuration parameters
413
- self ._configure_radio ()
408
+ # Defaults set modem config to RadioHead compatible Bw125Cr45Sf128 mode.
409
+ self .signal_bandwidth = 125000
410
+ self .coding_rate = 5
411
+ self .spreading_factor = 7
412
+ # Default to disable CRC checking on incoming packets.
413
+ self .enable_crc = False
414
+ # Note no sync word is set for LoRa mode either!
415
+ self ._write_u8 (_RH_RF95_REG_26_MODEM_CONFIG3 , 0x00 ) # Preamble lsb?
416
+ # Set transmit power to 13 dBm, a safe value any module supports.
417
+ self .tx_power = 13
414
418
# initialize last RSSI reading
415
419
self .last_rssi = 0.0
416
420
"""The RSSI of the last received packet. Stored when the packet was received.
@@ -463,17 +467,6 @@ def __init__(
463
467
Fourth byte of the RadioHead header.
464
468
"""
465
469
self .crc_error_count = 0
466
- def _configure_radio (self ):
467
- # Defaults set modem config to RadioHead compatible Bw125Cr45Sf128 mode.
468
- self .signal_bandwidth = 125000
469
- self .coding_rate = 5
470
- self .spreading_factor = 7
471
- # Default to disable CRC checking on incoming packets.
472
- self .enable_crc = False
473
- # Note no sync word is set for LoRa mode either!
474
- self ._write_u8 (_RH_RF95_REG_26_MODEM_CONFIG3 , 0x00 ) # Preamble lsb?
475
- # Set transmit power to 13 dBm, a safe value any module supports.
476
- self .tx_power = 13
477
470
478
471
# pylint: disable=no-member
479
472
# Reconsider pylint: disable when this can be tested
@@ -721,6 +714,15 @@ def enable_crc(self, val):
721
714
self ._read_u8 (_RH_RF95_REG_1E_MODEM_CONFIG2 ) & 0xFB ,
722
715
)
723
716
717
+ def tx_done (self ):
718
+ """Transmit status"""
719
+ return (self ._read_u8 (_RH_RF95_REG_12_IRQ_FLAGS ) & 0x4 ) >> 3
720
+
721
+ def rx_done (self ):
722
+ """Receive status"""
723
+ return (self ._read_u8 (_RH_RF95_REG_12_IRQ_FLAGS ) & 0x40 ) >> 6
724
+
725
+
724
726
def send (
725
727
self ,
726
728
data ,
@@ -783,7 +785,7 @@ def send(
783
785
# best that can be done right now without interrupts).
784
786
start = time .monotonic ()
785
787
timed_out = False
786
- while not timed_out and not self .tx_done :
788
+ while not timed_out and not self .tx_done () :
787
789
if (time .monotonic () - start ) >= self .xmit_timeout :
788
790
timed_out = True
789
791
# Listen again if necessary and return the result packet.
@@ -864,7 +866,7 @@ def receive(
864
866
self .listen ()
865
867
start = time .monotonic ()
866
868
timed_out = False
867
- while not timed_out and not self .rx_done :
869
+ while not timed_out and not self .rx_done () :
868
870
if (time .monotonic () - start ) >= timeout :
869
871
timed_out = True
870
872
# Payload ready is set, a packet is in the FIFO.
0 commit comments