Periodically try to connect RNodes that were unavailable at startup. Closes #87.
This commit is contained in:
parent
b3d85b583f
commit
18f450c58b
@ -197,15 +197,21 @@ class RNodeInterface(Interface):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
self.open_port()
|
self.open_port()
|
||||||
except Exception as e:
|
|
||||||
RNS.log("Could not open serial port for interface "+str(self), RNS.LOG_ERROR)
|
|
||||||
raise e
|
|
||||||
|
|
||||||
if self.serial.is_open:
|
if self.serial.is_open:
|
||||||
self.configure_device()
|
self.configure_device()
|
||||||
else:
|
else:
|
||||||
raise IOError("Could not open serial port")
|
raise IOError("Could not open serial port")
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
RNS.log("Could not open serial port for interface "+str(self), RNS.LOG_ERROR)
|
||||||
|
RNS.log("The contained exception was: "+str(e), RNS.LOG_ERROR)
|
||||||
|
RNS.log("Reticulum will attempt to bring up this interface periodically", RNS.LOG_ERROR)
|
||||||
|
thread = threading.Thread(target=self.reconnect_port)
|
||||||
|
thread.setDaemon(True)
|
||||||
|
thread.start()
|
||||||
|
|
||||||
|
|
||||||
def open_port(self):
|
def open_port(self):
|
||||||
RNS.log("Opening serial port "+self.port+"...")
|
RNS.log("Opening serial port "+self.port+"...")
|
||||||
self.serial = self.pyserial.Serial(
|
self.serial = self.pyserial.Serial(
|
||||||
@ -620,7 +626,7 @@ class RNodeInterface(Interface):
|
|||||||
def reconnect_port(self):
|
def reconnect_port(self):
|
||||||
while not self.online:
|
while not self.online:
|
||||||
try:
|
try:
|
||||||
time.sleep(3.5)
|
time.sleep(5)
|
||||||
RNS.log("Attempting to reconnect serial port "+str(self.port)+" for "+str(self)+"...", RNS.LOG_VERBOSE)
|
RNS.log("Attempting to reconnect serial port "+str(self.port)+" for "+str(self)+"...", RNS.LOG_VERBOSE)
|
||||||
self.open_port()
|
self.open_port()
|
||||||
if self.serial.is_open:
|
if self.serial.is_open:
|
||||||
|
@ -699,13 +699,22 @@ class Transport:
|
|||||||
timer = threading.Timer(wait_time, interface.process_announce_queue)
|
timer = threading.Timer(wait_time, interface.process_announce_queue)
|
||||||
timer.start()
|
timer.start()
|
||||||
|
|
||||||
wait_time_str = str(round(wait_time*1000,3))+"ms"
|
if wait_time < 1:
|
||||||
|
wait_time_str = str(round(wait_time*1000,2))+"ms"
|
||||||
|
else:
|
||||||
|
wait_time_str = str(round(wait_time*1,2))+"s"
|
||||||
|
|
||||||
ql_str = str(len(interface.announce_queue))
|
ql_str = str(len(interface.announce_queue))
|
||||||
RNS.log("Added announce to queue (height "+ql_str+") on "+str(interface)+" for processing in "+wait_time_str, RNS.LOG_EXTREME)
|
RNS.log("Added announce to queue (height "+ql_str+") on "+str(interface)+" for processing in "+wait_time_str, RNS.LOG_EXTREME)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
wait_time = max(interface.announce_allowed_at - time.time(), 0)
|
wait_time = max(interface.announce_allowed_at - time.time(), 0)
|
||||||
wait_time_str = str(round(wait_time*1000,3))+"ms"
|
|
||||||
|
if wait_time < 1:
|
||||||
|
wait_time_str = str(round(wait_time*1000,2))+"ms"
|
||||||
|
else:
|
||||||
|
wait_time_str = str(round(wait_time*1,2))+"s"
|
||||||
|
|
||||||
ql_str = str(len(interface.announce_queue))
|
ql_str = str(len(interface.announce_queue))
|
||||||
RNS.log("Added announce to queue (height "+ql_str+") on "+str(interface)+" for processing in "+wait_time_str, RNS.LOG_EXTREME)
|
RNS.log("Added announce to queue (height "+ql_str+") on "+str(interface)+" for processing in "+wait_time_str, RNS.LOG_EXTREME)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user