Skip to main content

Bluetooth Data Tools

CI Status Documentation Status Test coverage percentage CodSpeed Badge

Poetry black pre-commit

PyPI Version Supported Python versions License

Tools for converting bluetooth data and packets

Installation

Install this via pip (or your favourite package manager):

pip install bluetooth-data-tools

Usage

Parsing BLE GAP Advertisement Data

Parse raw BLE advertisement bytes into structured data:

from bluetooth_data_tools import parse_advertisement_data_bytes

# Parse raw GAP advertisement bytes
parsed = parse_advertisement_data_bytes(raw_bytes)
local_name = parsed[0]        # str | None
service_uuids = parsed[1]     # list[str]
service_data = parsed[2]      # dict[str, bytes]
manufacturer_data = parsed[3] # dict[int, bytes]
tx_power = parsed[4]          # int | None

Or use the object-oriented interface:

from bluetooth_data_tools import BLEGAPAdvertisement, parse_advertisement_data

adv = parse_advertisement_data([raw_bytes1, raw_bytes2])
print(adv.local_name)
print(adv.service_uuids)
print(adv.service_data)
print(adv.manufacturer_data)
print(adv.tx_power)

Bluetooth Address Utilities

from bluetooth_data_tools import (
    int_to_bluetooth_address,
    mac_to_int,
    short_address,
    human_readable_name,
)

# Convert integer to MAC address
int_to_bluetooth_address(0x123456789ABC)
# "12:34:56:78:9A:BC"

# Convert MAC address to integer
mac_to_int("FF:FF:FF:FF:FF:FF")
# 281474976710655

# Get short address (last 2 octets)
short_address("AA:BB:CC:DD:EE:FF")
# "EEFF"

# Format a human-readable device name
human_readable_name("My Sensor", "", "AA:BB:CC:DD:EE:FF")
# "My Sensor (EEFF)"

Distance Estimation

Estimate distance from TX power and RSSI:

from bluetooth_data_tools import calculate_distance_meters

distance = calculate_distance_meters(power=-59, rssi=-60)
# ~1.135 meters

Monotonic Time

A fast monotonic clock optimized for Bluetooth event timing. On Linux, uses CLOCK_MONOTONIC_COARSE via Cython for lower overhead:

from bluetooth_data_tools import monotonic_time_coarse

now = monotonic_time_coarse()

Private Address Resolution (RPA)

Resolve Bluetooth Low Energy random private addresses using an Identity Resolving Key:

from bluetooth_data_tools import get_cipher_for_irk, resolve_private_address

cipher = get_cipher_for_irk(irk_bytes)  # 16-byte Identity Resolving Key
is_match = resolve_private_address(cipher, "40:01:02:0A:C4:A6")

Contributors ✨

Thanks goes to these wonderful people (emoji key):

This project follows the all-contributors specification. Contributions of any kind welcome!

Credits

This package was created with Cookiecutter and the browniebroke/cookiecutter-pypackage project template.

Download files

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

Source Distribution

bluetooth_data_tools-1.29.20.tar.gz (20.9 kB view details)

Uploaded Source

Built Distribution

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

bluetooth_data_tools-1.29.20-cp314-cp314-manylinux_2_41_x86_64.whl (155.3 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.41+ x86-64

File details

Details for the file bluetooth_data_tools-1.29.20.tar.gz.

File metadata

  • Download URL: bluetooth_data_tools-1.29.20.tar.gz
  • Upload date:
  • Size: 20.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for bluetooth_data_tools-1.29.20.tar.gz
Algorithm Hash digest
SHA256 39df8bf00d05b09c10be150f758f0c1889d6e2b037cd70739e977d4c9d96acb2
MD5 09692d5ef3149218b8b2c71e50e173fe
BLAKE2b-256 8bdb22e6aabba7ef00c57c3fffde2135e94ac2205c951fa33267c6e68b16cb8e

See more details on using hashes here.

Provenance

The following attestation bundles were made for bluetooth_data_tools-1.29.20.tar.gz:

Publisher: ci.yml on Bluetooth-Devices/bluetooth-data-tools

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file bluetooth_data_tools-1.29.20-cp314-cp314-manylinux_2_41_x86_64.whl.

File metadata

File hashes

Hashes for bluetooth_data_tools-1.29.20-cp314-cp314-manylinux_2_41_x86_64.whl
Algorithm Hash digest
SHA256 15a8e11d205961a77f14d52a754fdeae5c926bb1382ddad2fa49cd92fbf778bb
MD5 17529e8e21ea4df37086649759ea57a8
BLAKE2b-256 addd0295e947d61a8eacf7bfa2606a8634ec8c924ef8bde87ecd890ba0862374

See more details on using hashes here.

Provenance

The following attestation bundles were made for bluetooth_data_tools-1.29.20-cp314-cp314-manylinux_2_41_x86_64.whl:

Publisher: ci.yml on Bluetooth-Devices/bluetooth-data-tools

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

1.29.21

2 files

This release

1.29.20 This release

2 files

1.29.19

2 files

1.29.18

2 files

1.29.17

2 files

1.29.16

2 files

1.29.15

2 files

1.29.14

2 files

1.29.13

2 files

1.29.12

2 files

1.29.11

2 files

1.29.10

2 files

1.29.9

2 files

1.29.8

2 files

1.29.7

2 files

1.29.6

62 files

1.29.5

62 files

1.29.4

2 files

1.29.3

2 files

1.29.2

2 files

1.29.1

2 files

1.29.0

2 files

1.28.4

62 files

1.28.3

62 files

1.28.2

50 files

1.28.1

50 files

1.28.0

50 files

1.27.0

50 files

1.26.5

50 files

1.26.4

50 files

1.26.3

50 files

1.26.2

50 files

1.26.1

50 files

1.26.0

50 files

1.25.1

50 files

1.25.0

50 files

1.24.1

50 files

1.24.0

2 files

1.23.4

43 files

1.23.3

43 files

1.23.0

43 files

1.22.0

43 files

1.21.0

2 files

1.20.0

34 files

1.19.4

27 files

1.19.3

27 files

1.19.2

2 files

1.19.1

2 files

1.19.0

27 files

1.18.0

27 files

1.17.0

27 files

1.16.0

27 files

1.15.0

27 files

1.14.0

27 files

1.13.0

27 files

1.12.0

16 files

1.11.0

16 files

1.10.0

16 files

1.9.1

16 files

1.9.0

16 files

1.8.0

16 files

1.7.0

16 files

1.6.1

16 files

1.6.0

16 files

1.5.0

16 files

1.4.0

16 files

1.3.0

16 files

1.2.0

16 files

1.1.0

16 files

1.0.0

16 files

0.4.0

16 files

0.3.1

2 files

0.3.0

2 files

0.2.0

2 files

0.1.2

2 files

0.0.1

2 files

Supported by

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