mirror of
https://github.com/markqvist/Reticulum.git
synced 2024-11-22 13:40:19 +00:00
RNode interface
This commit is contained in:
parent
540bde4cd4
commit
c03bce5547
@ -20,7 +20,7 @@ import RNS.vendor.umsgpack as umsgpack
|
||||
APP_NAME = "example_utilitites"
|
||||
|
||||
# We'll also define a default timeout, in seconds
|
||||
APP_TIMEOUT = 10.0
|
||||
APP_TIMEOUT = 15.0
|
||||
|
||||
##########################################################
|
||||
#### Server Part #########################################
|
||||
|
@ -259,6 +259,7 @@ class RNodeInterface(Interface):
|
||||
|
||||
def process_queue(self):
|
||||
if len(self.packet_queue) > 0:
|
||||
sleep(0.5)
|
||||
data = self.packet_queue.pop(0)
|
||||
self.interface_ready = True
|
||||
self.processOutgoing(data)
|
||||
@ -282,6 +283,8 @@ class RNodeInterface(Interface):
|
||||
if (in_frame and byte == KISS.FEND and command == KISS.CMD_DATA):
|
||||
in_frame = False
|
||||
self.processIncoming(data_buffer)
|
||||
data_buffer = ""
|
||||
command_buffer = ""
|
||||
elif (byte == KISS.FEND):
|
||||
in_frame = True
|
||||
command = KISS.CMD_UNKNOWN
|
||||
@ -391,6 +394,7 @@ class RNodeInterface(Interface):
|
||||
else:
|
||||
time_since_last = int(time.time()*1000) - last_read_ms
|
||||
if len(data_buffer) > 0 and time_since_last > self.timeout:
|
||||
RNS.log(str(self)+" serial read timeout", RNS.LOG_EXTREME)
|
||||
data_buffer = ""
|
||||
in_frame = False
|
||||
command = KISS.CMD_UNKNOWN
|
||||
|
@ -191,6 +191,8 @@ class Link:
|
||||
RNS.log("Link "+str(self)+" established with "+str(self.destination)+", RTT is "+str(self.rtt), RNS.LOG_VERBOSE)
|
||||
rtt_data = umsgpack.packb(self.rtt)
|
||||
rtt_packet = RNS.Packet(self, rtt_data, context=RNS.Packet.LRRTT)
|
||||
# TODO: remove
|
||||
RNS.log("Sending RTT packet", RNS.LOG_EXTREME)
|
||||
rtt_packet.send()
|
||||
|
||||
self.status = Link.ACTIVE
|
||||
@ -290,7 +292,7 @@ class Link:
|
||||
next_check = self.request_time + self.proof_timeout
|
||||
sleep_time = next_check - time.time()
|
||||
if time.time() >= self.request_time + self.proof_timeout:
|
||||
#RNS.log("Timeout waiting for RTT packet from link initiator", RNS.LOG_DEBUG)
|
||||
RNS.log("Timeout waiting for RTT packet from link initiator", RNS.LOG_DEBUG)
|
||||
self.status = Link.CLOSED
|
||||
self.teardown_reason = Link.TIMEOUT
|
||||
self.link_closed()
|
||||
|
@ -112,7 +112,9 @@ class Transport:
|
||||
should_transmit = False
|
||||
|
||||
if should_transmit:
|
||||
RNS.log("Transmitting "+str(len(packet.raw))+" bytes via: "+str(interface), RNS.LOG_DEBUG)
|
||||
# TODO: Remove
|
||||
RNS.log("Transmitting "+str(len(packet.raw))+" bytes via: "+str(interface), RNS.LOG_EXTREME)
|
||||
RNS.log("Hash is "+RNS.prettyhexrep(packet.packet_hash), RNS.LOG_EXTREME)
|
||||
interface.processOutgoing(packet.raw)
|
||||
sent = True
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user