Skip to content

Commit

Permalink
Merge pull request #508 from ianmcorvidae/set-ch-index-on-add
Browse files Browse the repository at this point in the history
Set --ch-index to a newly added channel when --ch-add is set, to allow further modification
  • Loading branch information
thebentern authored Mar 17, 2024
2 parents bb8a0d9 + 03abaf6 commit bd788ae
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions meshtastic/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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
Expand Down

0 comments on commit bd788ae

Please sign in to comment.