Enhance advert storage logic: prioritize direct routes and handle zero-hop measurements

Refactor packet processing: use processed_packet for forwarding and drop reason checks

Fix: Update zero-hop determination logic in AdvertHelper

Fix: Clone packet in process_packet to prevent modification of the original

Fix: Import copy module for deep copying of packets in process_packet
This commit is contained in:
Paul Picazo
2025-12-30 00:02:33 -08:00
parent 75c4967bd6
commit 942d4dfe28
3 changed files with 40 additions and 10 deletions
+6 -2
View File
@@ -1,4 +1,5 @@
import asyncio
import copy
import logging
import struct
import time
@@ -119,6 +120,9 @@ class RepeaterHandler(BaseHandler):
f"rssi={metadata.get('rssi', 'N/A')}, snr={metadata.get('snr', 'N/A')}, mode={mode}"
)
# clone the packet to avoid modifying the original
processed_packet = copy.deepcopy(packet)
snr = metadata.get("snr", 0.0)
rssi = metadata.get("rssi", 0)
transmitted = False
@@ -128,7 +132,7 @@ class RepeaterHandler(BaseHandler):
original_path = list(packet.path) if packet.path else []
# Process for forwarding (skip if in monitor mode or if this is a local transmission)
result = None if (monitor_mode or local_transmission) else self.process_packet(packet, snr)
result = None if (monitor_mode or local_transmission) else self.process_packet(processed_packet, snr)
forwarded_path = None
# For local transmissions, create a direct transmission result
@@ -196,7 +200,7 @@ class RepeaterHandler(BaseHandler):
drop_reason = "Monitor mode"
else:
# Check if packet has a specific drop reason set by handlers
drop_reason = packet.drop_reason or self._get_drop_reason(packet)
drop_reason = processed_packet.drop_reason or self._get_drop_reason(processed_packet)
logger.debug(f"Packet not forwarded: {drop_reason}")
# Extract packet type and route from header