Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds support for ble logging characteristic #616

Merged
merged 15 commits into from
Jun 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,15 @@
"request": "launch",
"module": "meshtastic",
"justMyCode": false,
"args": ["--debug", "--ble", "24:62:AB:DD:DF:3A"]
"args": ["--ble", "Meshtastic_9f6e"]
},
{
"name": "meshtastic BLE scan",
"type": "python",
"request": "launch",
"module": "meshtastic",
"justMyCode": false,
"args": ["--debug", "--ble-scan"]
},
{
"name": "meshtastic admin",
Expand Down Expand Up @@ -76,6 +84,14 @@
"justMyCode": true,
"args": ["--debug", "--info"]
},
{
"name": "meshtastic debug BLE",
"type": "python",
"request": "launch",
"module": "meshtastic",
"justMyCode": true,
"args": ["--debug", "--ble", "--info"]
},
{
"name": "meshtastic debug set region",
"type": "python",
Expand Down
15 changes: 6 additions & 9 deletions meshtastic/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1042,16 +1042,11 @@
subscribe()
if args.ble_scan:
logging.debug("BLE scan starting")
client = BLEInterface(None, debugOut=logfile, noProto=args.noproto)
try:
for x in client.scan():
print(f"Found: name='{x[1].local_name}' address='{x[0].address}'")
finally:
client.close()
for x in BLEInterface.scan():
print(f"Found: name='{x.name}' address='{x.address}'")

Check warning on line 1046 in meshtastic/__main__.py

View check run for this annotation

Codecov / codecov/patch

meshtastic/__main__.py#L1045-L1046

Added lines #L1045 - L1046 were not covered by tests
meshtastic.util.our_exit("BLE scan finished", 0)
return
elif args.ble:
client = BLEInterface(args.ble, debugOut=logfile, noProto=args.noproto, noNodes=args.no_nodes)
client = BLEInterface(args.ble if args.ble != "any" else None, debugOut=logfile, noProto=args.noproto, noNodes=args.no_nodes)

Check warning on line 1049 in meshtastic/__main__.py

View check run for this annotation

Codecov / codecov/patch

meshtastic/__main__.py#L1049

Added line #L1049 was not covered by tests
elif args.host:
try:
client = meshtastic.tcp_interface.TCPInterface(
Expand Down Expand Up @@ -1119,8 +1114,10 @@

group.add_argument(
"--ble",
help="The BLE device address or name to connect to",
help="Connect to a BLE device, optionally specifying a device name (defaults to 'any')",
nargs="?",
default=None,
const="any"
)

return parser
Expand Down
Loading
Loading