Python BluFi client for ESP32 WiFi provisioning via BLE
Project description
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pyblufi-0.1.0.tar.gz
(17.0 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
pyblufi-0.1.0-py3-none-any.whl
(14.3 kB
view details)
File details
Details for the file pyblufi-0.1.0.tar.gz.
File metadata
- Download URL: pyblufi-0.1.0.tar.gz
- Upload date:
- Size: 17.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
00bf3c0ce6697b634f01708f4d95324d2088372d9812fe418b21ebf85d02ee38
|
|
| MD5 |
37b57598c70b6f27448d65eedab90a08
|
|
| BLAKE2b-256 |
4037a69556703e0b6d2f779acec1f388602abbc01f7970594f5ea26c6c3e7b22
|
File details
Details for the file pyblufi-0.1.0-py3-none-any.whl.
File metadata
- Download URL: pyblufi-0.1.0-py3-none-any.whl
- Upload date:
- Size: 14.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
71800551a3bd58f66a2019c947ba6f7be5315229a3828d3f60e8a3d0737db673
|
|
| MD5 |
f5aba433e516156dfa8c9c7201f607bd
|
|
| BLAKE2b-256 |
c24747bc9e629ff9dec5b9823d9d228a95d3bd006828d5087a4c7eef7896d7de
|