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

Uploaded Python 3

File details

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

File metadata

  • Download URL: btsnoop_parser-0.2.2.tar.gz
  • Upload date:
  • Size: 15.8 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.2.tar.gz
Algorithm Hash digest
SHA256 e49805827644250981a5f6de9d0fff3e60baf88936ce0a69227d359ed26e544d
MD5 da4f8ba6cbca0949eeb8a3edc6b2f235
BLAKE2b-256 21dcb182573223ae21eff1532108680587db6f229e08a78f60f97c024c4412db

See more details on using hashes here.

File details

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

File metadata

  • Download URL: btsnoop_parser-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 15.1 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 283f98355ebb16b7f6149ca9ce585eef0e77d6ad44d9bd3a3ab7cc173e83be4e
MD5 1ab0163e06725c381f17eddff0b2e8cd
BLAKE2b-256 030a71a9d8383ad00c3194b4cdbc201976f5a9a6dd0057e4c7397c7b7397c8e2

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