@@ -343,37 +343,36 @@ def onConnected(interface):
343343 closeNow = True
344344 waitForAckNak = True
345345
346- # Validate owner names before connecting to device
347- if args .set_owner is not None :
348- stripped_long_name = args .set_owner .strip ()
349- if not stripped_long_name :
350- meshtastic .util .our_exit ("ERROR: Long Name cannot be empty or contain only whitespace characters" )
351-
352- if hasattr (args , 'set_owner_short' ) and args .set_owner_short is not None :
353- stripped_short_name = args .set_owner_short .strip ()
354- if not stripped_short_name :
355- meshtastic .util .our_exit ("ERROR: Short Name cannot be empty or contain only whitespace characters" )
356-
357- if args .set_owner and args .set_owner_short :
358- print (f"Setting device owner to { args .set_owner } and short name to { args .set_owner_short } " )
359- elif args .set_owner :
360- print (f"Setting device owner to { args .set_owner } " )
361- elif args .set_owner_short and not args .set_owner :
362- print (f"Setting device owner short to { args .set_owner_short } " )
363-
364- if args .set_is_unmessageable :
346+ long_name = args .set_owner .strip () if args .set_owner else None
347+ short_name = args .set_owner_short .strip () if args .set_owner_short else None
348+
349+ if long_name is not None and not long_name :
350+ meshtastic .util .our_exit ("ERROR: Long Name cannot be empty or contain only whitespace characters" )
351+
352+ if short_name is not None and not short_name :
353+ meshtastic .util .our_exit ("ERROR: Short Name cannot be empty or contain only whitespace characters" )
354+
355+ if long_name and short_name :
356+ print (f"Setting device owner to { long_name } and short name to { short_name } " )
357+ elif long_name :
358+ print (f"Setting device owner to { long_name } " )
359+ elif short_name :
360+ print (f"Setting device owner short to { short_name } " )
361+
362+ unmessagable = None
363+ if args .set_is_unmessageable is not None :
365364 unmessagable = (
366365 meshtastic .util .fromStr (args .set_is_unmessageable )
367366 if isinstance (args .set_is_unmessageable , str )
368367 else args .set_is_unmessageable
369368 )
369+ print (f"Setting device owner is_unmessageable to { unmessagable } " )
370370
371- if unmessagable is not None :
372- print (f"Setting device owner is_unmessageable to { unmessagable } " )
373- interface .getNode (
374- args .dest , False , ** getNode_kwargs ).setOwner (long_name = args .set_owner ,
375- short_name = args .set_owner_short , is_unmessagable = unmessagable
376- )
371+ interface .getNode (args .dest , False , ** getNode_kwargs ).setOwner (
372+ long_name = long_name ,
373+ short_name = short_name ,
374+ is_unmessagable = unmessagable
375+ )
377376
378377 if args .set_canned_message :
379378 closeNow = True
0 commit comments