Skip to content

Commit bd788ae

Browse files
authored
Merge pull request #508 from ianmcorvidae/set-ch-index-on-add
Set --ch-index to a newly added channel when --ch-add is set, to allow further modification
2 parents bb8a0d9 + 03abaf6 commit bd788ae

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

meshtastic/__main__.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -597,6 +597,12 @@ def onConnected(interface):
597597
# handle changing channels
598598

599599
if args.ch_add:
600+
channelIndex = our_globals.get_channel_index()
601+
if channelIndex is not None:
602+
# Since we set the channel index after adding a channel, don't allow --ch-index
603+
meshtastic.util.our_exit(
604+
"Warning: '--ch-add' and '--ch-index' are incompatible. Channel not added."
605+
)
600606
closeNow = True
601607
if len(args.ch_add) > 10:
602608
meshtastic.util.our_exit(
@@ -620,6 +626,9 @@ def onConnected(interface):
620626
ch.role = channel_pb2.Channel.Role.SECONDARY
621627
print(f"Writing modified channels to device")
622628
n.writeChannel(ch.index)
629+
if channelIndex is None:
630+
print(f"Setting newly-added channel's {ch.index} as '--ch-index' for further modifications")
631+
our_globals.set_channel_index(ch.index)
623632

624633
if args.ch_del:
625634
closeNow = True

0 commit comments

Comments
 (0)