mirror of
https://github.com/markqvist/Reticulum.git
synced 2024-11-23 06:00:18 +00:00
Refactored processOutgoing to process_outgoing
This commit is contained in:
parent
4a4b625075
commit
36c761e8dd
@ -251,7 +251,7 @@ class AX25KISSInterface(Interface):
|
|||||||
self.owner.inbound(data[AX25.HEADER_SIZE:], self)
|
self.owner.inbound(data[AX25.HEADER_SIZE:], self)
|
||||||
|
|
||||||
|
|
||||||
def processOutgoing(self,data):
|
def process_outgoing(self,data):
|
||||||
datalen = len(data)
|
datalen = len(data)
|
||||||
if self.online:
|
if self.online:
|
||||||
if self.interface_ready:
|
if self.interface_ready:
|
||||||
@ -301,7 +301,7 @@ class AX25KISSInterface(Interface):
|
|||||||
if len(self.packet_queue) > 0:
|
if len(self.packet_queue) > 0:
|
||||||
data = self.packet_queue.pop(0)
|
data = self.packet_queue.pop(0)
|
||||||
self.interface_ready = True
|
self.interface_ready = True
|
||||||
self.processOutgoing(data)
|
self.process_outgoing(data)
|
||||||
elif len(self.packet_queue) == 0:
|
elif len(self.packet_queue) == 0:
|
||||||
self.interface_ready = True
|
self.interface_ready = True
|
||||||
|
|
||||||
|
@ -289,7 +289,7 @@ class KISSInterface(Interface):
|
|||||||
self.owner.inbound(data, self)
|
self.owner.inbound(data, self)
|
||||||
threading.Thread(target=af, daemon=True).start()
|
threading.Thread(target=af, daemon=True).start()
|
||||||
|
|
||||||
def processOutgoing(self,data):
|
def process_outgoing(self,data):
|
||||||
datalen = len(data)
|
datalen = len(data)
|
||||||
if self.online:
|
if self.online:
|
||||||
if self.interface_ready:
|
if self.interface_ready:
|
||||||
@ -323,7 +323,7 @@ class KISSInterface(Interface):
|
|||||||
if len(self.packet_queue) > 0:
|
if len(self.packet_queue) > 0:
|
||||||
data = self.packet_queue.pop(0)
|
data = self.packet_queue.pop(0)
|
||||||
self.interface_ready = True
|
self.interface_ready = True
|
||||||
self.processOutgoing(data)
|
self.process_outgoing(data)
|
||||||
elif len(self.packet_queue) == 0:
|
elif len(self.packet_queue) == 0:
|
||||||
self.interface_ready = True
|
self.interface_ready = True
|
||||||
|
|
||||||
@ -395,7 +395,7 @@ class KISSInterface(Interface):
|
|||||||
while len(frame) < 15:
|
while len(frame) < 15:
|
||||||
frame.append(0x00)
|
frame.append(0x00)
|
||||||
|
|
||||||
self.processOutgoing(bytes(frame))
|
self.process_outgoing(bytes(frame))
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.online = False
|
self.online = False
|
||||||
|
@ -965,7 +965,7 @@ class RNodeInterface(Interface):
|
|||||||
threading.Thread(target=af, daemon=True).start()
|
threading.Thread(target=af, daemon=True).start()
|
||||||
|
|
||||||
|
|
||||||
def processOutgoing(self,data):
|
def process_outgoing(self,data):
|
||||||
datalen = len(data)
|
datalen = len(data)
|
||||||
if self.online:
|
if self.online:
|
||||||
if self.interface_ready:
|
if self.interface_ready:
|
||||||
@ -996,7 +996,7 @@ class RNodeInterface(Interface):
|
|||||||
if len(self.packet_queue) > 0:
|
if len(self.packet_queue) > 0:
|
||||||
data = self.packet_queue.pop(0)
|
data = self.packet_queue.pop(0)
|
||||||
self.interface_ready = True
|
self.interface_ready = True
|
||||||
self.processOutgoing(data)
|
self.process_outgoing(data)
|
||||||
elif len(self.packet_queue) == 0:
|
elif len(self.packet_queue) == 0:
|
||||||
self.interface_ready = True
|
self.interface_ready = True
|
||||||
|
|
||||||
@ -1304,7 +1304,7 @@ class RNodeInterface(Interface):
|
|||||||
if self.first_tx != None:
|
if self.first_tx != None:
|
||||||
if time.time() > self.first_tx + self.id_interval:
|
if time.time() > self.first_tx + self.id_interval:
|
||||||
RNS.log("Interface "+str(self)+" is transmitting beacon data: "+str(self.id_callsign.decode("utf-8")), RNS.LOG_DEBUG)
|
RNS.log("Interface "+str(self)+" is transmitting beacon data: "+str(self.id_callsign.decode("utf-8")), RNS.LOG_DEBUG)
|
||||||
self.processOutgoing(self.id_callsign)
|
self.process_outgoing(self.id_callsign)
|
||||||
|
|
||||||
if (time.time() - self.last_port_io > self.port_io_timeout):
|
if (time.time() - self.last_port_io > self.port_io_timeout):
|
||||||
self.detect()
|
self.detect()
|
||||||
|
@ -190,7 +190,7 @@ class SerialInterface(Interface):
|
|||||||
self.owner.inbound(data, self)
|
self.owner.inbound(data, self)
|
||||||
threading.Thread(target=af, daemon=True).start()
|
threading.Thread(target=af, daemon=True).start()
|
||||||
|
|
||||||
def processOutgoing(self,data):
|
def process_outgoing(self,data):
|
||||||
if self.online:
|
if self.online:
|
||||||
data = bytes([HDLC.FLAG])+HDLC.escape(data)+bytes([HDLC.FLAG])
|
data = bytes([HDLC.FLAG])+HDLC.escape(data)+bytes([HDLC.FLAG])
|
||||||
written = self.serial.write(data)
|
written = self.serial.write(data)
|
||||||
|
@ -470,7 +470,7 @@ class AutoInterface(Interface):
|
|||||||
self.rxb += len(data)
|
self.rxb += len(data)
|
||||||
self.owner.inbound(data, self)
|
self.owner.inbound(data, self)
|
||||||
|
|
||||||
def processOutgoing(self,data):
|
def process_outgoing(self,data):
|
||||||
for peer in self.peers:
|
for peer in self.peers:
|
||||||
try:
|
try:
|
||||||
if self.outbound_udp_socket == None:
|
if self.outbound_udp_socket == None:
|
||||||
|
@ -634,7 +634,7 @@ class I2PInterfacePeer(Interface):
|
|||||||
|
|
||||||
self.owner.inbound(data, self)
|
self.owner.inbound(data, self)
|
||||||
|
|
||||||
def processOutgoing(self, data):
|
def process_outgoing(self, data):
|
||||||
if self.online:
|
if self.online:
|
||||||
while self.writing:
|
while self.writing:
|
||||||
time.sleep(0.001)
|
time.sleep(0.001)
|
||||||
@ -975,7 +975,7 @@ class I2PInterface(Interface):
|
|||||||
self.spawned_interfaces.append(spawned_interface)
|
self.spawned_interfaces.append(spawned_interface)
|
||||||
spawned_interface.read_loop()
|
spawned_interface.read_loop()
|
||||||
|
|
||||||
def processOutgoing(self, data):
|
def process_outgoing(self, data):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def received_announce(self, from_spawned=False):
|
def received_announce(self, from_spawned=False):
|
||||||
|
@ -223,7 +223,7 @@ class Interface:
|
|||||||
wait_time = (tx_time / self.announce_cap)
|
wait_time = (tx_time / self.announce_cap)
|
||||||
self.announce_allowed_at = now + wait_time
|
self.announce_allowed_at = now + wait_time
|
||||||
|
|
||||||
self.processOutgoing(selected["raw"])
|
self.process_outgoing(selected["raw"])
|
||||||
self.sent_announce()
|
self.sent_announce()
|
||||||
|
|
||||||
if selected in self.announce_queue:
|
if selected in self.announce_queue:
|
||||||
|
@ -241,7 +241,7 @@ class KISSInterface(Interface):
|
|||||||
self.owner.inbound(data, self)
|
self.owner.inbound(data, self)
|
||||||
|
|
||||||
|
|
||||||
def processOutgoing(self,data):
|
def process_outgoing(self,data):
|
||||||
datalen = len(data)
|
datalen = len(data)
|
||||||
if self.online:
|
if self.online:
|
||||||
if self.interface_ready:
|
if self.interface_ready:
|
||||||
@ -275,7 +275,7 @@ class KISSInterface(Interface):
|
|||||||
if len(self.packet_queue) > 0:
|
if len(self.packet_queue) > 0:
|
||||||
data = self.packet_queue.pop(0)
|
data = self.packet_queue.pop(0)
|
||||||
self.interface_ready = True
|
self.interface_ready = True
|
||||||
self.processOutgoing(data)
|
self.process_outgoing(data)
|
||||||
elif len(self.packet_queue) == 0:
|
elif len(self.packet_queue) == 0:
|
||||||
self.interface_ready = True
|
self.interface_ready = True
|
||||||
|
|
||||||
@ -344,7 +344,7 @@ class KISSInterface(Interface):
|
|||||||
while len(frame) < 15:
|
while len(frame) < 15:
|
||||||
frame.append(0x00)
|
frame.append(0x00)
|
||||||
|
|
||||||
self.processOutgoing(bytes(frame))
|
self.process_outgoing(bytes(frame))
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.online = False
|
self.online = False
|
||||||
|
@ -166,7 +166,7 @@ class LocalClientInterface(Interface):
|
|||||||
# duration = time.time() - processing_start
|
# duration = time.time() - processing_start
|
||||||
# self.rxptime += duration
|
# self.rxptime += duration
|
||||||
|
|
||||||
def processOutgoing(self, data):
|
def process_outgoing(self, data):
|
||||||
if self.online:
|
if self.online:
|
||||||
try:
|
try:
|
||||||
self.writing = True
|
self.writing = True
|
||||||
@ -350,7 +350,7 @@ class LocalServerInterface(Interface):
|
|||||||
self.clients += 1
|
self.clients += 1
|
||||||
spawned_interface.read_loop()
|
spawned_interface.read_loop()
|
||||||
|
|
||||||
def processOutgoing(self, data):
|
def process_outgoing(self, data):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def received_announce(self, from_spawned=False):
|
def received_announce(self, from_spawned=False):
|
||||||
|
@ -115,7 +115,7 @@ class PipeInterface(Interface):
|
|||||||
self.owner.inbound(data, self)
|
self.owner.inbound(data, self)
|
||||||
|
|
||||||
|
|
||||||
def processOutgoing(self,data):
|
def process_outgoing(self,data):
|
||||||
if self.online:
|
if self.online:
|
||||||
data = bytes([HDLC.FLAG])+HDLC.escape(data)+bytes([HDLC.FLAG])
|
data = bytes([HDLC.FLAG])+HDLC.escape(data)+bytes([HDLC.FLAG])
|
||||||
written = self.process.stdin.write(data)
|
written = self.process.stdin.write(data)
|
||||||
|
@ -604,7 +604,7 @@ class RNodeInterface(Interface):
|
|||||||
self.r_stat_snr = None
|
self.r_stat_snr = None
|
||||||
|
|
||||||
|
|
||||||
def processOutgoing(self,data):
|
def process_outgoing(self,data):
|
||||||
datalen = len(data)
|
datalen = len(data)
|
||||||
if self.online:
|
if self.online:
|
||||||
if self.interface_ready:
|
if self.interface_ready:
|
||||||
@ -635,7 +635,7 @@ class RNodeInterface(Interface):
|
|||||||
if len(self.packet_queue) > 0:
|
if len(self.packet_queue) > 0:
|
||||||
data = self.packet_queue.pop(0)
|
data = self.packet_queue.pop(0)
|
||||||
self.interface_ready = True
|
self.interface_ready = True
|
||||||
self.processOutgoing(data)
|
self.process_outgoing(data)
|
||||||
elif len(self.packet_queue) == 0:
|
elif len(self.packet_queue) == 0:
|
||||||
self.interface_ready = True
|
self.interface_ready = True
|
||||||
|
|
||||||
@ -935,7 +935,7 @@ class RNodeInterface(Interface):
|
|||||||
if self.first_tx != None:
|
if self.first_tx != None:
|
||||||
if time.time() > self.first_tx + self.id_interval:
|
if time.time() > self.first_tx + self.id_interval:
|
||||||
RNS.log("Interface "+str(self)+" is transmitting beacon data: "+str(self.id_callsign.decode("utf-8")), RNS.LOG_DEBUG)
|
RNS.log("Interface "+str(self)+" is transmitting beacon data: "+str(self.id_callsign.decode("utf-8")), RNS.LOG_DEBUG)
|
||||||
self.processOutgoing(self.id_callsign)
|
self.process_outgoing(self.id_callsign)
|
||||||
|
|
||||||
sleep(0.08)
|
sleep(0.08)
|
||||||
|
|
||||||
|
@ -566,7 +566,7 @@ class RNodeMultiInterface(Interface):
|
|||||||
RNS.log("Please update your RNode firmware with rnodeconf from https://github.com/markqvist/Reticulum/RNS/Utilities/rnodeconf.py")
|
RNS.log("Please update your RNode firmware with rnodeconf from https://github.com/markqvist/Reticulum/RNS/Utilities/rnodeconf.py")
|
||||||
RNS.panic()
|
RNS.panic()
|
||||||
|
|
||||||
def processOutgoing(self, data, interface = None):
|
def process_outgoing(self, data, interface = None):
|
||||||
if interface is None:
|
if interface is None:
|
||||||
# do nothing if RNS tries to transmit on this interface directly
|
# do nothing if RNS tries to transmit on this interface directly
|
||||||
pass
|
pass
|
||||||
@ -893,7 +893,7 @@ class RNodeMultiInterface(Interface):
|
|||||||
for interface in self.subinterfaces:
|
for interface in self.subinterfaces:
|
||||||
if interface != 0 and interface.online:
|
if interface != 0 and interface.online:
|
||||||
interface_available = True
|
interface_available = True
|
||||||
self.subinterfaces[interface.index].processOutgoing(self.id_callsign)
|
self.subinterfaces[interface.index].process_outgoing(self.id_callsign)
|
||||||
|
|
||||||
if interface_available:
|
if interface_available:
|
||||||
RNS.log("Interface "+str(self)+" is transmitting beacon data on all subinterfaces: "+str(self.id_callsign.decode("utf-8")), RNS.LOG_DEBUG)
|
RNS.log("Interface "+str(self)+" is transmitting beacon data on all subinterfaces: "+str(self.id_callsign.decode("utf-8")), RNS.LOG_DEBUG)
|
||||||
@ -1205,7 +1205,7 @@ class RNodeSubInterface(Interface):
|
|||||||
self.r_stat_rssi = None
|
self.r_stat_rssi = None
|
||||||
self.r_stat_snr = None
|
self.r_stat_snr = None
|
||||||
|
|
||||||
def processOutgoing(self,data):
|
def process_outgoing(self,data):
|
||||||
if self.online:
|
if self.online:
|
||||||
if self.interface_ready:
|
if self.interface_ready:
|
||||||
if self.flow_control:
|
if self.flow_control:
|
||||||
@ -1217,7 +1217,7 @@ class RNodeSubInterface(Interface):
|
|||||||
if self.parent_interface.first_tx == None:
|
if self.parent_interface.first_tx == None:
|
||||||
self.parent_interface.first_tx = time.time()
|
self.parent_interface.first_tx = time.time()
|
||||||
self.txb += len(data)
|
self.txb += len(data)
|
||||||
self.parent_interface.processOutgoing(data, self)
|
self.parent_interface.process_outgoing(data, self)
|
||||||
else:
|
else:
|
||||||
self.queue(data)
|
self.queue(data)
|
||||||
|
|
||||||
@ -1229,7 +1229,7 @@ class RNodeSubInterface(Interface):
|
|||||||
if len(self.packet_queue) > 0:
|
if len(self.packet_queue) > 0:
|
||||||
data = self.packet_queue.pop(0)
|
data = self.packet_queue.pop(0)
|
||||||
self.interface_ready = True
|
self.interface_ready = True
|
||||||
self.processOutgoing(data)
|
self.process_outgoing(data)
|
||||||
elif len(self.packet_queue) == 0:
|
elif len(self.packet_queue) == 0:
|
||||||
self.interface_ready = True
|
self.interface_ready = True
|
||||||
|
|
||||||
|
@ -138,7 +138,7 @@ class SerialInterface(Interface):
|
|||||||
self.owner.inbound(data, self)
|
self.owner.inbound(data, self)
|
||||||
|
|
||||||
|
|
||||||
def processOutgoing(self,data):
|
def process_outgoing(self,data):
|
||||||
if self.online:
|
if self.online:
|
||||||
data = bytes([HDLC.FLAG])+HDLC.escape(data)+bytes([HDLC.FLAG])
|
data = bytes([HDLC.FLAG])+HDLC.escape(data)+bytes([HDLC.FLAG])
|
||||||
written = self.serial.write(data)
|
written = self.serial.write(data)
|
||||||
|
@ -291,7 +291,7 @@ class TCPClientInterface(Interface):
|
|||||||
|
|
||||||
self.owner.inbound(data, self)
|
self.owner.inbound(data, self)
|
||||||
|
|
||||||
def processOutgoing(self, data):
|
def process_outgoing(self, data):
|
||||||
if self.online:
|
if self.online:
|
||||||
# while self.writing:
|
# while self.writing:
|
||||||
# time.sleep(0.01)
|
# time.sleep(0.01)
|
||||||
@ -593,7 +593,7 @@ class TCPServerInterface(Interface):
|
|||||||
def sent_announce(self, from_spawned=False):
|
def sent_announce(self, from_spawned=False):
|
||||||
if from_spawned: self.oa_freq_deque.append(time.time())
|
if from_spawned: self.oa_freq_deque.append(time.time())
|
||||||
|
|
||||||
def processOutgoing(self, data):
|
def process_outgoing(self, data):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
@ -109,7 +109,7 @@ class UDPInterface(Interface):
|
|||||||
self.rxb += len(data)
|
self.rxb += len(data)
|
||||||
self.owner.inbound(data, self)
|
self.owner.inbound(data, self)
|
||||||
|
|
||||||
def processOutgoing(self,data):
|
def process_outgoing(self,data):
|
||||||
try:
|
try:
|
||||||
udp_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
udp_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||||
udp_socket.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
|
udp_socket.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
|
||||||
|
@ -743,10 +743,10 @@ class Transport:
|
|||||||
i += 1
|
i += 1
|
||||||
|
|
||||||
# Send it
|
# Send it
|
||||||
interface.processOutgoing(masked_raw)
|
interface.process_outgoing(masked_raw)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
interface.processOutgoing(raw)
|
interface.process_outgoing(raw)
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
RNS.log("Error while transmitting on "+str(interface)+". The contained exception was: "+str(e), RNS.LOG_ERROR)
|
RNS.log("Error while transmitting on "+str(interface)+". The contained exception was: "+str(e), RNS.LOG_ERROR)
|
||||||
|
Loading…
Reference in New Issue
Block a user