pyblufi
Python implementation of Espressif's BluFi protocol for ESP32 WiFi provisioning over Bluetooth Low Energy (BLE).
Features
- Full BluFi protocol implementation
- WiFi provisioning via BLE using bleak
- WiFi scanning from ESP32 device
- WiFi status reporting (connection, SSID, BSSID)
- Custom data transmission
- Async/await API
- Command-line tool for quick provisioning
- No encryption support (plaintext mode)
Installation
pip install .
Or from PyPI (once published):
pip install pyblufi
Requirements
- Python >= 3.8
- bleak >= 0.20.0
Quick Start
Command Line
# Scan for BluFi devices
blufi-provision scan
# Provision a device with WiFi credentials
blufi-provision provision --ssid "MyWiFi" --password "secret123" --device "BLUFI_DEVICE"
Python API
import asyncio
from pyblufi import BlufiClient
async def main():
client = BlufiClient(debug=True)
# Scan and find device
device = await client.scan_for_device("BLUFI_DEVICE", timeout=10)
# Connect
await client.connect(device.address)
# Set STA mode
await client.set_sta_mode()
# Send SSID and password
await client.set_ssid("MyWiFi")
await client.set_password("secret123")
# Trigger connection
await client.connect_to_ap()
# Wait for WiFi status via notifications
status = await client.wait_for_wifi_status(timeout=30)
print(f"Connected: {status}")
await client.disconnect()
asyncio.run(main())
Protocol
BluFi frame format:
[TypeSubtype][FrameControl][Sequence][Length][Data...]
- TypeSubtype: Combined byte (type in lower 2 bits, subtype in upper 6 bits)
- FrameControl: Control flags (encryption, checksum, fragmentation)
- Sequence: Auto-incrementing sequence number (wraps at 256)
- Length: Payload length (max 255)
- Data: Variable-length payload
Frame Types
| Type | Value | Description |
|---|---|---|
| CTRL | 0x00 | Control frame |
| DATA | 0x01 | Data frame |
Control Subtypes
| Subtype | Command |
|---|---|
| 0x00 | ACK |
| 0x02 | SET_WIFI_OPMODE |
| 0x03 | CONN_TO_AP |
| 0x05 | GET_WIFI_STATUS |
| 0x09 | GET_WIFI_LIST |
Data Subtypes
| Subtype | Command |
|---|---|
| 0x00 | NEG (negotiation) |
| 0x02 | STA_SSID |
| 0x03 | STA_PASSWD |
| 0x0F | WIFI_REP (WiFi status report) |
| 0x11 | WIFI_LIST (WiFi scan results) |
Testing
pytest tests/ -v
License
MIT
Metadata
Release files for pyblufi 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pyblufi-0.1.0.tar.gz | 17.0 kB | Without provenance | Details for pyblufi-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pyblufi-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for pyblufi-0.1.0-py3-none-any.whl |
Total release size: 31.3 kB
Release files / pyblufi-0.1.0.tar.gz
| Download URL | pyblufi-0.1.0.tar.gz |
|---|---|
| Size | 17.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
00bf3c0ce6697b634f01708f4d95324d2088372d9812fe418b21ebf85d02ee38
|
|
BLAKE2b-256 checksum How to use checksums |
4037a69556703e0b6d2f779acec1f388602abbc01f7970594f5ea26c6c3e7b22
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.2
|
Release files / pyblufi-0.1.0-py3-none-any.whl
| Download URL | pyblufi-0.1.0-py3-none-any.whl |
|---|---|
| Size | 14.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
71800551a3bd58f66a2019c947ba6f7be5315229a3828d3f60e8a3d0737db673
|
|
BLAKE2b-256 checksum How to use checksums |
c24747bc9e629ff9dec5b9823d9d228a95d3bd006828d5087a4c7eef7896d7de
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.2
|
Security for pyblufi 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.