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.2.1.tar.gz (15.1 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.2.1-py3-none-any.whl (14.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: btsnoop_parser-0.2.1.tar.gz
  • Upload date:
  • Size: 15.1 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.2.1.tar.gz
Algorithm Hash digest
SHA256 955eac671557bede0697a56b48189220042d8ceaec67ed825a962cb45215e4ce
MD5 63efb0d9e8e64191d59058cb59957e4a
BLAKE2b-256 75747ece2392fc7bb189f737a90e76bf0d1c156dc982a96cf4b1cf39199f3149

See more details on using hashes here.

File details

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

File metadata

  • Download URL: btsnoop_parser-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 14.5 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.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7a8c8f2d847a6d4ea93d810a0dd2f66efb4b92628deab548f7b52f03f747e2c9
MD5 7ba9f322eb411d22e705e27839774d7a
BLAKE2b-256 05c7f0026c74d735623cbe53a73231bbe0ddc41608a8aff6b427cfe39b2237f3

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