Skip to content

Commit 67cb5c9

Browse files
committed
Update network examples
1 parent 9e0684d commit 67cb5c9

File tree

2 files changed

+20
-16
lines changed

2 files changed

+20
-16
lines changed

examples/network/LoRa_simple_gateway.py

+10-8
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
import os, sys
22
currentdir = os.path.dirname(os.path.realpath(__file__))
3-
parentdir = os.path.dirname(currentdir)
4-
sys.path.append(parentdir)
5-
from LoRaRF import SX126x
3+
sys.path.append(os.path.dirname(os.path.dirname(currentdir)))
4+
from LoRaRF import SX126x, LoRaSpi, LoRaGpio
65
import time
76
import struct
87

9-
# Begin LoRa radio and set NSS, reset, busy, IRQ, txen, and rxen pin with connected Raspberry Pi gpio pins
10-
busId = 1; csId = 0
11-
resetPin = 22; busyPin = 23; irqPin = -1; txenPin = 5; rxenPin = 25; wakePin = 18
12-
LoRa = SX126x()
8+
# Begin LoRa radio with connected SPI bus and IO pins (cs and reset) on GPIO
9+
# SPI is defined by bus ID and cs ID and IO pins defined by chip and offset number
10+
spi = LoRaSpi(0, 0)
11+
cs = LoRaGpio(0, 8)
12+
reset = LoRaGpio(0, 24)
13+
busy = LoRaGpio(0, 23)
14+
LoRa = SX126x(spi, cs, reset, busy)
1315
print("Begin LoRa radio")
14-
if not LoRa.begin(busId, csId, resetPin, busyPin, irqPin, txenPin, rxenPin, wakePin) :
16+
if not LoRa.begin() :
1517
raise Exception("Something wrong, can't begin LoRa radio")
1618

1719
# Configure LoRa to use TCXO with DIO3 as control

examples/network/LoRa_simple_node.py

+10-8
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
11
import os, sys
22
currentdir = os.path.dirname(os.path.realpath(__file__))
3-
parentdir = os.path.dirname(currentdir)
4-
sys.path.append(parentdir)
5-
from LoRaRF import SX126x
3+
sys.path.append(os.path.dirname(os.path.dirname(currentdir)))
4+
from LoRaRF import SX126x, LoRaSpi, LoRaGpio
65
import time
76
import struct
87
import random
98

10-
# Begin LoRa radio and set NSS, reset, busy, IRQ, txen, and rxen pin with connected Raspberry Pi gpio pins
11-
busId = 1; csId = 1
12-
resetPin = 27; busyPin = 24; irqPin = -1; txenPin = 5; rxenPin = 25; wakePin = 17
13-
LoRa = SX126x()
9+
# Begin LoRa radio with connected SPI bus and IO pins (cs and reset) on GPIO
10+
# SPI is defined by bus ID and cs ID and IO pins defined by chip and offset number
11+
spi = LoRaSpi(0, 0)
12+
cs = LoRaGpio(0, 8)
13+
reset = LoRaGpio(0, 24)
14+
busy = LoRaGpio(0, 23)
15+
LoRa = SX126x(spi, cs, reset, busy)
1416
print("Begin LoRa radio")
15-
if not LoRa.begin(busId, csId, resetPin, busyPin, irqPin, txenPin, rxenPin, wakePin) :
17+
if not LoRa.begin() :
1618
raise Exception("Something wrong, can't begin LoRa radio")
1719

1820
# Configure LoRa to use TCXO with DIO3 as control

0 commit comments

Comments
 (0)