mirror of
https://github.com/rightup/pyMC_Repeater.git
synced 2026-03-28 17:43:06 +01:00
add tests and more validation to packets, remove crc setting from config as hardcoded.
This commit is contained in:
@@ -133,9 +133,6 @@ radio:
|
||||
# Sync word (LoRa network ID)
|
||||
sync_word: 13380
|
||||
|
||||
# Enable CRC checking
|
||||
crc_enabled: true
|
||||
|
||||
# Use implicit header mode
|
||||
implicit_header: false
|
||||
|
||||
|
||||
@@ -513,6 +513,8 @@ class RepeaterHandler(BaseHandler):
|
||||
if self.is_duplicate(packet):
|
||||
packet.drop_reason = "Duplicate"
|
||||
return None
|
||||
|
||||
self.mark_seen(packet)
|
||||
|
||||
if packet.path is None:
|
||||
packet.path = bytearray()
|
||||
@@ -522,12 +524,22 @@ class RepeaterHandler(BaseHandler):
|
||||
packet.path.append(self.local_hash)
|
||||
packet.path_len = len(packet.path)
|
||||
|
||||
self.mark_seen(packet)
|
||||
|
||||
return packet
|
||||
|
||||
def direct_forward(self, packet: Packet) -> Optional[Packet]:
|
||||
|
||||
# Validate packet (empty payload, oversized path, etc.)
|
||||
valid, reason = self.validate_packet(packet)
|
||||
if not valid:
|
||||
packet.drop_reason = reason
|
||||
return None
|
||||
|
||||
# Check if packet is marked do-not-retransmit
|
||||
if packet.is_marked_do_not_retransmit():
|
||||
if not packet.drop_reason:
|
||||
packet.drop_reason = "Marked do not retransmit"
|
||||
return None
|
||||
|
||||
# Check if we're the next hop
|
||||
if not packet.path or len(packet.path) == 0:
|
||||
packet.drop_reason = "Direct: no path"
|
||||
@@ -543,12 +555,11 @@ class RepeaterHandler(BaseHandler):
|
||||
packet.drop_reason = "Duplicate"
|
||||
return None
|
||||
|
||||
original_path = list(packet.path)
|
||||
self.mark_seen(packet)
|
||||
|
||||
packet.path = bytearray(packet.path[1:])
|
||||
packet.path_len = len(packet.path)
|
||||
|
||||
self.mark_seen(packet)
|
||||
|
||||
return packet
|
||||
|
||||
@staticmethod
|
||||
|
||||
0
tests/__init__.py
Normal file
0
tests/__init__.py
Normal file
1264
tests/test_engine.py
Normal file
1264
tests/test_engine.py
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user