Skip to content

Commit 5c2851d

Browse files
committed
nargs='?' is awesome! get rid of ble_dest.
1 parent 7e44069 commit 5c2851d

2 files changed

Lines changed: 5 additions & 9 deletions

File tree

.vscode/launch.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"request": "launch",
1111
"module": "meshtastic",
1212
"justMyCode": false,
13-
"args": ["--ble", "--ble-dest", "Meshtastic_9f6e"]
13+
"args": ["--ble", "Meshtastic_9f6e"]
1414
},
1515
{
1616
"name": "meshtastic BLE scan",

meshtastic/__main__.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1046,7 +1046,7 @@ def common():
10461046
print(f"Found: name='{x.name}' address='{x.address}'")
10471047
meshtastic.util.our_exit("BLE scan finished", 0)
10481048
elif args.ble:
1049-
client = BLEInterface(args.ble_dest, debugOut=logfile, noProto=args.noproto, noNodes=args.no_nodes)
1049+
client = BLEInterface(args.ble if args.ble != "any" else None, debugOut=logfile, noProto=args.noproto, noNodes=args.no_nodes)
10501050
elif args.host:
10511051
try:
10521052
client = meshtastic.tcp_interface.TCPInterface(
@@ -1114,14 +1114,10 @@ def addConnectionArgs(parser: argparse.ArgumentParser) -> argparse.ArgumentParse
11141114

11151115
group.add_argument(
11161116
"--ble",
1117-
help="The BLE device address or name to connect to",
1118-
action="store_true",
1119-
)
1120-
1121-
outer.add_argument(
1122-
"--ble-dest",
1123-
help="The BLE device address or name to connect to",
1117+
help="Connect to a BLE device, optionally specifying a device name (defaults to 'any')",
1118+
nargs="?",
11241119
default=None,
1120+
const="any"
11251121
)
11261122

11271123
return parser

0 commit comments

Comments
 (0)