mirror of
https://github.com/markqvist/RNode_Firmware.git
synced 2024-12-25 23:49:41 -05:00
Cleaned up whitespace
This commit is contained in:
parent
a683e2df4d
commit
02525cee55
@ -7,13 +7,15 @@ from RNode import RNodeInterface
|
||||
# We'll also define which serial port the
|
||||
# RNode is attached to.
|
||||
serialPort = "/dev/ttyUSB0"
|
||||
# TODO: Remove
|
||||
serialPort = "/dev/tty.usbserial-DN03E0FQ"
|
||||
|
||||
# This function gets called every time a
|
||||
# packet is received
|
||||
def gotPacket(data, rnode):
|
||||
print "Received a packet: "+data
|
||||
print "RSSI: "+str(rnode.r_stat_rssi)+" dBm"
|
||||
print "SNR: "+str(rnode.r_stat_snr)+" dB"
|
||||
print("Received a packet: "+data)
|
||||
print("RSSI: "+str(rnode.r_stat_rssi)+" dBm")
|
||||
print("SNR: "+str(rnode.r_stat_snr)+" dB")
|
||||
|
||||
# Create an RNode instance. This configures
|
||||
# and powers up the radio.
|
||||
@ -30,10 +32,10 @@ rnode = RNodeInterface(
|
||||
|
||||
# Enter a loop waiting for user input.
|
||||
try:
|
||||
print "Waiting for packets, hit enter to send a packet, Ctrl-C to exit"
|
||||
print("Waiting for packets, hit enter to send a packet, Ctrl-C to exit")
|
||||
while True:
|
||||
raw_input()
|
||||
input()
|
||||
rnode.send("Hello World!")
|
||||
except KeyboardInterrupt as e:
|
||||
print ""
|
||||
print("")
|
||||
exit()
|
@ -1,4 +1,3 @@
|
||||
from __future__ import print_function
|
||||
from time import sleep
|
||||
import sys
|
||||
import serial
|
||||
@ -7,48 +6,47 @@ import time
|
||||
import math
|
||||
|
||||
class KISS():
|
||||
FEND = chr(0xC0)
|
||||
FESC = chr(0xDB)
|
||||
TFEND = chr(0xDC)
|
||||
TFESC = chr(0xDD)
|
||||
FEND = 0xC0
|
||||
FESC = 0xDB
|
||||
TFEND = 0xDC
|
||||
TFESC = 0xDD
|
||||
CMD_UNKNOWN = 0xFE
|
||||
CMD_DATA = 0x00
|
||||
CMD_FREQUENCY = 0x01
|
||||
CMD_BANDWIDTH = 0x02
|
||||
CMD_TXPOWER = 0x03
|
||||
CMD_SF = 0x04
|
||||
CMD_CR = 0x05
|
||||
CMD_RADIO_STATE = 0x06
|
||||
CMD_RADIO_LOCK = 0x07
|
||||
CMD_DETECT = 0x08
|
||||
CMD_PROMISC = 0x0E
|
||||
CMD_READY = 0x0F
|
||||
CMD_STAT_RX = 0x21
|
||||
CMD_STAT_TX = 0x22
|
||||
CMD_STAT_RSSI = 0x23
|
||||
CMD_STAT_SNR = 0x24
|
||||
CMD_BLINK = 0x30
|
||||
CMD_RANDOM = 0x40
|
||||
CMD_FW_VERSION = 0x50
|
||||
CMD_ROM_READ = 0x51
|
||||
|
||||
CMD_UNKNOWN = chr(0xFE)
|
||||
CMD_DATA = chr(0x00)
|
||||
CMD_FREQUENCY = chr(0x01)
|
||||
CMD_BANDWIDTH = chr(0x02)
|
||||
CMD_TXPOWER = chr(0x03)
|
||||
CMD_SF = chr(0x04)
|
||||
CMD_CR = chr(0x05)
|
||||
CMD_RADIO_STATE = chr(0x06)
|
||||
CMD_RADIO_LOCK = chr(0x07)
|
||||
CMD_DETECT = chr(0x08)
|
||||
CMD_PROMISC = chr(0x0E)
|
||||
CMD_READY = chr(0x0F)
|
||||
CMD_STAT_RX = chr(0x21)
|
||||
CMD_STAT_TX = chr(0x22)
|
||||
CMD_STAT_RSSI = chr(0x23)
|
||||
CMD_STAT_SNR = chr(0x24)
|
||||
CMD_BLINK = chr(0x30)
|
||||
CMD_RANDOM = chr(0x40)
|
||||
CMD_FW_VERSION = chr(0x50)
|
||||
CMD_ROM_READ = chr(0x51)
|
||||
DETECT_REQ = 0x73
|
||||
DETECT_RESP = 0x46
|
||||
|
||||
DETECT_REQ = chr(0x73)
|
||||
DETECT_RESP = chr(0x46)
|
||||
RADIO_STATE_OFF = 0x00
|
||||
RADIO_STATE_ON = 0x01
|
||||
RADIO_STATE_ASK = 0xFF
|
||||
|
||||
RADIO_STATE_OFF = chr(0x00)
|
||||
RADIO_STATE_ON = chr(0x01)
|
||||
RADIO_STATE_ASK = chr(0xFF)
|
||||
|
||||
CMD_ERROR = chr(0x90)
|
||||
ERROR_INITRADIO = chr(0x01)
|
||||
ERROR_TXFAILED = chr(0x02)
|
||||
ERROR_EEPROM_LOCKED = chr(0x03)
|
||||
CMD_ERROR = chr0x90
|
||||
ERROR_INITRADIO = chr0x01
|
||||
ERROR_TXFAILED = chr0x02
|
||||
ERROR_EEPROM_LOCKED = chr0x03
|
||||
|
||||
@staticmethod
|
||||
def escape(data):
|
||||
data = data.replace(chr(0xdb), chr(0xdb)+chr(0xdd))
|
||||
data = data.replace(chr(0xc0), chr(0xdb)+chr(0xdc))
|
||||
data = data.replace(bytes([0xdb]), bytes([0xdb, 0xdd]))
|
||||
data = data.replace(bytes([0xc0]), bytes([0xdb, 0xdc]))
|
||||
return data
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user