---
title: "bluetooth-data-tools | pypx"
description: "Tools for converting bluetooth data and packets"
canonical_url: "https://pypx.app/packages/bluetooth-data-tools"
meta:
  "og:description": "Tools for converting bluetooth data and packets"
  "og:image": "https://pypx.app/_og/d/h_630%2Cc_PackageCard%2Cname_bluetooth-data-tools%2Cversion_1.29.24%2Csummary_Tools%2Bfor%2Bconverting%2Bbluetooth%2Bdata%2Band%2Bpackets%2Clicense_Apache-2.0%2Cp_Ii9wYWNrYWdlcy9ibHVldG9vdGgtZGF0YS10b29scyI%2Cs_AOv807fsUI97PGVD.png"
  "og:image:height": "630"
  "og:image:type": image/png
  "og:image:width": "1200"
  "og:title": "bluetooth-data-tools 1.29.24"
  "twitter:image": "https://pypx.app/_og/d/h_630%2Cc_PackageCard%2Cname_bluetooth-data-tools%2Cversion_1.29.24%2Csummary_Tools%2Bfor%2Bconverting%2Bbluetooth%2Bdata%2Band%2Bpackets%2Clicense_Apache-2.0%2Cp_Ii9wYWNrYWdlcy9ibHVldG9vdGgtZGF0YS10b29scyI%2Cs_AOv807fsUI97PGVD.png"
---

> Index of every page on this site: [llms.txt](https://pypx.app/llms.txt)

# **bluetooth-data-tools**

v1.29.24

Tools for converting bluetooth data and packets

110 KB Python 3.10+ platform-specificApache-2.01 deps

[** Diff **](https://pypx.app/packages/bluetooth-data-tools/diff)

`$ uv add bluetooth-data-tools`

# Bluetooth Data Tools

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](https://allcontributors.org/docs/en/emoji-key)):

This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!

## Credits

This package was created with [Cookiecutter](https://github.com/audreyr/cookiecutter) and the [browniebroke/cookiecutter-pypackage](https://github.com/browniebroke/cookiecutter-pypackage) project template.

## **Details **

<dl>

<dt>Version</dt>
<dd>1.29.24</dd>

<dt>License</dt>
<dd>Apache-2.0</dd>

<dt>Python</dt>
<dd>&gt;=3.10</dd>

<dt>Maintainer</dt>
<dd>J. Nick Koston</dd></dl>

## **Links**

- [Bug Tracker](https://github.com/bdraco/bluetooth-data-tools/issues)
- [Changelog](https://github.com/bdraco/bluetooth-data-tools/blob/main/CHANGELOG.md)
- [Documentation](https://bluetooth-data-tools.readthedocs.io)
- [Repository](https://github.com/bdraco/bluetooth-data-tools)
- [View on PyPI](https://pypi.org/project/bluetooth-data-tools/)

## **Release Cadence **

**25**

releases in the past year

avg 19 days between releases

## **Platforms **

linuxarm64mac-x86mac-armwinmusl

## **Maintainers **

- J. Nick Koston · [nick@koston.org](mailto:nick@koston.org)

```json
{"@context":"https://schema.org","@graph":[{"@id":"https://pypx.app/#website","@type":"WebSite","description":"The Python Package Index, reimagined. Fast search, dependency insights, download trends, and changelogs — all in one place.","name":"pypx","url":"https://pypx.app/"},{"@id":"https://pypx.app/packages/bluetooth-data-tools#webpage","@type":"WebPage","description":"Tools for converting bluetooth data and packets","name":"bluetooth-data-tools","url":"https://pypx.app/packages/bluetooth-data-tools","isPartOf":{"@id":"https://pypx.app/#website"},"potentialAction":[{"@type":"ReadAction","target":["https://pypx.app/packages/bluetooth-data-tools"]}]},{"@id":"https://pypx.app/packages/bluetooth-data-tools#/schema/software-application/1","@type":"SoftwareApplication","applicationCategory":"DeveloperApplication","description":"Tools for converting bluetooth data and packets","license":"Apache-2.0","name":"bluetooth-data-tools","softwareVersion":"1.29.24"}]}
```

## Sitemap

See the full [sitemap](https://pypx.app/sitemap.md) for all pages.
