martynwheeler / u-lora

raspi-lora for micropython
GNU General Public License v3.0
74 stars 13 forks source link

AttributeError: 'LoRa' object has no attribute 'cs' #2

Open BKuipers opened 2 years ago

BKuipers commented 2 years ago

I have been trying to get this library to work with the client and server example, but i keep getting the error shown in the picture.

image

This is very strange to me because I can see the CS attribute being made in the ulora.py file.

SailingGreg commented 2 years ago

I had the same problem and realised it was because the interrupt routines are being setup before the device is initialised. To address this I move the interrupts setup code down to around line 150 so it is done after the SPI interface is initialised.

    # Setup the module

gpio_interrupt = Pin(self._interrupt, Pin.IN, Pin.PULL_DOWN)

    gpio_interrupt = Pin(self._interrupt, Pin.IN)
    gpio_interrupt.irq(trigger=Pin.IRQ_RISING, handler=self._handle_interrupt)

PS this addresses both the 'cs' error and one that you will get related to 'spi'