Dead simple serial-over-LoRa pipe using Pycom modules.
Note that this example is only half-duplex. You will need to implement some kind of flow control / media access control to be able to use it like a full duplex pipe.
| import machine | |
| machine.main('main.py') |
| import select | |
| import socket | |
| from machine import UART | |
| from network import LoRa | |
| uart = UART(0, baudrate=115200) | |
| lora_card = LoRa(mode=LoRa.LORA, region=LoRa.EU868) | |
| lora = socket.socket(socket.AF_LORA, socket.SOCK_RAW) | |
| lora.setblocking(True) | |
| ios = [uart, lora] | |
| while True: | |
| readable, _, _ = select.select(ios, [], []) | |
| if lora in readable: | |
| uart.write(lora.recv(128)) | |
| if uart in readable: | |
| lora.send(uart.read(128)) |