Only allow PRIVATE_APP custom port

This commit is contained in:
digitaldisarray
2024-12-31 15:15:18 -08:00
parent 74c911cb75
commit 0fb72b8ad1

View File

@@ -442,7 +442,7 @@ def onConnected(interface):
channelIndex = mt_config.channel_index or 0
if checkChannel(interface, channelIndex):
print(
f"Sending text message {args.sendtext} to {args.dest}:{args.textport} on channelIndex:{channelIndex}"
f"Sending text message {args.sendtext} to {args.dest} on channelIndex:{channelIndex} {"using PRIVATE_APP port" if args.private else ""}"
)
interface.sendText(
args.sendtext,
@@ -450,7 +450,7 @@ def onConnected(interface):
wantAck=True,
channelIndex=channelIndex,
onResponse=interface.getNode(args.dest, False, **getNode_kwargs).onAckNak,
portNum=args.textport
portNum=portnums_pb2.PortNum.PRIVATE_APP if args.private else portnums_pb2.PortNum.TEXT_MESSAGE_APP
)
else:
meshtastic.util.our_exit(
@@ -1593,16 +1593,14 @@ def addRemoteActionArgs(parser: argparse.ArgumentParser) -> argparse.ArgumentPar
group.add_argument(
"--sendtext",
help="Send a text message. Can specify a destination '--dest', port '--textport', and/or channel index '--ch-index'.",
help="Send a text message. Can specify a destination '--dest', use of PRIVATE_APP port '--private', and/or channel index '--ch-index'.",
metavar="TEXT",
)
group.add_argument(
"--textport",
help="Optional argument for sending text messages to the non default port. Use in combination with --sendtext.",
type=int,
default=portnums_pb2.PortNum.TEXT_MESSAGE_APP,
metavar="PORT"
group.add_argument(
"--private",
help="Optional argument for sending text messages to the PRIVATE_APP port. Use in combination with --sendtext.",
action="store_true"
)
group.add_argument(