diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index fff3aa9..1dad804 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -40,7 +40,7 @@ jobs: source actions-ci/install.sh - name: Pip install pylint, black, & Sphinx run: | - pip install --force-reinstall pylint==1.9.2 black==19.10b0 Sphinx sphinx-rtd-theme + pip install --force-reinstall pylint black==19.10b0 Sphinx sphinx-rtd-theme - name: Library version run: git describe --dirty --always --tags - name: PyLint diff --git a/adafruit_rfm9x.py b/adafruit_rfm9x.py index b362146..89c5501 100644 --- a/adafruit_rfm9x.py +++ b/adafruit_rfm9x.py @@ -36,9 +36,14 @@ try: from warnings import warn except ImportError: + def warn(msg, **kwargs): "Issue a warning to stdout." - print("%s: %s" % ("Warning" if kwargs.get("cat") is None else kwargs["cat"].__name__, msg)) + print( + "%s: %s" + % ("Warning" if kwargs.get("cat") is None else kwargs["cat"].__name__, msg) + ) + import adafruit_bus_device.spi_device as spidev @@ -50,189 +55,189 @@ def warn(msg, **kwargs): # pylint: disable=bad-whitespace # Internal constants: # Register names (FSK Mode even though we use LoRa instead, from table 85) -_RH_RF95_REG_00_FIFO = const(0x00) -_RH_RF95_REG_01_OP_MODE = const(0x01) -_RH_RF95_REG_02_RESERVED = const(0x02) -_RH_RF95_REG_03_RESERVED = const(0x03) -_RH_RF95_REG_04_RESERVED = const(0x04) -_RH_RF95_REG_05_RESERVED = const(0x05) -_RH_RF95_REG_06_FRF_MSB = const(0x06) -_RH_RF95_REG_07_FRF_MID = const(0x07) -_RH_RF95_REG_08_FRF_LSB = const(0x08) -_RH_RF95_REG_09_PA_CONFIG = const(0x09) -_RH_RF95_REG_0A_PA_RAMP = const(0x0a) -_RH_RF95_REG_0B_OCP = const(0x0b) -_RH_RF95_REG_0C_LNA = const(0x0c) -_RH_RF95_REG_0D_FIFO_ADDR_PTR = const(0x0d) -_RH_RF95_REG_0E_FIFO_TX_BASE_ADDR = const(0x0e) -_RH_RF95_REG_0F_FIFO_RX_BASE_ADDR = const(0x0f) -_RH_RF95_REG_10_FIFO_RX_CURRENT_ADDR = const(0x10) -_RH_RF95_REG_11_IRQ_FLAGS_MASK = const(0x11) -_RH_RF95_REG_12_IRQ_FLAGS = const(0x12) -_RH_RF95_REG_13_RX_NB_BYTES = const(0x13) -_RH_RF95_REG_14_RX_HEADER_CNT_VALUE_MSB = const(0x14) -_RH_RF95_REG_15_RX_HEADER_CNT_VALUE_LSB = const(0x15) -_RH_RF95_REG_16_RX_PACKET_CNT_VALUE_MSB = const(0x16) -_RH_RF95_REG_17_RX_PACKET_CNT_VALUE_LSB = const(0x17) -_RH_RF95_REG_18_MODEM_STAT = const(0x18) -_RH_RF95_REG_19_PKT_SNR_VALUE = const(0x19) -_RH_RF95_REG_1A_PKT_RSSI_VALUE = const(0x1a) -_RH_RF95_REG_1B_RSSI_VALUE = const(0x1b) -_RH_RF95_REG_1C_HOP_CHANNEL = const(0x1c) -_RH_RF95_REG_1D_MODEM_CONFIG1 = const(0x1d) -_RH_RF95_REG_1E_MODEM_CONFIG2 = const(0x1e) -_RH_RF95_REG_1F_SYMB_TIMEOUT_LSB = const(0x1f) -_RH_RF95_REG_20_PREAMBLE_MSB = const(0x20) -_RH_RF95_REG_21_PREAMBLE_LSB = const(0x21) -_RH_RF95_REG_22_PAYLOAD_LENGTH = const(0x22) -_RH_RF95_REG_23_MAX_PAYLOAD_LENGTH = const(0x23) -_RH_RF95_REG_24_HOP_PERIOD = const(0x24) -_RH_RF95_REG_25_FIFO_RX_BYTE_ADDR = const(0x25) -_RH_RF95_REG_26_MODEM_CONFIG3 = const(0x26) - -_RH_RF95_REG_40_DIO_MAPPING1 = const(0x40) -_RH_RF95_REG_41_DIO_MAPPING2 = const(0x41) -_RH_RF95_REG_42_VERSION = const(0x42) - -_RH_RF95_REG_4B_TCXO = const(0x4b) -_RH_RF95_REG_4D_PA_DAC = const(0x4d) -_RH_RF95_REG_5B_FORMER_TEMP = const(0x5b) -_RH_RF95_REG_61_AGC_REF = const(0x61) -_RH_RF95_REG_62_AGC_THRESH1 = const(0x62) -_RH_RF95_REG_63_AGC_THRESH2 = const(0x63) -_RH_RF95_REG_64_AGC_THRESH3 = const(0x64) +_RH_RF95_REG_00_FIFO = const(0x00) +_RH_RF95_REG_01_OP_MODE = const(0x01) +_RH_RF95_REG_02_RESERVED = const(0x02) +_RH_RF95_REG_03_RESERVED = const(0x03) +_RH_RF95_REG_04_RESERVED = const(0x04) +_RH_RF95_REG_05_RESERVED = const(0x05) +_RH_RF95_REG_06_FRF_MSB = const(0x06) +_RH_RF95_REG_07_FRF_MID = const(0x07) +_RH_RF95_REG_08_FRF_LSB = const(0x08) +_RH_RF95_REG_09_PA_CONFIG = const(0x09) +_RH_RF95_REG_0A_PA_RAMP = const(0x0A) +_RH_RF95_REG_0B_OCP = const(0x0B) +_RH_RF95_REG_0C_LNA = const(0x0C) +_RH_RF95_REG_0D_FIFO_ADDR_PTR = const(0x0D) +_RH_RF95_REG_0E_FIFO_TX_BASE_ADDR = const(0x0E) +_RH_RF95_REG_0F_FIFO_RX_BASE_ADDR = const(0x0F) +_RH_RF95_REG_10_FIFO_RX_CURRENT_ADDR = const(0x10) +_RH_RF95_REG_11_IRQ_FLAGS_MASK = const(0x11) +_RH_RF95_REG_12_IRQ_FLAGS = const(0x12) +_RH_RF95_REG_13_RX_NB_BYTES = const(0x13) +_RH_RF95_REG_14_RX_HEADER_CNT_VALUE_MSB = const(0x14) +_RH_RF95_REG_15_RX_HEADER_CNT_VALUE_LSB = const(0x15) +_RH_RF95_REG_16_RX_PACKET_CNT_VALUE_MSB = const(0x16) +_RH_RF95_REG_17_RX_PACKET_CNT_VALUE_LSB = const(0x17) +_RH_RF95_REG_18_MODEM_STAT = const(0x18) +_RH_RF95_REG_19_PKT_SNR_VALUE = const(0x19) +_RH_RF95_REG_1A_PKT_RSSI_VALUE = const(0x1A) +_RH_RF95_REG_1B_RSSI_VALUE = const(0x1B) +_RH_RF95_REG_1C_HOP_CHANNEL = const(0x1C) +_RH_RF95_REG_1D_MODEM_CONFIG1 = const(0x1D) +_RH_RF95_REG_1E_MODEM_CONFIG2 = const(0x1E) +_RH_RF95_REG_1F_SYMB_TIMEOUT_LSB = const(0x1F) +_RH_RF95_REG_20_PREAMBLE_MSB = const(0x20) +_RH_RF95_REG_21_PREAMBLE_LSB = const(0x21) +_RH_RF95_REG_22_PAYLOAD_LENGTH = const(0x22) +_RH_RF95_REG_23_MAX_PAYLOAD_LENGTH = const(0x23) +_RH_RF95_REG_24_HOP_PERIOD = const(0x24) +_RH_RF95_REG_25_FIFO_RX_BYTE_ADDR = const(0x25) +_RH_RF95_REG_26_MODEM_CONFIG3 = const(0x26) + +_RH_RF95_REG_40_DIO_MAPPING1 = const(0x40) +_RH_RF95_REG_41_DIO_MAPPING2 = const(0x41) +_RH_RF95_REG_42_VERSION = const(0x42) + +_RH_RF95_REG_4B_TCXO = const(0x4B) +_RH_RF95_REG_4D_PA_DAC = const(0x4D) +_RH_RF95_REG_5B_FORMER_TEMP = const(0x5B) +_RH_RF95_REG_61_AGC_REF = const(0x61) +_RH_RF95_REG_62_AGC_THRESH1 = const(0x62) +_RH_RF95_REG_63_AGC_THRESH2 = const(0x63) +_RH_RF95_REG_64_AGC_THRESH3 = const(0x64) # RH_RF95_REG_01_OP_MODE 0x01 -_RH_RF95_LONG_RANGE_MODE = const(0x80) -_RH_RF95_ACCESS_SHARED_REG = const(0x40) -_RH_RF95_MODE = const(0x07) -_RH_RF95_MODE_SLEEP = const(0x00) -_RH_RF95_MODE_STDBY = const(0x01) -_RH_RF95_MODE_FSTX = const(0x02) -_RH_RF95_MODE_TX = const(0x03) -_RH_RF95_MODE_FSRX = const(0x04) -_RH_RF95_MODE_RXCONTINUOUS = const(0x05) -_RH_RF95_MODE_RXSINGLE = const(0x06) -_RH_RF95_MODE_CAD = const(0x07) +_RH_RF95_LONG_RANGE_MODE = const(0x80) +_RH_RF95_ACCESS_SHARED_REG = const(0x40) +_RH_RF95_MODE = const(0x07) +_RH_RF95_MODE_SLEEP = const(0x00) +_RH_RF95_MODE_STDBY = const(0x01) +_RH_RF95_MODE_FSTX = const(0x02) +_RH_RF95_MODE_TX = const(0x03) +_RH_RF95_MODE_FSRX = const(0x04) +_RH_RF95_MODE_RXCONTINUOUS = const(0x05) +_RH_RF95_MODE_RXSINGLE = const(0x06) +_RH_RF95_MODE_CAD = const(0x07) # RH_RF95_REG_09_PA_CONFIG 0x09 -_RH_RF95_PA_SELECT = const(0x80) -_RH_RF95_MAX_POWER = const(0x70) -_RH_RF95_OUTPUT_POWER = const(0x0f) +_RH_RF95_PA_SELECT = const(0x80) +_RH_RF95_MAX_POWER = const(0x70) +_RH_RF95_OUTPUT_POWER = const(0x0F) # RH_RF95_REG_0A_PA_RAMP 0x0a -_RH_RF95_LOW_PN_TX_PLL_OFF = const(0x10) -_RH_RF95_PA_RAMP = const(0x0f) -_RH_RF95_PA_RAMP_3_4MS = const(0x00) -_RH_RF95_PA_RAMP_2MS = const(0x01) -_RH_RF95_PA_RAMP_1MS = const(0x02) -_RH_RF95_PA_RAMP_500US = const(0x03) -_RH_RF95_PA_RAMP_250US = const(0x04) -_RH_RF95_PA_RAMP_125US = const(0x05) -_RH_RF95_PA_RAMP_100US = const(0x06) -_RH_RF95_PA_RAMP_62US = const(0x07) -_RH_RF95_PA_RAMP_50US = const(0x08) -_RH_RF95_PA_RAMP_40US = const(0x09) -_RH_RF95_PA_RAMP_31US = const(0x0a) -_RH_RF95_PA_RAMP_25US = const(0x0b) -_RH_RF95_PA_RAMP_20US = const(0x0c) -_RH_RF95_PA_RAMP_15US = const(0x0d) -_RH_RF95_PA_RAMP_12US = const(0x0e) -_RH_RF95_PA_RAMP_10US = const(0x0f) +_RH_RF95_LOW_PN_TX_PLL_OFF = const(0x10) +_RH_RF95_PA_RAMP = const(0x0F) +_RH_RF95_PA_RAMP_3_4MS = const(0x00) +_RH_RF95_PA_RAMP_2MS = const(0x01) +_RH_RF95_PA_RAMP_1MS = const(0x02) +_RH_RF95_PA_RAMP_500US = const(0x03) +_RH_RF95_PA_RAMP_250US = const(0x04) +_RH_RF95_PA_RAMP_125US = const(0x05) +_RH_RF95_PA_RAMP_100US = const(0x06) +_RH_RF95_PA_RAMP_62US = const(0x07) +_RH_RF95_PA_RAMP_50US = const(0x08) +_RH_RF95_PA_RAMP_40US = const(0x09) +_RH_RF95_PA_RAMP_31US = const(0x0A) +_RH_RF95_PA_RAMP_25US = const(0x0B) +_RH_RF95_PA_RAMP_20US = const(0x0C) +_RH_RF95_PA_RAMP_15US = const(0x0D) +_RH_RF95_PA_RAMP_12US = const(0x0E) +_RH_RF95_PA_RAMP_10US = const(0x0F) # RH_RF95_REG_0B_OCP 0x0b -_RH_RF95_OCP_ON = const(0x20) -_RH_RF95_OCP_TRIM = const(0x1f) +_RH_RF95_OCP_ON = const(0x20) +_RH_RF95_OCP_TRIM = const(0x1F) # RH_RF95_REG_0C_LNA 0x0c -_RH_RF95_LNA_GAIN = const(0xe0) -_RH_RF95_LNA_BOOST = const(0x03) -_RH_RF95_LNA_BOOST_DEFAULT = const(0x00) -_RH_RF95_LNA_BOOST_150PC = const(0x11) +_RH_RF95_LNA_GAIN = const(0xE0) +_RH_RF95_LNA_BOOST = const(0x03) +_RH_RF95_LNA_BOOST_DEFAULT = const(0x00) +_RH_RF95_LNA_BOOST_150PC = const(0x11) # RH_RF95_REG_11_IRQ_FLAGS_MASK 0x11 -_RH_RF95_RX_TIMEOUT_MASK = const(0x80) -_RH_RF95_RX_DONE_MASK = const(0x40) -_RH_RF95_PAYLOAD_CRC_ERROR_MASK = const(0x20) -_RH_RF95_VALID_HEADER_MASK = const(0x10) -_RH_RF95_TX_DONE_MASK = const(0x08) -_RH_RF95_CAD_DONE_MASK = const(0x04) -_RH_RF95_FHSS_CHANGE_CHANNEL_MASK = const(0x02) -_RH_RF95_CAD_DETECTED_MASK = const(0x01) +_RH_RF95_RX_TIMEOUT_MASK = const(0x80) +_RH_RF95_RX_DONE_MASK = const(0x40) +_RH_RF95_PAYLOAD_CRC_ERROR_MASK = const(0x20) +_RH_RF95_VALID_HEADER_MASK = const(0x10) +_RH_RF95_TX_DONE_MASK = const(0x08) +_RH_RF95_CAD_DONE_MASK = const(0x04) +_RH_RF95_FHSS_CHANGE_CHANNEL_MASK = const(0x02) +_RH_RF95_CAD_DETECTED_MASK = const(0x01) # RH_RF95_REG_12_IRQ_FLAGS 0x12 -_RH_RF95_RX_TIMEOUT = const(0x80) -_RH_RF95_RX_DONE = const(0x40) -_RH_RF95_PAYLOAD_CRC_ERROR = const(0x20) -_RH_RF95_VALID_HEADER = const(0x10) -_RH_RF95_TX_DONE = const(0x08) -_RH_RF95_CAD_DONE = const(0x04) -_RH_RF95_FHSS_CHANGE_CHANNEL = const(0x02) -_RH_RF95_CAD_DETECTED = const(0x01) +_RH_RF95_RX_TIMEOUT = const(0x80) +_RH_RF95_RX_DONE = const(0x40) +_RH_RF95_PAYLOAD_CRC_ERROR = const(0x20) +_RH_RF95_VALID_HEADER = const(0x10) +_RH_RF95_TX_DONE = const(0x08) +_RH_RF95_CAD_DONE = const(0x04) +_RH_RF95_FHSS_CHANGE_CHANNEL = const(0x02) +_RH_RF95_CAD_DETECTED = const(0x01) # RH_RF95_REG_18_MODEM_STAT 0x18 -_RH_RF95_RX_CODING_RATE = const(0xe0) -_RH_RF95_MODEM_STATUS_CLEAR = const(0x10) -_RH_RF95_MODEM_STATUS_HEADER_INFO_VALID = const(0x08) -_RH_RF95_MODEM_STATUS_RX_ONGOING = const(0x04) -_RH_RF95_MODEM_STATUS_SIGNAL_SYNCHRONIZED = const(0x02) -_RH_RF95_MODEM_STATUS_SIGNAL_DETECTED = const(0x01) +_RH_RF95_RX_CODING_RATE = const(0xE0) +_RH_RF95_MODEM_STATUS_CLEAR = const(0x10) +_RH_RF95_MODEM_STATUS_HEADER_INFO_VALID = const(0x08) +_RH_RF95_MODEM_STATUS_RX_ONGOING = const(0x04) +_RH_RF95_MODEM_STATUS_SIGNAL_SYNCHRONIZED = const(0x02) +_RH_RF95_MODEM_STATUS_SIGNAL_DETECTED = const(0x01) # RH_RF95_REG_1C_HOP_CHANNEL 0x1c -_RH_RF95_PLL_TIMEOUT = const(0x80) -_RH_RF95_RX_PAYLOAD_CRC_IS_ON = const(0x40) -_RH_RF95_FHSS_PRESENT_CHANNEL = const(0x3f) +_RH_RF95_PLL_TIMEOUT = const(0x80) +_RH_RF95_RX_PAYLOAD_CRC_IS_ON = const(0x40) +_RH_RF95_FHSS_PRESENT_CHANNEL = const(0x3F) # RH_RF95_REG_1D_MODEM_CONFIG1 0x1d -_RH_RF95_BW = const(0xc0) -_RH_RF95_BW_125KHZ = const(0x00) -_RH_RF95_BW_250KHZ = const(0x40) -_RH_RF95_BW_500KHZ = const(0x80) -_RH_RF95_BW_RESERVED = const(0xc0) -_RH_RF95_CODING_RATE = const(0x38) -_RH_RF95_CODING_RATE_4_5 = const(0x00) -_RH_RF95_CODING_RATE_4_6 = const(0x08) -_RH_RF95_CODING_RATE_4_7 = const(0x10) -_RH_RF95_CODING_RATE_4_8 = const(0x18) -_RH_RF95_IMPLICIT_HEADER_MODE_ON = const(0x04) -_RH_RF95_RX_PAYLOAD_CRC_ON = const(0x02) -_RH_RF95_LOW_DATA_RATE_OPTIMIZE = const(0x01) +_RH_RF95_BW = const(0xC0) +_RH_RF95_BW_125KHZ = const(0x00) +_RH_RF95_BW_250KHZ = const(0x40) +_RH_RF95_BW_500KHZ = const(0x80) +_RH_RF95_BW_RESERVED = const(0xC0) +_RH_RF95_CODING_RATE = const(0x38) +_RH_RF95_CODING_RATE_4_5 = const(0x00) +_RH_RF95_CODING_RATE_4_6 = const(0x08) +_RH_RF95_CODING_RATE_4_7 = const(0x10) +_RH_RF95_CODING_RATE_4_8 = const(0x18) +_RH_RF95_IMPLICIT_HEADER_MODE_ON = const(0x04) +_RH_RF95_RX_PAYLOAD_CRC_ON = const(0x02) +_RH_RF95_LOW_DATA_RATE_OPTIMIZE = const(0x01) # RH_RF95_REG_1E_MODEM_CONFIG2 0x1e -_RH_RF95_DETECTION_OPTIMIZE = const(0x31) -_RH_RF95_DETECTION_THRESHOLD = const(0x37) -_RH_RF95_SPREADING_FACTOR = const(0xf0) -_RH_RF95_SPREADING_FACTOR_64CPS = const(0x60) -_RH_RF95_SPREADING_FACTOR_128CPS = const(0x70) -_RH_RF95_SPREADING_FACTOR_256CPS = const(0x80) -_RH_RF95_SPREADING_FACTOR_512CPS = const(0x90) -_RH_RF95_SPREADING_FACTOR_1024CPS = const(0xa0) -_RH_RF95_SPREADING_FACTOR_2048CPS = const(0xb0) -_RH_RF95_SPREADING_FACTOR_4096CPS = const(0xc0) -_RH_RF95_TX_CONTINUOUS_MOE = const(0x08) -_RH_RF95_AGC_AUTO_ON = const(0x04) -_RH_RF95_SYM_TIMEOUT_MSB = const(0x03) +_RH_RF95_DETECTION_OPTIMIZE = const(0x31) +_RH_RF95_DETECTION_THRESHOLD = const(0x37) +_RH_RF95_SPREADING_FACTOR = const(0xF0) +_RH_RF95_SPREADING_FACTOR_64CPS = const(0x60) +_RH_RF95_SPREADING_FACTOR_128CPS = const(0x70) +_RH_RF95_SPREADING_FACTOR_256CPS = const(0x80) +_RH_RF95_SPREADING_FACTOR_512CPS = const(0x90) +_RH_RF95_SPREADING_FACTOR_1024CPS = const(0xA0) +_RH_RF95_SPREADING_FACTOR_2048CPS = const(0xB0) +_RH_RF95_SPREADING_FACTOR_4096CPS = const(0xC0) +_RH_RF95_TX_CONTINUOUS_MOE = const(0x08) +_RH_RF95_AGC_AUTO_ON = const(0x04) +_RH_RF95_SYM_TIMEOUT_MSB = const(0x03) # RH_RF95_REG_4D_PA_DAC 0x4d -_RH_RF95_PA_DAC_DISABLE = const(0x04) -_RH_RF95_PA_DAC_ENABLE = const(0x07) +_RH_RF95_PA_DAC_DISABLE = const(0x04) +_RH_RF95_PA_DAC_ENABLE = const(0x07) # The crystal oscillator frequency of the module _RH_RF95_FXOSC = 32000000.0 # The Frequency Synthesizer step = RH_RF95_FXOSC / 2^^19 -_RH_RF95_FSTEP = (_RH_RF95_FXOSC / 524288) +_RH_RF95_FSTEP = _RH_RF95_FXOSC / 524288 # RadioHead specific compatibility constants. _RH_BROADCAST_ADDRESS = const(0xFF) # User facing constants: -SLEEP_MODE = 0b000 +SLEEP_MODE = 0b000 STANDBY_MODE = 0b001 -FS_TX_MODE = 0b010 -TX_MODE = 0b011 -FS_RX_MODE = 0b100 -RX_MODE = 0b101 +FS_TX_MODE = 0b010 +TX_MODE = 0b011 +FS_RX_MODE = 0b100 +RX_MODE = 0b101 # pylint: enable=bad-whitespace @@ -242,6 +247,7 @@ def warn(msg, **kwargs): # the warning to work around the error. # pylint: disable=too-many-instance-attributes + class RFM9x: """Interface to a RFM95/6/7/8 LoRa radio module. Allows sending and receivng bytes of data in long range LoRa mode at a support board frequency @@ -346,13 +352,21 @@ def __set__(self, obj, val): bw_bins = (7800, 10400, 15600, 20800, 31250, 41700, 62500, 125000, 250000) - def __init__(self, spi, cs, reset, frequency, *, preamble_length=8, - high_power=True, baudrate=5000000): + def __init__( + self, + spi, + cs, + reset, + frequency, + *, + preamble_length=8, + high_power=True, + baudrate=5000000 + ): self.high_power = high_power # Device support SPI mode 0 (polarity & phase = 0) up to a max of 10mhz. # Set Default Baudrate to 5MHz to avoid problems - self._device = spidev.SPIDevice(spi, cs, baudrate=baudrate, - polarity=0, phase=0) + self._device = spidev.SPIDevice(spi, cs, baudrate=baudrate, polarity=0, phase=0) # Setup reset as a digital input (default state for reset line according # to the datasheet). This line is pulled low as an output quickly to # trigger a reset. Note that reset MUST be done like this and set as @@ -364,7 +378,9 @@ def __init__(self, spi, cs, reset, frequency, *, preamble_length=8, # throw a nicer message to indicate possible wiring problems. version = self._read_u8(_RH_RF95_REG_42_VERSION) if version != 18: - raise RuntimeError('Failed to find rfm9x with expected version -- check wiring') + raise RuntimeError( + "Failed to find rfm9x with expected version -- check wiring" + ) # Set sleep mode, wait 10s and confirm in sleep mode (basic device check). # Also set long range mode (LoRa mode) as it can only be done in sleep. @@ -372,7 +388,7 @@ def __init__(self, spi, cs, reset, frequency, *, preamble_length=8, time.sleep(0.01) self.long_range_mode = True if self.operation_mode != SLEEP_MODE or not self.long_range_mode: - raise RuntimeError('Failed to configure radio for LoRa mode, check wiring!') + raise RuntimeError("Failed to configure radio for LoRa mode, check wiring!") # clear default setting for access to LF registers if frequency > 525MHz if frequency > 525: self.low_frequency_mode = 0 @@ -406,7 +422,7 @@ def _read_into(self, address, buf, length=None): length = len(buf) with self._device as device: self._BUFFER[0] = address & 0x7F # Strip out top bit to set 0 - # value (read). + # value (read). device.write(self._BUFFER, end=1) device.readinto(buf, end=length) @@ -423,7 +439,7 @@ def _write_from(self, address, buf, length=None): length = len(buf) with self._device as device: self._BUFFER[0] = (address | 0x80) & 0xFF # Set top bit to 1 to - # indicate a write. + # indicate a write. device.write(self._BUFFER, end=1) device.write(buf, end=length) @@ -432,7 +448,7 @@ def _write_u8(self, address, val): # 8-bit value to write to that address. with self._device as device: self._BUFFER[0] = (address | 0x80) & 0xFF # Set top bit to 1 to - # indicate a write. + # indicate a write. self._BUFFER[1] = val & 0xFF device.write(self._BUFFER, end=2) @@ -442,7 +458,7 @@ def reset(self): self._reset.switch_to_output(value=False) time.sleep(0.0001) # 100 us self._reset.switch_to_input(pull=digitalio.Pull.UP) - time.sleep(0.005) # 5 ms + time.sleep(0.005) # 5 ms def idle(self): """Enter idle standby mode.""" @@ -498,7 +514,7 @@ def frequency_mhz(self): @frequency_mhz.setter def frequency_mhz(self, val): if val < 240 or val > 960: - raise RuntimeError('frequency_mhz must be between 240 and 960') + raise RuntimeError("frequency_mhz must be between 240 and 960") # Calculate FRF register 24-bit value. frf = int((val * 1000000.0) / _RH_RF95_FSTEP) & 0xFFFFFF # Extract byte values and update registers. @@ -529,7 +545,7 @@ def tx_power(self, val): val = int(val) if self.high_power: if val < 5 or val > 23: - raise RuntimeError('tx_power must be between 5 and 23') + raise RuntimeError("tx_power must be between 5 and 23") # Enable power amp DAC if power is above 20 dB. # Lower setting by 3db when PA_BOOST enabled - see Data Sheet Section 6.4 if val > 20: @@ -558,7 +574,7 @@ def signal_bandwidth(self): value to increase throughput or to a lower value to increase the likelihood of successfully received payloads). Valid values are listed in RFM9x.bw_bins.""" - bw_id = (self._read_u8(_RH_RF95_REG_1D_MODEM_CONFIG1) & 0xf0) >> 4 + bw_id = (self._read_u8(_RH_RF95_REG_1D_MODEM_CONFIG1) & 0xF0) >> 4 if bw_id >= len(self.bw_bins): current_bandwidth = 500000 else: @@ -575,7 +591,7 @@ def signal_bandwidth(self, val): bw_id = 9 self._write_u8( _RH_RF95_REG_1D_MODEM_CONFIG1, - (self._read_u8(_RH_RF95_REG_1D_MODEM_CONFIG1) & 0x0f) | (bw_id << 4) + (self._read_u8(_RH_RF95_REG_1D_MODEM_CONFIG1) & 0x0F) | (bw_id << 4), ) @property @@ -584,7 +600,7 @@ def coding_rate(self): correction (try setting to a higher value to increase tolerance of short bursts of interference or to a lower value to increase bit rate). Valid values are limited to 5, 6, 7, or 8.""" - cr_id = (self._read_u8(_RH_RF95_REG_1D_MODEM_CONFIG1) & 0x0e) >> 1 + cr_id = (self._read_u8(_RH_RF95_REG_1D_MODEM_CONFIG1) & 0x0E) >> 1 denominator = cr_id + 4 return denominator @@ -595,7 +611,7 @@ def coding_rate(self, val): cr_id = denominator - 4 self._write_u8( _RH_RF95_REG_1D_MODEM_CONFIG1, - (self._read_u8(_RH_RF95_REG_1D_MODEM_CONFIG1) & 0xf1) | (cr_id << 1) + (self._read_u8(_RH_RF95_REG_1D_MODEM_CONFIG1) & 0xF1) | (cr_id << 1), ) @property @@ -604,25 +620,21 @@ def spreading_factor(self): value to increase the receiver's ability to distinguish signal from noise or to a lower value to increase the data transmission rate). Valid values are limited to 6, 7, 8, 9, 10, 11, or 12.""" - sf_id = (self._read_u8(_RH_RF95_REG_1E_MODEM_CONFIG2) & 0xf0) >> 4 + sf_id = (self._read_u8(_RH_RF95_REG_1E_MODEM_CONFIG2) & 0xF0) >> 4 return sf_id @spreading_factor.setter def spreading_factor(self, val): # Set spreading factor (set to 7 to match RadioHead Sf128). val = min(max(val, 6), 12) - self._write_u8( - _RH_RF95_DETECTION_OPTIMIZE, 0xc5 if val == 6 else 0xc3 - ) - self._write_u8( - _RH_RF95_DETECTION_THRESHOLD, 0x0c if val == 6 else 0x0a - ) + self._write_u8(_RH_RF95_DETECTION_OPTIMIZE, 0xC5 if val == 6 else 0xC3) + self._write_u8(_RH_RF95_DETECTION_THRESHOLD, 0x0C if val == 6 else 0x0A) self._write_u8( _RH_RF95_REG_1E_MODEM_CONFIG2, ( - (self._read_u8(_RH_RF95_REG_1E_MODEM_CONFIG2) & 0x0f) | - ((val << 4) & 0xf0) - ) + (self._read_u8(_RH_RF95_REG_1E_MODEM_CONFIG2) & 0x0F) + | ((val << 4) & 0xF0) + ), ) @property @@ -638,16 +650,21 @@ def enable_crc(self, val): if val: self._write_u8( _RH_RF95_REG_1E_MODEM_CONFIG2, - self._read_u8(_RH_RF95_REG_1E_MODEM_CONFIG2) | 0x04 + self._read_u8(_RH_RF95_REG_1E_MODEM_CONFIG2) | 0x04, ) else: self._write_u8( _RH_RF95_REG_1E_MODEM_CONFIG2, - self._read_u8(_RH_RF95_REG_1E_MODEM_CONFIG2) & 0xfb + self._read_u8(_RH_RF95_REG_1E_MODEM_CONFIG2) & 0xFB, ) - def send(self, data, timeout=2., keep_listening=False, - tx_header=(_RH_BROADCAST_ADDRESS, _RH_BROADCAST_ADDRESS, 0, 0)): + def send( + self, + data, + timeout=2.0, + keep_listening=False, + tx_header=(_RH_BROADCAST_ADDRESS, _RH_BROADCAST_ADDRESS, 0, 0), + ): """Send a string of data using the transmitter. You can only send 252 bytes at a time (limited by chip's FIFO size and appended headers). @@ -670,10 +687,10 @@ def send(self, data, timeout=2., keep_listening=False, # Fill the FIFO with a packet to send. self._write_u8(_RH_RF95_REG_0D_FIFO_ADDR_PTR, 0x00) # FIFO starts at 0. # Write header bytes. - self._write_u8(_RH_RF95_REG_00_FIFO, tx_header[0]) # Header: To - self._write_u8(_RH_RF95_REG_00_FIFO, tx_header[1]) # Header: From - self._write_u8(_RH_RF95_REG_00_FIFO, tx_header[2]) # Header: Id - self._write_u8(_RH_RF95_REG_00_FIFO, tx_header[3]) # Header: Flags + self._write_u8(_RH_RF95_REG_00_FIFO, tx_header[0]) # Header: To + self._write_u8(_RH_RF95_REG_00_FIFO, tx_header[1]) # Header: From + self._write_u8(_RH_RF95_REG_00_FIFO, tx_header[2]) # Header: Id + self._write_u8(_RH_RF95_REG_00_FIFO, tx_header[3]) # Header: Flags # Write payload. self._write_from(_RH_RF95_REG_00_FIFO, data) # Write payload and header length. @@ -691,17 +708,20 @@ def send(self, data, timeout=2., keep_listening=False, if keep_listening: self.listen() else: - # Enter idle mode to stop receiving other packets. + # Enter idle mode to stop receiving other packets. self.idle() # Clear interrupt. self._write_u8(_RH_RF95_REG_12_IRQ_FLAGS, 0xFF) if timed_out: - raise RuntimeError('Timeout during packet send') - - - - def receive(self, timeout=0.5, keep_listening=True, with_header=False, - rx_filter=_RH_BROADCAST_ADDRESS): + raise RuntimeError("Timeout during packet send") + + def receive( + self, + timeout=0.5, + keep_listening=True, + with_header=False, + rx_filter=_RH_BROADCAST_ADDRESS, + ): """Wait to receive a packet from the receiver. Will wait for up to timeout_s amount of seconds for a packet to be received and decoded. If a packet is found the payload bytes are returned, otherwise None is returned (which indicates the timeout elapsed with no @@ -753,8 +773,11 @@ def receive(self, timeout=0.5, keep_listening=True, with_header=False, packet = bytearray(length) # Read the packet. self._read_into(_RH_RF95_REG_00_FIFO, packet) - if (rx_filter != _RH_BROADCAST_ADDRESS and packet[0] != _RH_BROADCAST_ADDRESS - and packet[0] != rx_filter): + if ( + rx_filter != _RH_BROADCAST_ADDRESS + and packet[0] != _RH_BROADCAST_ADDRESS + and packet[0] != rx_filter + ): packet = None elif not with_header: # skip the header if not wanted packet = packet[4:] @@ -762,7 +785,7 @@ def receive(self, timeout=0.5, keep_listening=True, with_header=False, if keep_listening: self.listen() else: - # Enter idle mode to stop receiving other packets. + # Enter idle mode to stop receiving other packets. self.idle() # Clear interrupt. self._write_u8(_RH_RF95_REG_12_IRQ_FLAGS, 0xFF) diff --git a/docs/conf.py b/docs/conf.py index 2c18c73..ef56f6e 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -2,7 +2,8 @@ import os import sys -sys.path.insert(0, os.path.abspath('..')) + +sys.path.insert(0, os.path.abspath("..")) # -- General configuration ------------------------------------------------ @@ -10,10 +11,10 @@ # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # ones. extensions = [ - 'sphinx.ext.autodoc', - 'sphinx.ext.intersphinx', + "sphinx.ext.autodoc", + "sphinx.ext.intersphinx", #'sphinx.ext.napoleon' - 'sphinx.ext.todo', + "sphinx.ext.todo", ] # Uncomment the below if you use native CircuitPython modules such as @@ -22,29 +23,36 @@ # autodoc_mock_imports = ["digitalio", "busio", "micropython", "adafruit_bus_device.spi_device", "adafruit_bus_device"] -intersphinx_mapping = {'python': ('https://docs.python.org/3.4', None),'BusDevice': ('https://circuitpython.readthedocs.io/projects/busdevice/en/latest/', None),'CircuitPython': ('https://circuitpython.readthedocs.io/en/latest/', None)} +intersphinx_mapping = { + "python": ("https://docs.python.org/3.4", None), + "BusDevice": ( + "https://circuitpython.readthedocs.io/projects/busdevice/en/latest/", + None, + ), + "CircuitPython": ("https://circuitpython.readthedocs.io/en/latest/", None), +} # Add any paths that contain templates here, relative to this directory. -templates_path = ['_templates'] +templates_path = ["_templates"] -source_suffix = '.rst' +source_suffix = ".rst" # The master toctree document. -master_doc = 'index' +master_doc = "index" # General information about the project. -project = u'Adafruit rfm9x Library' -copyright = u'2018 Tony DiCola' -author = u'Tony DiCola' +project = u"Adafruit rfm9x Library" +copyright = u"2018 Tony DiCola" +author = u"Tony DiCola" # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the # built documents. # # The short X.Y version. -version = u'1.0' +version = u"1.0" # The full version, including alpha/beta/rc tags. -release = u'1.0' +release = u"1.0" # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. @@ -56,7 +64,7 @@ # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. # This patterns also effect to html_static_path and html_extra_path -exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store', '.env', 'CODE_OF_CONDUCT.md'] +exclude_patterns = ["_build", "Thumbs.db", ".DS_Store", ".env", "CODE_OF_CONDUCT.md"] # The reST default role (used for this markup: `text`) to use for all # documents. @@ -68,7 +76,7 @@ add_function_parentheses = True # The name of the Pygments (syntax highlighting) style to use. -pygments_style = 'sphinx' +pygments_style = "sphinx" # If true, `todo` and `todoList` produce output, else they produce nothing. todo_include_todos = False @@ -83,59 +91,62 @@ # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. # -on_rtd = os.environ.get('READTHEDOCS', None) == 'True' +on_rtd = os.environ.get("READTHEDOCS", None) == "True" if not on_rtd: # only import and set the theme if we're building docs locally try: import sphinx_rtd_theme - html_theme = 'sphinx_rtd_theme' - html_theme_path = [sphinx_rtd_theme.get_html_theme_path(), '.'] + + html_theme = "sphinx_rtd_theme" + html_theme_path = [sphinx_rtd_theme.get_html_theme_path(), "."] except: - html_theme = 'default' - html_theme_path = ['.'] + html_theme = "default" + html_theme_path = ["."] else: - html_theme_path = ['.'] + html_theme_path = ["."] # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". -html_static_path = ['_static'] +html_static_path = ["_static"] # The name of an image file (relative to this directory) to use as a favicon of # the docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 # pixels large. # -html_favicon = '_static/favicon.ico' +html_favicon = "_static/favicon.ico" # Output file base name for HTML help builder. -htmlhelp_basename = 'AdafruitRfm9xLibrarydoc' +htmlhelp_basename = "AdafruitRfm9xLibrarydoc" # -- Options for LaTeX output --------------------------------------------- latex_elements = { - # The paper size ('letterpaper' or 'a4paper'). - # - # 'papersize': 'letterpaper', - - # The font size ('10pt', '11pt' or '12pt'). - # - # 'pointsize': '10pt', - - # Additional stuff for the LaTeX preamble. - # - # 'preamble': '', - - # Latex figure (float) alignment - # - # 'figure_align': 'htbp', + # The paper size ('letterpaper' or 'a4paper'). + # + # 'papersize': 'letterpaper', + # The font size ('10pt', '11pt' or '12pt'). + # + # 'pointsize': '10pt', + # Additional stuff for the LaTeX preamble. + # + # 'preamble': '', + # Latex figure (float) alignment + # + # 'figure_align': 'htbp', } # Grouping the document tree into LaTeX files. List of tuples # (source start file, target name, title, # author, documentclass [howto, manual, or own class]). latex_documents = [ - (master_doc, 'Adafruitrfm9xLibrary.tex', u'Adafruitrfm9x Library Documentation', - author, 'manual'), + ( + master_doc, + "Adafruitrfm9xLibrary.tex", + u"Adafruitrfm9x Library Documentation", + author, + "manual", + ), ] # -- Options for manual page output --------------------------------------- @@ -143,8 +154,13 @@ # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). man_pages = [ - (master_doc, 'Adafruitrfm9xlibrary', u'Adafruit rfm9x Library Documentation', - [author], 1) + ( + master_doc, + "Adafruitrfm9xlibrary", + u"Adafruit rfm9x Library Documentation", + [author], + 1, + ) ] # -- Options for Texinfo output ------------------------------------------- @@ -153,7 +169,13 @@ # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ - (master_doc, 'Adafruitrfm9xLibrary', u'Adafruit rfm9x Library Documentation', - author, 'Adafruitrfm9xLibrary', 'One line description of project.', - 'Miscellaneous'), + ( + master_doc, + "Adafruitrfm9xLibrary", + u"Adafruit rfm9x Library Documentation", + author, + "Adafruitrfm9xLibrary", + "One line description of project.", + "Miscellaneous", + ), ] diff --git a/examples/rfm9x_rpi_interrupt.py b/examples/rfm9x_rpi_interrupt.py index 31e01e4..6943c0c 100644 --- a/examples/rfm9x_rpi_interrupt.py +++ b/examples/rfm9x_rpi_interrupt.py @@ -13,23 +13,23 @@ # setup interrupt callback function def rfm9x_callback(rfm9x_irq): - global packet_received #pylint: disable=global-statement - print("IRQ detected ",rfm9x_irq, rfm9x.rx_done) + global packet_received # pylint: disable=global-statement + print("IRQ detected ", rfm9x_irq, rfm9x.rx_done) # check to see if this was a rx interrupt - ignore tx if rfm9x.rx_done: - packet = rfm9x.receive(timeout = None) + packet = rfm9x.receive(timeout=None) if packet is not None: packet_received = True # Received a packet! # Print out the raw bytes of the packet: - print('Received (raw bytes): {0}'.format(packet)) + print("Received (raw bytes): {0}".format(packet)) print([hex(x) for x in packet]) - print('RSSI: {0}'.format(rfm9x.rssi)) + print("RSSI: {0}".format(rfm9x.rssi)) # Define radio parameters. RADIO_FREQ_MHZ = 915.0 # Frequency of the radio in Mhz. Must match your - # module! Can be a value like 915.0, 433.0, etc. +# module! Can be a value like 915.0, 433.0, etc. # Define pins connected to the chip, use these if wiring up the breakout according to the guide: CS = digitalio.DigitalInOut(board.CE1) @@ -51,25 +51,25 @@ def rfm9x_callback(rfm9x_irq): # configure the interrupt pin and event handling. RFM9X_G0 = 22 io.setmode(io.BCM) -io.setup(RFM9X_G0, io.IN,pull_up_down=io.PUD_DOWN) # activate input -io.add_event_detect(RFM9X_G0,io.RISING) -io.add_event_callback(RFM9X_G0,rfm9x_callback) +io.setup(RFM9X_G0, io.IN, pull_up_down=io.PUD_DOWN) # activate input +io.add_event_detect(RFM9X_G0, io.RISING) +io.add_event_callback(RFM9X_G0, rfm9x_callback) packet_received = False # Send a packet. Note you can only send a packet up to 252 bytes in length. # This is a limitation of the radio packet size, so if you need to send larger # amounts of data you will need to break it into smaller send calls. Each send # call will wait for the previous one to finish before continuing. -rfm9x.send(bytes("Hello world!\r\n","utf-8"), keep_listening = True) -print('Sent Hello World message!') +rfm9x.send(bytes("Hello world!\r\n", "utf-8"), keep_listening=True) +print("Sent Hello World message!") # Wait to receive packets. Note that this library can't receive data at a fast # rate, in fact it can only receive and process one 252 byte packet at a time. # This means you should only use this for low bandwidth scenarios, like sending # and receiving a single message at a time. -print('Waiting for packets...') +print("Waiting for packets...") while True: - time.sleep(.1) + time.sleep(0.1) if packet_received: - print('received message!') + print("received message!") packet_received = False diff --git a/examples/rfm9x_simpletest.py b/examples/rfm9x_simpletest.py index a0dd436..9f63a3a 100644 --- a/examples/rfm9x_simpletest.py +++ b/examples/rfm9x_simpletest.py @@ -9,7 +9,7 @@ # Define radio parameters. RADIO_FREQ_MHZ = 915.0 # Frequency of the radio in Mhz. Must match your - # module! Can be a value like 915.0, 433.0, etc. +# module! Can be a value like 915.0, 433.0, etc. # Define pins connected to the chip, use these if wiring up the breakout according to the guide: CS = digitalio.DigitalInOut(board.D5) @@ -40,36 +40,36 @@ # This is a limitation of the radio packet size, so if you need to send larger # amounts of data you will need to break it into smaller send calls. Each send # call will wait for the previous one to finish before continuing. -rfm9x.send(bytes("Hello world!\r\n","utf-8")) -print('Sent Hello World message!') +rfm9x.send(bytes("Hello world!\r\n", "utf-8")) +print("Sent Hello World message!") # Wait to receive packets. Note that this library can't receive data at a fast # rate, in fact it can only receive and process one 252 byte packet at a time. # This means you should only use this for low bandwidth scenarios, like sending # and receiving a single message at a time. -print('Waiting for packets...') +print("Waiting for packets...") while True: packet = rfm9x.receive() # Optionally change the receive timeout from its default of 0.5 seconds: - #packet = rfm9x.receive(timeout=5.0) + # packet = rfm9x.receive(timeout=5.0) # If no packet was received during the timeout then None is returned. if packet is None: # Packet has not been received LED.value = False - print('Received nothing! Listening again...') + print("Received nothing! Listening again...") else: # Received a packet! LED.value = True # Print out the raw bytes of the packet: - print('Received (raw bytes): {0}'.format(packet)) + print("Received (raw bytes): {0}".format(packet)) # And decode to ASCII text and print it too. Note that you always # receive raw bytes and need to convert to a text format like ASCII # if you intend to do string processing on your data. Make sure the # sending side is sending ASCII data before you try to decode! - packet_text = str(packet, 'ascii') - print('Received (ASCII): {0}'.format(packet_text)) + packet_text = str(packet, "ascii") + print("Received (ASCII): {0}".format(packet_text)) # Also read the RSSI (signal strength) of the last received message and # print it. rssi = rfm9x.rssi - print('Received signal strength: {0} dB'.format(rssi)) + print("Received signal strength: {0} dB".format(rssi)) diff --git a/examples/rfm9x_transmit.py b/examples/rfm9x_transmit.py index 6a558ba..49d9728 100644 --- a/examples/rfm9x_transmit.py +++ b/examples/rfm9x_transmit.py @@ -8,14 +8,14 @@ import adafruit_rfm9x # set the time interval (seconds) for sending packets -transmit_interval=10 +transmit_interval = 10 # Define radio parameters. -RADIO_FREQ_MHZ = 915.0 # Frequency of the radio in Mhz. Must match your - # module! Can be a value like 915.0, 433.0, etc. +RADIO_FREQ_MHZ = 915.0 # Frequency of the radio in Mhz. Must match your +# module! Can be a value like 915.0, 433.0, etc. # Define pins connected to the chip. -CS = digitalio.DigitalInOut(board.CE1) +CS = digitalio.DigitalInOut(board.CE1) RESET = digitalio.DigitalInOut(board.D25) # Initialize SPI bus. @@ -34,14 +34,14 @@ # initialize counter counter = 0 -#send a broadcast mesage -rfm9x.send(bytes("message number {}".format(counter),"UTF-8")) +# send a broadcast mesage +rfm9x.send(bytes("message number {}".format(counter), "UTF-8")) # Wait to receive packets. -print('Waiting for packets...') -#initialize flag and timer -send_reading=False -time_now=time.monotonic() +print("Waiting for packets...") +# initialize flag and timer +send_reading = False +time_now = time.monotonic() while True: # Look for a new packet - wait up to 5 seconds: packet = rfm9x.receive(timeout=5.0) @@ -49,12 +49,12 @@ if packet is not None: # Received a packet! # Print out the raw bytes of the packet: - print('Received (raw bytes): {0}'.format(packet)) + print("Received (raw bytes): {0}".format(packet)) # send reading after any packet received - if time.monotonic()-time_now>transmit_interval: - #reset timeer - time_now=time.monotonic() - #clear flag to send data - send_reading=False + if time.monotonic() - time_now > transmit_interval: + # reset timeer + time_now = time.monotonic() + # clear flag to send data + send_reading = False counter = counter + 1 - rfm9x.send(bytes("message number {}".format(counter),"UTF-8")) + rfm9x.send(bytes("message number {}".format(counter), "UTF-8")) diff --git a/setup.py b/setup.py index ed7f39d..f42fbdb 100644 --- a/setup.py +++ b/setup.py @@ -7,6 +7,7 @@ # Always prefer setuptools over distutils from setuptools import setup, find_packages + # To use a consistent encoding from codecs import open from os import path @@ -14,48 +15,39 @@ here = path.abspath(path.dirname(__file__)) # Get the long description from the README file -with open(path.join(here, 'README.rst'), encoding='utf-8') as f: +with open(path.join(here, "README.rst"), encoding="utf-8") as f: long_description = f.read() setup( - name='adafruit-circuitpython-rfm9x', - + name="adafruit-circuitpython-rfm9x", use_scm_version=True, - setup_requires=['setuptools_scm'], - - description='CircuitPython library for RFM95/6/7/8 LoRa 433/915mhz radio modules.', + setup_requires=["setuptools_scm"], + description="CircuitPython library for RFM95/6/7/8 LoRa 433/915mhz radio modules.", long_description=long_description, - long_description_content_type='text/x-rst', - + long_description_content_type="text/x-rst", # The project's main homepage. - url='https://github.com/adafruit/Adafruit_CircuitPython_RFM9x', - + url="https://github.com/adafruit/Adafruit_CircuitPython_RFM9x", # Author details - author='Adafruit Industries', - author_email='circuitpython@adafruit.com', - - install_requires=['Adafruit-Blinka', 'adafruit-circuitpython-busdevice'], - + author="Adafruit Industries", + author_email="circuitpython@adafruit.com", + install_requires=["Adafruit-Blinka", "adafruit-circuitpython-busdevice"], # Choose your license - license='MIT', - + license="MIT", # See https://pypi.python.org/pypi?%3Aaction=list_classifiers classifiers=[ - 'Development Status :: 3 - Alpha', - 'Intended Audience :: Developers', - 'Topic :: Software Development :: Libraries', - 'Topic :: System :: Hardware', - 'License :: OSI Approved :: MIT License', - 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.4', - 'Programming Language :: Python :: 3.5', - 'Programming Language :: Python :: 3.7', + "Development Status :: 3 - Alpha", + "Intended Audience :: Developers", + "Topic :: Software Development :: Libraries", + "Topic :: System :: Hardware", + "License :: OSI Approved :: MIT License", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.4", + "Programming Language :: Python :: 3.5", + "Programming Language :: Python :: 3.7", ], - # What does your project relate to? - keywords='adafruit lora radio rfm95 rfm9x rfm96 rfm97 rfm98 hardware micropython circuitpython', - + keywords="adafruit lora radio rfm95 rfm9x rfm96 rfm97 rfm98 hardware micropython circuitpython", # You can just specify the packages manually here if your project is # simple. Or you can use find_packages(). - py_modules=['adafruit_rfm9x'], + py_modules=["adafruit_rfm9x"], )