From c8b1b8ea6fe823b0c897f0e5f94868b81d00e2c8 Mon Sep 17 00:00:00 2001 From: Rob <95710162+thatSFguy@users.noreply.github.com> Date: Fri, 26 Dec 2025 15:17:46 -0500 Subject: [PATCH 1/2] Filter --reply based on specified channel index Ensures that automatic replies are sent back on the same channel index the message was received on. Previously, all replies defaulted to the primary channel (0), even if the incoming message arrived on a secondary channel. Additionally it ensures incoming messages match the specified channel index. E.g: meshtastic --ch-index 1 --reply . Modified the `onReceive` handler to extract the `channel` index from received packets. This ensures `interface.sendText` targets the originating channel rather than always defaulting to the primary channel. Added a filter to ensure that only the specified channel index is being replied to. --- meshtastic/__main__.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/meshtastic/__main__.py b/meshtastic/__main__.py index 1685400..9962506 100644 --- a/meshtastic/__main__.py +++ b/meshtastic/__main__.py @@ -85,12 +85,18 @@ def onReceive(packet, interface) -> None: if d is not None and args and args.reply: msg = d.get("text") if msg: - rxSnr = packet["rxSnr"] - hopLimit = packet["hopLimit"] - print(f"message: {msg}") - reply = f"got msg '{msg}' with rxSnr: {rxSnr} and hopLimit: {hopLimit}" - print("Sending reply: ", reply) - interface.sendText(reply) + rxChannel = packet.get("channel", 0) + targetChannel = int(args.ch_index or 0) + if rxChannel == targetChannel: + rxSnr = packet["rxSnr"] + hopLimit = packet["hopLimit"] + print(f"message: {msg}") + reply = f"got msg '{msg}' with rxSnr: {rxSnr} and hopLimit: {hopLimit}" + print(f"Received channel {rxChannel}. Sending reply: {reply}") + interface.sendText(reply,channelIndex=rxChannel) + else: + print(f"Ignored message on channel {rxChannel} (waiting for channel {targetChannel})") + except Exception as ex: print(f"Warning: Error processing received packet: {ex}.") From c7f43b3100c55b3fba45232ef5ab0229dfd844c2 Mon Sep 17 00:00:00 2001 From: Ian McEwen Date: Sun, 31 May 2026 12:43:38 -0700 Subject: [PATCH 2/2] Document the use of --ch-index along with --reply a little --- meshtastic/__main__.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/meshtastic/__main__.py b/meshtastic/__main__.py index 9962506..b642080 100644 --- a/meshtastic/__main__.py +++ b/meshtastic/__main__.py @@ -1889,7 +1889,10 @@ def addRemoteActionArgs(parser: argparse.ArgumentParser) -> argparse.ArgumentPar ) group.add_argument( - "--reply", help="Reply to received messages", action="store_true" + "--reply", + help="Reply to received messages on the channel they were received. " + "If '--ch-index' is set, only messages on that channel are replied to.", + action="store_true", ) return parser