mirror of
https://github.com/liberatedsystems/RNode_Firmware_CE.git
synced 2025-05-05 07:55:36 -04:00
Library and example
This commit is contained in:
parent
255d978bd7
commit
0dd6ce6539
4 changed files with 58 additions and 15 deletions
37
Libraries/Example.py
Normal file
37
Libraries/Example.py
Normal file
|
@ -0,0 +1,37 @@
|
|||
# This is a short example program that
|
||||
# demonstrates the bare minimum of using
|
||||
# RNode in a Python program. First we'll
|
||||
# import the RNodeInterface class.
|
||||
from RNode import RNodeInterface
|
||||
|
||||
# We'll also define which serial port the
|
||||
# RNode is attached to.
|
||||
serialPort = "/dev/ttyUSB0"
|
||||
|
||||
# This function gets called every time a
|
||||
# packet is received
|
||||
def gotPacket(data, rnode):
|
||||
print "Received a packet: "+data
|
||||
|
||||
# Create an RNode instance. This configures
|
||||
# and powers up the radio.
|
||||
rnode = RNodeInterface(
|
||||
callback = gotPacket,
|
||||
name = "My RNode",
|
||||
port = serialPort,
|
||||
frequency = 868000000,
|
||||
bandwidth = 125000,
|
||||
txpower = 2,
|
||||
sf = 7,
|
||||
cr = 5,
|
||||
loglevel = RNodeInterface.LOG_DEBUG)
|
||||
|
||||
# Enter a loop waiting for user input.
|
||||
try:
|
||||
print "Waiting for packets, hit enter to send a packet, Ctrl-C to exit"
|
||||
while True:
|
||||
raw_input()
|
||||
rnode.send("Hello World!")
|
||||
except KeyboardInterrupt as e:
|
||||
print ""
|
||||
exit()
|
Loading…
Add table
Add a link
Reference in a new issue