Skip to content

Commit 42236f2

Browse files
committed
Merge branch 'ble-logging' into pr-powermon
# Conflicts: # poetry.lock # pyproject.toml
2 parents 821d3e9 + 9004f1e commit 42236f2

5 files changed

Lines changed: 235 additions & 173 deletions

File tree

.vscode/launch.json

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,15 @@
1010
"request": "launch",
1111
"module": "meshtastic",
1212
"justMyCode": false,
13-
"args": ["--debug", "--ble", "24:62:AB:DD:DF:3A"]
13+
"args": ["--ble", "--ble-dest", "Meshtastic_9f6e"]
14+
},
15+
{
16+
"name": "meshtastic BLE scan",
17+
"type": "python",
18+
"request": "launch",
19+
"module": "meshtastic",
20+
"justMyCode": false,
21+
"args": ["--debug", "--ble-scan"]
1422
},
1523
{
1624
"name": "meshtastic admin",
@@ -76,6 +84,14 @@
7684
"justMyCode": true,
7785
"args": ["--debug", "--info"]
7886
},
87+
{
88+
"name": "meshtastic debug BLE",
89+
"type": "python",
90+
"request": "launch",
91+
"module": "meshtastic",
92+
"justMyCode": true,
93+
"args": ["--debug", "--ble", "--info"]
94+
},
7995
{
8096
"name": "meshtastic debug set region",
8197
"type": "debugpy",

meshtastic/__main__.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1085,16 +1085,11 @@ def common():
10851085
subscribe()
10861086
if args.ble_scan:
10871087
logging.debug("BLE scan starting")
1088-
client = BLEInterface(None, debugOut=logfile, noProto=args.noproto)
1089-
try:
1090-
for x in client.scan():
1091-
print(f"Found: name='{x[1].local_name}' address='{x[0].address}'")
1092-
finally:
1093-
client.close()
1088+
for x in BLEInterface.scan():
1089+
print(f"Found: name='{x.name}' address='{x.address}'")
10941090
meshtastic.util.our_exit("BLE scan finished", 0)
1095-
return
10961091
elif args.ble:
1097-
client = BLEInterface(args.ble, debugOut=logfile, noProto=args.noproto, noNodes=args.no_nodes)
1092+
client = BLEInterface(args.ble_dest, debugOut=logfile, noProto=args.noproto, noNodes=args.no_nodes)
10981093
elif args.host:
10991094
try:
11001095
client = meshtastic.tcp_interface.TCPInterface(
@@ -1165,6 +1160,12 @@ def addConnectionArgs(parser: argparse.ArgumentParser) -> argparse.ArgumentParse
11651160
group.add_argument(
11661161
"--ble",
11671162
help="The BLE device address or name to connect to",
1163+
action="store_true",
1164+
)
1165+
1166+
outer.add_argument(
1167+
"--ble-dest",
1168+
help="The BLE device address or name to connect to",
11681169
default=None,
11691170
)
11701171

0 commit comments

Comments
 (0)