Reverted RNode interface to exclude Android-specific logic
This commit is contained in:
parent
e9de01e10e
commit
9cad90266e
|
@ -100,23 +100,16 @@ class RNodeInterface(Interface):
|
||||||
REQUIRED_FW_VER_MAJ = 1
|
REQUIRED_FW_VER_MAJ = 1
|
||||||
REQUIRED_FW_VER_MIN = 26
|
REQUIRED_FW_VER_MIN = 26
|
||||||
|
|
||||||
|
RECONNECT_WAIT = 5
|
||||||
|
|
||||||
def __init__(self, owner, name, port, frequency = None, bandwidth = None, txpower = None, sf = None, cr = None, flow_control = False, id_interval = None, id_callsign = None):
|
def __init__(self, owner, name, port, frequency = None, bandwidth = None, txpower = None, sf = None, cr = None, flow_control = False, id_interval = None, id_callsign = None):
|
||||||
import importlib
|
import importlib
|
||||||
if not RNS.vendor.platformutils.is_android():
|
if importlib.util.find_spec('serial') != None:
|
||||||
if importlib.util.find_spec('serial') != None:
|
import serial
|
||||||
import serial
|
|
||||||
self.parity = serial.PARITY_NONE
|
|
||||||
else:
|
|
||||||
RNS.log("Using the RNode interface requires a serial communication module to be installed.", RNS.LOG_CRITICAL)
|
|
||||||
RNS.log("You can install one with the command: python3 -m pip install pyserial", RNS.LOG_CRITICAL)
|
|
||||||
RNS.panic()
|
|
||||||
else:
|
else:
|
||||||
if importlib.util.find_spec('usbserial4a') != None:
|
RNS.log("Using the RNode interface requires a serial communication module to be installed.", RNS.LOG_CRITICAL)
|
||||||
from usbserial4a import serial4a as serial
|
RNS.log("You can install one with the command: python3 -m pip install pyserial", RNS.LOG_CRITICAL)
|
||||||
self.parity = "N"
|
RNS.panic()
|
||||||
else:
|
|
||||||
RNS.log("Could not load USB serial module for Android, RNode interface cannot be created.", RNS.LOG_CRITICAL)
|
|
||||||
RNS.panic()
|
|
||||||
|
|
||||||
self.rxb = 0
|
self.rxb = 0
|
||||||
self.txb = 0
|
self.txb = 0
|
||||||
|
@ -150,6 +143,7 @@ class RNodeInterface(Interface):
|
||||||
|
|
||||||
self.last_id = 0
|
self.last_id = 0
|
||||||
self.first_tx = None
|
self.first_tx = None
|
||||||
|
self.reconnect_w = RNodeInterface.RECONNECT_WAIT
|
||||||
|
|
||||||
self.r_frequency = None
|
self.r_frequency = None
|
||||||
self.r_bandwidth = None
|
self.r_bandwidth = None
|
||||||
|
@ -166,6 +160,7 @@ class RNodeInterface(Interface):
|
||||||
self.packet_queue = []
|
self.packet_queue = []
|
||||||
self.flow_control = flow_control
|
self.flow_control = flow_control
|
||||||
self.interface_ready = False
|
self.interface_ready = False
|
||||||
|
self.announce_rate_target = None
|
||||||
|
|
||||||
self.validcfg = True
|
self.validcfg = True
|
||||||
if (self.frequency < RNodeInterface.FREQ_MIN or self.frequency > RNodeInterface.FREQ_MAX):
|
if (self.frequency < RNodeInterface.FREQ_MIN or self.frequency > RNodeInterface.FREQ_MAX):
|
||||||
|
@ -222,34 +217,20 @@ class RNodeInterface(Interface):
|
||||||
|
|
||||||
def open_port(self):
|
def open_port(self):
|
||||||
RNS.log("Opening serial port "+self.port+"...")
|
RNS.log("Opening serial port "+self.port+"...")
|
||||||
if not RNS.vendor.platformutils.is_android():
|
self.serial = self.pyserial.Serial(
|
||||||
self.serial = self.pyserial.Serial(
|
port = self.port,
|
||||||
port = self.port,
|
baudrate = self.speed,
|
||||||
baudrate = self.speed,
|
bytesize = self.databits,
|
||||||
bytesize = self.databits,
|
parity = self.parity,
|
||||||
parity = self.parity,
|
stopbits = self.stopbits,
|
||||||
stopbits = self.stopbits,
|
xonxoff = False,
|
||||||
xonxoff = False,
|
rtscts = False,
|
||||||
rtscts = False,
|
timeout = 0,
|
||||||
timeout = 0,
|
inter_byte_timeout = None,
|
||||||
inter_byte_timeout = None,
|
write_timeout = None,
|
||||||
write_timeout = None,
|
dsrdtr = False,
|
||||||
dsrdtr = False,
|
)
|
||||||
)
|
|
||||||
else:
|
|
||||||
self.serial = self.pyserial.get_serial_port(
|
|
||||||
self.port,
|
|
||||||
baudrate = self.speed,
|
|
||||||
bytesize = self.databits,
|
|
||||||
parity = self.parity,
|
|
||||||
stopbits = self.stopbits,
|
|
||||||
xonxoff = False,
|
|
||||||
rtscts = False,
|
|
||||||
timeout = 0,
|
|
||||||
inter_byte_timeout = None,
|
|
||||||
write_timeout = None,
|
|
||||||
dsrdtr = False,
|
|
||||||
)
|
|
||||||
|
|
||||||
def configure_device(self):
|
def configure_device(self):
|
||||||
sleep(2.0)
|
sleep(2.0)
|
||||||
|
@ -258,10 +239,7 @@ class RNodeInterface(Interface):
|
||||||
thread.start()
|
thread.start()
|
||||||
|
|
||||||
self.detect()
|
self.detect()
|
||||||
if not RNS.vendor.platformutils.is_android():
|
sleep(0.2)
|
||||||
sleep(0.1)
|
|
||||||
else:
|
|
||||||
sleep(0.25)
|
|
||||||
|
|
||||||
if not self.detected:
|
if not self.detected:
|
||||||
raise IOError("Could not detect device")
|
raise IOError("Could not detect device")
|
||||||
|
@ -270,6 +248,7 @@ 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
|
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)
|
||||||
|
@ -375,12 +354,10 @@ class RNodeInterface(Interface):
|
||||||
|
|
||||||
def validateRadioState(self):
|
def validateRadioState(self):
|
||||||
RNS.log("Wating for radio configuration validation for "+str(self)+"...", RNS.LOG_VERBOSE)
|
RNS.log("Wating for radio configuration validation for "+str(self)+"...", RNS.LOG_VERBOSE)
|
||||||
if not RNS.vendor.platformutils.is_android():
|
sleep(0.25);
|
||||||
sleep(0.25);
|
|
||||||
else:
|
|
||||||
sleep(1.00);
|
|
||||||
|
|
||||||
if (self.frequency != self.r_frequency):
|
self.validcfg = True
|
||||||
|
if (self.r_frequency != None and abs(self.frequency - int(self.r_frequency)) > 100):
|
||||||
RNS.log("Frequency mismatch", RNS.LOG_ERROR)
|
RNS.log("Frequency mismatch", RNS.LOG_ERROR)
|
||||||
self.validcfg = False
|
self.validcfg = False
|
||||||
if (self.bandwidth != self.r_bandwidth):
|
if (self.bandwidth != self.r_bandwidth):
|
||||||
|
|
Loading…
Reference in New Issue