Skip to main content

Parse and explore Bluetooth HCI btsnoop captures from Android devices.

Project description

btsnoop-parser

CI

btsnoop-parser is a small library and CLI for exploring Bluetooth btsnoop_hci.log captures produced on Android devices. It focuses on being a lightweight alternative to Wireshark when you only need a quick glance at packet metadata or want to script over captures in Python.

Features

  • Parses BTSnoop HCI logs into friendly Python dictionaries.
  • Provides a Wireshark-style CLI table with optional JSON export.
  • Decodes common HCI command/event payloads.
  • Ships with pure-Python code and zero runtime dependencies.

Installation

pip install btsnoop-parser

To work with a local checkout during development:

pip install -e .

Command Line Usage

After installation the btsnoop_parser entry point becomes available:

# Show the first 10 packets in a capture
btsnoop_parser path/to/btsnoop_hci.log --limit 10

# Emit JSON for scripting
btsnoop_parser path/to/btsnoop_hci.log --json --limit 5

# Print decoded HCI command/event metadata
btsnoop_parser path/to/btsnoop_hci.log --decode

Run btsnoop_parser --help for the complete option list.

Python API

from btsnoop_parser import decode_hci_packet, parse_btsnoop_file

records = parse_btsnoop_file("btsnoop_hci.log")

for record in records[:5]:
    print(record["timestamp"], record["packet_type_name"], record["direction"])
    decoded = decode_hci_packet(record["packet_type"], record["payload"])
    if decoded["type"] == "COMMAND":
        print("  ↳", decoded["name"], hex(decoded["opcode"]))

If you only need to stream over a file without holding everything in memory, btsnoop_parser.iter_records(Path("capture.btsnoop")) yields the same dictionaries as parse_btsnoop_file but lazily.

Development

This project relies on an Automated Testing Pipeline to maintain code quality. A GitHub Action workflow runs the full test suite across multiple Python versions on every push and pull request.

To run the tests locally during development:

# Install development dependencies
pip install ".[dev]"

# Run tests using pytest
pytest

# Optional linting (install optional dev dependencies first)
ruff check

License

MIT © Kranthi

Contributing

Please read CONTRIBUTING.md for guidelines on setting up your environment, running tests, and submitting pull requests.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

btsnoop_parser-0.3.0.tar.gz (17.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

btsnoop_parser-0.3.0-py3-none-any.whl (15.3 kB view details)

Uploaded Python 3

File details

Details for the file btsnoop_parser-0.3.0.tar.gz.

File metadata

  • Download URL: btsnoop_parser-0.3.0.tar.gz
  • Upload date:
  • Size: 17.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for btsnoop_parser-0.3.0.tar.gz
Algorithm Hash digest
SHA256 8743bd85f9836401025490718160f1bb1f7c973229a0d12888eb8bba728a26bd
MD5 15377bee7e428dd60dfb5102de07d712
BLAKE2b-256 a435f077ad80ce4bcf31bcdc2a44c50c7d8c150cd6054b93bad7c95c4690ed1c

See more details on using hashes here.

File details

Details for the file btsnoop_parser-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: btsnoop_parser-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 15.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.0

File hashes

Hashes for btsnoop_parser-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7a6ddeed5ea289f6c9f2fb278de2dcbf892b785c38bd0de7512147c7d9003543
MD5 26e1472873e2d6080a8b5c02d436ca09
BLAKE2b-256 88a443e0b5d8edd16f01f182cc51db63d099779cf9b915c12aaf29a6231ba527

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page