mirror of
https://github.com/markqvist/Reticulum.git
synced 2024-12-26 07:59:36 -05:00
Cleanup
This commit is contained in:
parent
16cf1ab1ba
commit
a564dd2b2d
@ -82,14 +82,6 @@ class KISS():
|
|||||||
class RNodeInterface(Interface):
|
class RNodeInterface(Interface):
|
||||||
MAX_CHUNK = 32768
|
MAX_CHUNK = 32768
|
||||||
|
|
||||||
owner = None
|
|
||||||
port = None
|
|
||||||
speed = None
|
|
||||||
databits = None
|
|
||||||
parity = None
|
|
||||||
stopbits = None
|
|
||||||
serial = None
|
|
||||||
|
|
||||||
FREQ_MIN = 137000000
|
FREQ_MIN = 137000000
|
||||||
FREQ_MAX = 1020000000
|
FREQ_MAX = 1020000000
|
||||||
|
|
||||||
@ -294,17 +286,14 @@ class RNodeInterface(Interface):
|
|||||||
# RNS.log("Resetting ESP32-based device before configuration...", RNS.LOG_VERBOSE)
|
# RNS.log("Resetting ESP32-based device before configuration...", RNS.LOG_VERBOSE)
|
||||||
# self.hard_reset()
|
# self.hard_reset()
|
||||||
|
|
||||||
# TODO: Check correct placement for reconnect support
|
|
||||||
RNS.log("SETTING ONLINE STATUS TO TRUE -------------------")
|
|
||||||
|
|
||||||
self.online = True
|
|
||||||
RNS.log("Serial port "+self.port+" is now open")
|
RNS.log("Serial port "+self.port+" is now open")
|
||||||
RNS.log("Configuring RNode interface...", RNS.LOG_VERBOSE)
|
RNS.log("Configuring RNode interface...", RNS.LOG_VERBOSE)
|
||||||
self.initRadio()
|
self.initRadio()
|
||||||
if (self.validateRadioState()):
|
if (self.validateRadioState()):
|
||||||
self.interface_ready = True
|
self.interface_ready = True
|
||||||
RNS.log(str(self)+" is configured and powered up")
|
RNS.log(str(self)+" is configured and powered up")
|
||||||
sleep(1.0)
|
sleep(0.3)
|
||||||
|
self.online = True
|
||||||
else:
|
else:
|
||||||
RNS.log("After configuring "+str(self)+", the reported radio parameters did not match your configuration.", RNS.LOG_ERROR)
|
RNS.log("After configuring "+str(self)+", the reported radio parameters did not match your configuration.", RNS.LOG_ERROR)
|
||||||
RNS.log("Make sure that your hardware actually supports the parameters specified in the configuration", RNS.LOG_ERROR)
|
RNS.log("Make sure that your hardware actually supports the parameters specified in the configuration", RNS.LOG_ERROR)
|
||||||
@ -507,7 +496,7 @@ class RNodeInterface(Interface):
|
|||||||
# TODO: Ensure hotplug support
|
# TODO: Ensure hotplug support
|
||||||
while self.serial.is_open:
|
while self.serial.is_open:
|
||||||
if True or waiting_bytes > 0:
|
if True or waiting_bytes > 0:
|
||||||
# TODO: CHECK multibyte reads
|
# TODO: Check multibyte reads
|
||||||
serial_bytes = self.serial.read()
|
serial_bytes = self.serial.read()
|
||||||
got = len(serial_bytes)
|
got = len(serial_bytes)
|
||||||
|
|
||||||
@ -516,12 +505,10 @@ class RNodeInterface(Interface):
|
|||||||
|
|
||||||
if (in_frame and byte == KISS.FEND and command == KISS.CMD_DATA):
|
if (in_frame and byte == KISS.FEND and command == KISS.CMD_DATA):
|
||||||
in_frame = False
|
in_frame = False
|
||||||
RNS.log("F "+str(len(data_buffer)))
|
|
||||||
self.processIncoming(data_buffer)
|
self.processIncoming(data_buffer)
|
||||||
data_buffer = b""
|
data_buffer = b""
|
||||||
command_buffer = b""
|
command_buffer = b""
|
||||||
elif (byte == KISS.FEND):
|
elif (byte == KISS.FEND):
|
||||||
RNS.log("R")
|
|
||||||
in_frame = True
|
in_frame = True
|
||||||
command = KISS.CMD_UNKNOWN
|
command = KISS.CMD_UNKNOWN
|
||||||
data_buffer = b""
|
data_buffer = b""
|
||||||
@ -529,7 +516,6 @@ class RNodeInterface(Interface):
|
|||||||
elif (in_frame and len(data_buffer) < self.HW_MTU):
|
elif (in_frame and len(data_buffer) < self.HW_MTU):
|
||||||
if (len(data_buffer) == 0 and command == KISS.CMD_UNKNOWN):
|
if (len(data_buffer) == 0 and command == KISS.CMD_UNKNOWN):
|
||||||
command = byte
|
command = byte
|
||||||
RNS.log("C "+RNS.hexrep(command))
|
|
||||||
elif (command == KISS.CMD_DATA):
|
elif (command == KISS.CMD_DATA):
|
||||||
if (byte == KISS.FESC):
|
if (byte == KISS.FESC):
|
||||||
escape = True
|
escape = True
|
||||||
@ -639,10 +625,8 @@ class RNodeInterface(Interface):
|
|||||||
|
|
||||||
elif (command == KISS.CMD_STAT_RSSI):
|
elif (command == KISS.CMD_STAT_RSSI):
|
||||||
self.r_stat_rssi = byte-RNodeInterface.RSSI_OFFSET
|
self.r_stat_rssi = byte-RNodeInterface.RSSI_OFFSET
|
||||||
RNS.log("S1")
|
|
||||||
elif (command == KISS.CMD_STAT_SNR):
|
elif (command == KISS.CMD_STAT_SNR):
|
||||||
self.r_stat_snr = int.from_bytes(bytes([byte]), byteorder="big", signed=True) * 0.25
|
self.r_stat_snr = int.from_bytes(bytes([byte]), byteorder="big", signed=True) * 0.25
|
||||||
RNS.log("S2")
|
|
||||||
elif (command == KISS.CMD_RANDOM):
|
elif (command == KISS.CMD_RANDOM):
|
||||||
self.r_random = byte
|
self.r_random = byte
|
||||||
elif (command == KISS.CMD_PLATFORM):
|
elif (command == KISS.CMD_PLATFORM):
|
||||||
@ -673,11 +657,11 @@ class RNodeInterface(Interface):
|
|||||||
else:
|
else:
|
||||||
self.detected = False
|
self.detected = False
|
||||||
|
|
||||||
else:
|
# else:
|
||||||
RNS.log("NC")
|
# RNS.log("NC")
|
||||||
|
|
||||||
elif (not in_frame and byte != KISS.FEND):
|
# elif (not in_frame and byte != KISS.FEND):
|
||||||
RNS.log("UF")
|
# RNS.log("UF")
|
||||||
|
|
||||||
if got == 0:
|
if got == 0:
|
||||||
time_since_last = int(time.time()*1000) - last_read_ms
|
time_since_last = int(time.time()*1000) - last_read_ms
|
||||||
|
@ -82,14 +82,6 @@ class KISS():
|
|||||||
class RNodeInterface(Interface):
|
class RNodeInterface(Interface):
|
||||||
MAX_CHUNK = 32768
|
MAX_CHUNK = 32768
|
||||||
|
|
||||||
owner = None
|
|
||||||
port = None
|
|
||||||
speed = None
|
|
||||||
databits = None
|
|
||||||
parity = None
|
|
||||||
stopbits = None
|
|
||||||
serial = None
|
|
||||||
|
|
||||||
FREQ_MIN = 137000000
|
FREQ_MIN = 137000000
|
||||||
FREQ_MAX = 1020000000
|
FREQ_MAX = 1020000000
|
||||||
|
|
||||||
@ -224,7 +216,7 @@ class RNodeInterface(Interface):
|
|||||||
port = self.port,
|
port = self.port,
|
||||||
baudrate = self.speed,
|
baudrate = self.speed,
|
||||||
bytesize = self.databits,
|
bytesize = self.databits,
|
||||||
parity = self.parity,
|
parity = self.pyserial.PARITY_NONE,
|
||||||
stopbits = self.stopbits,
|
stopbits = self.stopbits,
|
||||||
xonxoff = False,
|
xonxoff = False,
|
||||||
rtscts = False,
|
rtscts = False,
|
||||||
@ -251,15 +243,14 @@ class RNodeInterface(Interface):
|
|||||||
RNS.log("Resetting ESP32-based device before configuration...", RNS.LOG_VERBOSE)
|
RNS.log("Resetting ESP32-based device before configuration...", RNS.LOG_VERBOSE)
|
||||||
self.hard_reset()
|
self.hard_reset()
|
||||||
|
|
||||||
# TODO: Check whether this needs to be moved
|
|
||||||
self.online = True
|
|
||||||
RNS.log("Serial port "+self.port+" is now open")
|
RNS.log("Serial port "+self.port+" is now open")
|
||||||
RNS.log("Configuring RNode interface...", RNS.LOG_VERBOSE)
|
RNS.log("Configuring RNode interface...", RNS.LOG_VERBOSE)
|
||||||
self.initRadio()
|
self.initRadio()
|
||||||
if (self.validateRadioState()):
|
if (self.validateRadioState()):
|
||||||
self.interface_ready = True
|
self.interface_ready = True
|
||||||
RNS.log(str(self)+" is configured and powered up")
|
RNS.log(str(self)+" is configured and powered up")
|
||||||
sleep(1.0)
|
sleep(0.3)
|
||||||
|
self.online = True
|
||||||
else:
|
else:
|
||||||
RNS.log("After configuring "+str(self)+", the reported radio parameters did not match your configuration.", RNS.LOG_ERROR)
|
RNS.log("After configuring "+str(self)+", the reported radio parameters did not match your configuration.", RNS.LOG_ERROR)
|
||||||
RNS.log("Make sure that your hardware actually supports the parameters specified in the configuration", RNS.LOG_ERROR)
|
RNS.log("Make sure that your hardware actually supports the parameters specified in the configuration", RNS.LOG_ERROR)
|
||||||
|
Loading…
Reference in New Issue
Block a user