From d48b941d5640c81aa3c17a8141e4095589e9a4d6 Mon Sep 17 00:00:00 2001 From: Kyle Manna Date: Sat, 19 Sep 2026 12:16:39 -0700 Subject: [PATCH 1/2] messaging: Fix send_cmd destination type handling - Fall back to repeater commands when a destination has no contact type. - Keep an explicit dst_type instead of overwriting it with REPEATER. --- src/meshcore/commands/messaging.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/meshcore/commands/messaging.py b/src/meshcore/commands/messaging.py index dae7936..12cbf49 100644 --- a/src/meshcore/commands/messaging.py +++ b/src/meshcore/commands/messaging.py @@ -73,10 +73,11 @@ class MessagingCommands(CommandHandlerBase): timestamp = int(time.time()) if dst_type is None: - dst_type = dst["type"] - else: # assume destination is a repeater - logger.warning("Can't determine destination type, please ensure contacts first or specify dst_type when calling `send_cmd`. Assuming it's a repeater.") - dst_type = AdvType.REPEATER.value + if isinstance(dst, dict) and "type" in dst: + dst_type = dst["type"] + else: # assume destination is a repeater + logger.warning("Can't determine destination type, please ensure contacts first or specify dst_type when calling `send_cmd`. Assuming it's a repeater.") + dst_type = AdvType.REPEATER.value cmd_data = bytearray([CommandType.SEND_TXT_MSG.value]) if dst_type == AdvType.CHAT.value : From 170f94e0bd3bab60bd75b15858e809ac1d259997 Mon Sep 17 00:00:00 2001 From: Kyle Manna Date: Sat, 19 Sep 2026 12:17:02 -0700 Subject: [PATCH 2/2] tests: Fix ADVERT_PATH packet fixture - Use packet type 0x16 and include the four-byte timestamp so the fixture exercises ADVERT_PATH parsing instead of PRIVATE_KEY handling. - Preserve the embedded zero byte and existing path assertions. --- tests/unit/test_reader.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/unit/test_reader.py b/tests/unit/test_reader.py index 2abc906..335a114 100644 --- a/tests/unit/test_reader.py +++ b/tests/unit/test_reader.py @@ -286,10 +286,10 @@ async def test_advert_path_preserves_embedded_zero_bytes(): dispatcher = _CapturingDispatcher() reader = MessageReader(dispatcher) - # ADVERT_PATH (0x0e), 2 hops, 3-byte hashes. + # ADVERT_PATH (0x16), timestamp 1, 2 hops, 3-byte hashes. # path_len byte: hash mode 2 (3 bytes) + 2 hops = 0x82. # The first hash deliberately contains an embedded 0x00 byte. - packet = bytearray.fromhex("0e8212003456789a") + packet = bytearray.fromhex("16010000008212003456789a") await reader.handle_rx(packet)