From 03abaf605943186b0d88f8b31ba931a014ee21bd Mon Sep 17 00:00:00 2001 From: Ian McEwen Date: Sat, 16 Mar 2024 11:06:32 -0700 Subject: [PATCH] Set --ch-index to a newly added channel when --ch-add is set, to allow further modification --- meshtastic/__main__.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/meshtastic/__main__.py b/meshtastic/__main__.py index c1d2269..c392498 100644 --- a/meshtastic/__main__.py +++ b/meshtastic/__main__.py @@ -597,6 +597,12 @@ def onConnected(interface): # handle changing channels if args.ch_add: + channelIndex = our_globals.get_channel_index() + if channelIndex is not None: + # Since we set the channel index after adding a channel, don't allow --ch-index + meshtastic.util.our_exit( + "Warning: '--ch-add' and '--ch-index' are incompatible. Channel not added." + ) closeNow = True if len(args.ch_add) > 10: meshtastic.util.our_exit( @@ -620,6 +626,9 @@ def onConnected(interface): ch.role = channel_pb2.Channel.Role.SECONDARY print(f"Writing modified channels to device") n.writeChannel(ch.index) + if channelIndex is None: + print(f"Setting newly-added channel's {ch.index} as '--ch-index' for further modifications") + our_globals.set_channel_index(ch.index) if args.ch_del: closeNow = True