Skip to content

Commit

Permalink
Merge pull request #666 from ianmcorvidae/fix-set-owner
Browse files Browse the repository at this point in the history
Ensure set-owner combined with set-owner-short sets both values
  • Loading branch information
ianmcorvidae authored Sep 5, 2024
2 parents a689fd7 + 17f3605 commit b59ecff
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 17 deletions.
27 changes: 12 additions & 15 deletions meshtastic/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,19 +315,16 @@ def onConnected(interface):
# can include lat/long/alt etc: latitude = 37.5, longitude = -122.1
interface.localNode.setFixedPosition(lat, lon, alt)

if args.set_owner:
if args.set_owner or args.set_owner_short:
closeNow = True
waitForAckNak = True
print(f"Setting device owner to {args.set_owner}")
interface.getNode(args.dest, False).setOwner(args.set_owner)

if args.set_owner_short:
closeNow = True
waitForAckNak = True
print(f"Setting device owner short to {args.set_owner_short}")
interface.getNode(args.dest, False).setOwner(
long_name=None, short_name=args.set_owner_short
)
if args.set_owner and args.set_owner_short:
print(f"Setting device owner to {args.set_owner} and short name to {args.set_owner_short}")
elif args.set_owner:
print(f"Setting device owner to {args.set_owner}")
else: # short name only
print(f"Setting device owner short to {args.set_owner_short}")
interface.getNode(args.dest, False).setOwner(long_name=args.set_owner, short_name=args.set_owner_short)

# TODO: add to export-config and configure
if args.set_canned_message:
Expand Down Expand Up @@ -1452,6 +1449,10 @@ def initParser():

group.add_argument("--set-owner", help="Set device owner name", action="store")

group.add_argument(
"--set-owner-short", help="Set device owner short name", action="store"
)

group.add_argument(
"--set-canned-message",
help="Set the canned messages plugin message (up to 200 characters).",
Expand All @@ -1464,10 +1465,6 @@ def initParser():
action="store",
)

group.add_argument(
"--set-owner-short", help="Set device owner short name", action="store"
)

group.add_argument(
"--set-ham", help="Set licensed Ham ID and turn off encryption", action="store"
)
Expand Down
4 changes: 2 additions & 2 deletions meshtastic/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import logging
import time

from typing import Union
from typing import Optional, Union

from meshtastic.protobuf import admin_pb2, apponly_pb2, channel_pb2, localonly_pb2, mesh_pb2, portnums_pb2
from meshtastic.util import (
Expand Down Expand Up @@ -279,7 +279,7 @@ def _getAdminChannelIndex(self):
return c.index
return 0

def setOwner(self, long_name=None, short_name=None, is_licensed=False):
def setOwner(self, long_name: Optional[str]=None, short_name: Optional[str]=None, is_licensed: bool=False):
"""Set device owner name"""
logging.debug(f"in setOwner nodeNum:{self.nodeNum}")
p = admin_pb2.AdminMessage()
Expand Down

0 comments on commit b59ecff

Please sign in to comment.