mirror of
https://github.com/meshtastic/python.git
synced 2026-06-02 12:45:00 -04:00
@@ -86,12 +86,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}.")
|
||||
@@ -1927,7 +1933,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
|
||||
|
||||
Reference in New Issue
Block a user