refactor rxInt

This commit is contained in:
SpudGunMan
2025-10-21 11:00:26 -07:00
parent 34e95c86d6
commit a9a65a6c6d
2 changed files with 32 additions and 28 deletions
+16 -14
View File
@@ -1471,27 +1471,29 @@ def onReceive(packet, interface):
logger.debug(f"Packet Received\n {packet} \n END of packet \n")
# determine the rxNode based on the interface type
if rxType == 'TCPInterface':
rxHost = interface.__dict__.get('hostname', 'unknown')
rxNodeHostName = interface.__dict__.get('ip', None)
rxNode = next(
(i for i in range(1, 10)
if multiple_interface and rxHost and
globals().get(f'hostname{i}', '').split(':', 1)[0] in rxHost and
globals().get(f'interface{i}_type', '') == 'tcp'),None)
if rxType == 'SerialInterface':
rxInterface = interface.__dict__.get('devPath', 'unknown')
rxNode = next(
(i for i in range(1, 10)
if globals().get(f'port{i}', '') in rxInterface),
0)
# if TCPInterface check rxNodeHostName as well
if rxType == 'TCPInterface':
rxHost = interface.__dict__.get('hostname', 'unknown')
rxNodeHostName = interface.__dict__.get('ip', None)
rxNode = next((i for i in range(1, 10)
if multiple_interface and rxHost and
globals().get(f'hostname{i}', '').split(':', 1)[0] in rxHost and
globals().get(f'interface{i}_type', '') == 'tcp'), 0)
if globals().get(f'port{i}', '') in rxInterface),None)
if rxType == 'BLEInterface':
rxNode = next(
(i for i in range(1, 10)
if globals().get(f'interface{i}_type', '') == 'ble'),
0)
if globals().get(f'interface{i}_type', '') == 'ble'),0)
if rxNode is None:
logger.warning(f"System: Received packet on unknown interface packet, dropped. Packet: {packet}")
return
# check if the packet has a channel flag use it ## FIXME needs to be channel hash lookup
if packet.get('channel'):
+16 -14
View File
@@ -235,27 +235,29 @@ def onReceive(packet, interface):
logger.debug(f"Packet Received\n {packet} \n END of packet \n")
# determine the rxNode based on the interface type
if rxType == 'TCPInterface':
rxHost = interface.__dict__.get('hostname', 'unknown')
rxNodeHostName = interface.__dict__.get('ip', None)
rxNode = next(
(i for i in range(1, 10)
if multiple_interface and rxHost and
globals().get(f'hostname{i}', '').split(':', 1)[0] in rxHost and
globals().get(f'interface{i}_type', '') == 'tcp'),None)
if rxType == 'SerialInterface':
rxInterface = interface.__dict__.get('devPath', 'unknown')
rxNode = next(
(i for i in range(1, 10)
if globals().get(f'port{i}', '') in rxInterface),
0)
# if TCPInterface check rxNodeHostName as well
if rxType == 'TCPInterface':
rxHost = interface.__dict__.get('hostname', 'unknown')
rxNodeHostName = interface.__dict__.get('ip', None)
rxNode = next((i for i in range(1, 10)
if multiple_interface and rxHost and
globals().get(f'hostname{i}', '').split(':', 1)[0] in rxHost and
globals().get(f'interface{i}_type', '') == 'tcp'), 0)
if globals().get(f'port{i}', '') in rxInterface),None)
if rxType == 'BLEInterface':
rxNode = next(
(i for i in range(1, 10)
if globals().get(f'interface{i}_type', '') == 'ble'),
0)
if globals().get(f'interface{i}_type', '') == 'ble'),0)
if rxNode is None:
logger.warning(f"System: Received packet on unknown interface packet, dropped. Packet: {packet}")
return
# check if the packet has a channel flag use it ## FIXME needs to be channel hash lookup
if packet.get('channel'):