added rssi and snr reading, set baudrate, set packet_len to 120

This commit is contained in:
Paul 2024-01-08 17:15:08 +01:00
parent 549e74daff
commit a72aa16333
1 changed files with 4 additions and 3 deletions

View File

@ -10,7 +10,7 @@ CS = DigitalInOut(board.CE1)
RESET = DigitalInOut(board.D25)
spi = busio.SPI(board.SCK, MOSI=board.MOSI, MISO=board.MISO)
#rfm = adafruit_rfm69.RFM69(spi, CS, RESET, 868.0)
rfm = adafruit_rfm9x.RFM9x(spi, CS, RESET, 868.0)
rfm = adafruit_rfm9x.RFM9x(spi, CS, RESET, 868.0, baudrate=20000000)
addr = '/tmp/rfmtty'
addr_client = '/tmp/rfmtty_client'
@ -22,12 +22,12 @@ time.sleep(1)
ser = serial.serial_for_url(addr)
packet_len = 120
while True:
packet = None
packet = rfm.receive()
ser_data = bytearray()
while ser.inWaiting() > 0 and len(ser_data) <= 251:
while ser.inWaiting() > 0 and len(ser_data) <= packet_len:
recieved_byte = ser.read(1)
ser_data += recieved_byte
if ser_data == b'':
@ -39,6 +39,7 @@ while True:
pass
else:
print(f'Received lora data: {packet}')
print(f'RSSI: {rfm.last_rssi} SNR: {rfm.last_snr}')
ser.write(packet)
socat_proc.kill()