Conversation
Radiohead should be given a protocol and it will do everything with the given protocol
jbwillis
left a comment
There was a problem hiding this comment.
For the purpose of unifying FSK and LoRa, I think this does the job. There is a lot of duplicated functionality in radiohead.py between the FSK and LoRa send/receive functions. Ultimately I'd like to reduce those down so FSK and LoRa packets are handled by the same code. This is partly to avoid having two diverging packet protocols making it hard to keep track of bugs and where changes need to be made.
| @@ -0,0 +1,689 @@ | |||
| # SPDX-FileCopyrightText: 2017 Tony DiCola for Adafruit Industries | |||
There was a problem hiding this comment.
Rename to pycubed_rfm9x_lora.py
| """crc status""" | ||
| return (self._read_u8(Constants._RH_RF95_REG_12_IRQ_FLAGS) & 0x20) >> 5 | ||
|
|
||
| def write_payload(self, payload) -> bool: |
There was a problem hiding this comment.
does this actually return a bool?
lib/radiohead.py
Outdated
| @@ -218,9 +219,14 @@ async def fsk_send( | |||
| # efficient and proper way to ensure a precondition that the provided | |||
There was a problem hiding this comment.
probably delete these comments
lib/radiohead.py
Outdated
| assert 0 < len(data) <= 57 # TODO: Allow longer packets, see pg 76 | ||
| self.tx_device.check_data(data) | ||
|
|
||
| # pylint: enable=len-as-condition |
lib/radiohead.py
Outdated
| if self.protocol == "lora": | ||
| # tells device that FIFO should start at 0. | ||
| # register is used different in fsk | ||
| self.tx_device._write_u8(self.constants._RH_RF95_REG_0D_FIFO_ADDR_PTR, 0x00) |
There was a problem hiding this comment.
put this in a function in the lora module
lib/radiohead.py
Outdated
| # Enter idle mode to stop receiving other packets. | ||
| self.idle() | ||
| if self.protocol == "lora": | ||
| self.tx_device._write_u8(self.constants._RH_RF95_REG_12_IRQ_FLAGS, 0xFF) |
There was a problem hiding this comment.
put this in a function in the lora module.
letting a user easily choose between fsk and lora in radio_configuration.