diff --git a/adafruit_rfm/rfm69.py b/adafruit_rfm/rfm69.py index e4c2108..4ff3c54 100644 --- a/adafruit_rfm/rfm69.py +++ b/adafruit_rfm/rfm69.py @@ -3,7 +3,7 @@ # SPDX-License-Identifier: MIT """ -`adafruit_rfm69` +`adafruit_rfm.rfm69` ==================================================== CircuitPython RFM69 packet radio module. This supports sending and @@ -33,12 +33,12 @@ except ImportError: pass - try: from typing import Optional import busio import digitalio + from circuitpython_typing import ReadableBuffer except ImportError: pass @@ -567,6 +567,7 @@ def enable_crc(self, val: bool) -> None: else: self.crc_on = 0 + @property def crc_error(self) -> bool: """crc status""" return (self.read_u8(_RF69_REG_28_IRQ_FLAGS2) & 0x2) >> 1 @@ -629,7 +630,7 @@ def clear_interrupt(self) -> None: self.write_u8(_RF69_REG_27_IRQ_FLAGS1, 0xFF) self.write_u8(_RF69_REG_28_IRQ_FLAGS2, 0xFF) - def fill_fifo(self, payload: bytearray) -> None: + def fill_fifo(self, payload: ReadableBuffer) -> None: """Write the payload to the FIFO.""" complete_payload = bytearray(1) # prepend packet length to payload complete_payload[0] = len(payload) diff --git a/adafruit_rfm/rfm9x.py b/adafruit_rfm/rfm9x.py index 144c0f4..d89000a 100644 --- a/adafruit_rfm/rfm9x.py +++ b/adafruit_rfm/rfm9x.py @@ -3,7 +3,7 @@ # SPDX-License-Identifier: MIT """ -`adafruit_rfm9x` +`adafruit_rfm.rfm9x` ==================================================== CircuitPython module for the RFM95/6/7/8 LoRa 433/915mhz radio modules. @@ -20,6 +20,7 @@ try: import busio import digitalio + from circuitpython_typing import ReadableBuffer try: from typing import Literal @@ -490,6 +491,7 @@ def enable_crc(self, val: bool) -> None: self.read_u8(_RF95_REG_1E_MODEM_CONFIG2) & 0xFB, ) + @property def crc_error(self) -> bool: """crc status""" return (self.read_u8(_RF95_REG_12_IRQ_FLAGS) & 0x20) >> 5 @@ -506,7 +508,7 @@ def clear_interrupt(self) -> None: """Clear Interrupt flags""" self.write_u8(_RF95_REG_12_IRQ_FLAGS, 0xFF) - def fill_fifo(self, payload: bytearray) -> None: + def fill_fifo(self, payload: ReadableBuffer) -> None: """len_data is not used but is here for compatibility with rfm69 Fill the FIFO with a packet to send""" self.write_u8(_RF95_REG_0D_FIFO_ADDR_PTR, 0x00) # FIFO starts at 0. diff --git a/adafruit_rfm/rfm9xfsk.py b/adafruit_rfm/rfm9xfsk.py index d456b86..4394cde 100644 --- a/adafruit_rfm/rfm9xfsk.py +++ b/adafruit_rfm/rfm9xfsk.py @@ -3,7 +3,7 @@ # SPDX-License-Identifier: MIT """ -`adafruit_rfm9xFSK` +`adafruit_rfm.rfm9xfsk` ==================================================== CircuitPython module for the RFM95/6/7/8 FSK 433/915mhz radio modules. @@ -22,6 +22,7 @@ import busio import digitalio + from circuitpython_typing import ReadableBuffer try: from typing import Literal @@ -490,6 +491,7 @@ def enable_crc(self, val: bool) -> None: else: self.crc_on = 0 + @property def crc_error(self) -> bool: """crc status""" return (self.read_u8(_RF95_REG_3F_IRQ_FLAGS_2) & 0x2) >> 1 @@ -552,7 +554,7 @@ def clear_interrupt(self) -> None: self.write_u8(_RF95_REG_3E_IRQ_FLAGS_1, 0xFF) self.write_u8(_RF95_REG_3F_IRQ_FLAGS_2, 0xFF) - def fill_fifo(self, payload: bytearray) -> None: + def fill_fifo(self, payload: ReadableBuffer) -> None: """Write the payload to the FIFO.""" complete_payload = bytearray(1) # prepend packet length to payload complete_payload[0] = len(payload) diff --git a/adafruit_rfm/rfm_common.py b/adafruit_rfm/rfm_common.py index 04096db..ed5a55a 100644 --- a/adafruit_rfm/rfm_common.py +++ b/adafruit_rfm/rfm_common.py @@ -336,6 +336,9 @@ async def asyncio_send( # noqa: PLR0912 PLR0913 return not timed_out send = asyncio_to_blocking(asyncio_send) + """Non-asyncio wrapper to Send a string of data using the transmitter + using the same arguments and keywords as asyncio_send() + """ async def asyncio_send_with_ack(self, data: ReadableBuffer) -> bool: """Reliable Datagram mode: @@ -377,6 +380,9 @@ async def asyncio_send_with_ack(self, data: ReadableBuffer) -> bool: return got_ack send_with_ack = asyncio_to_blocking(asyncio_send_with_ack) + """Non-asyncio wrapper to Send a string of data using the transmitter + using the same arguments and keywords as asyncio_send_with_ack() + """ async def asyncio_receive( # noqa: PLR0912 self, @@ -420,7 +426,7 @@ async def asyncio_receive( # noqa: PLR0912 # Enter idle mode to stop receiving other packets. self.idle() if not timed_out: - if self.enable_crc and self.crc_error(): + if self.enable_crc and self.crc_error: self.crc_error_count += 1 else: packet = self.read_fifo() @@ -447,6 +453,9 @@ async def asyncio_receive( # noqa: PLR0912 return packet receive = asyncio_to_blocking(asyncio_receive) + """Non-asyncio wrapper to Receive a packet + using the same arguments and keywords as asyncio_receive() + """ async def asyncio_receive_with_ack( # noqa: PLR0912 self, @@ -490,7 +499,7 @@ async def asyncio_receive_with_ack( # noqa: PLR0912 # Enter idle mode to stop receiving other packets. self.idle() if not timed_out: - if self.enable_crc and self.crc_error(): + if self.enable_crc and self.crc_error: self.crc_error_count += 1 else: packet = self.read_fifo() @@ -543,3 +552,6 @@ async def asyncio_receive_with_ack( # noqa: PLR0912 return packet receive_with_ack = asyncio_to_blocking(asyncio_receive_with_ack) + """Non-asyncio wrapper to Receive a packet + using the same arguments and keywords as asyncio_receive_with_ack() + """ diff --git a/docs/api.rst b/docs/api.rst index 0d6d4f7..d82934e 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -4,5 +4,14 @@ .. If your library file(s) are nested in a directory (e.g. /adafruit_foo/foo.py) .. use this format as the module name: "adafruit_foo.foo" -.. automodule:: adafruit_rfm +.. automodule:: adafruit_rfm.rfm_common + :members: + +.. automodule:: adafruit_rfm.rfm69 + :members: + +.. automodule:: adafruit_rfm.rfm9x + :members: + +.. automodule:: adafruit_rfm.rfm9xfsk :members: