Skip to content

Repository files navigation

iroh-ble-transport Crates.io iroh-ble-transport Docs.rs

iroh-ble-transport

🔥 Warning: 🔥 This library is experimental. A best effort will be made to resolve bugs and follow semantic versioning, but there are no guarantees. Do not rely on it until it has been sufficiently field-tested.

iroh-ble-transport is a Rust crate providing BLE (Bluetooth Low Energy) as a custom transport for the Iroh peer-to-peer networking stack. Devices act as both central (scanner/client) and peripheral (advertiser/server) simultaneously to discover and connect to each other over BLE.

Built on top of blew, a cross-platform BLE library for Rust.

High-level functionality

  • Each node advertises a GATT service whose UUID encodes its public key prefix
  • Peers discover each other from advertising packets without connecting
  • Connections start on GATT, then upgrade to L2CAP when available
  • If L2CAP setup fails or times out, the connection falls back to GATT

Supported Platforms

This library currently supports iOS, macOS, Android, and Linux.

Usage

BLE is a high-touch transport — it needs more wiring than the IP-based defaults (a dedup hook and an address lookup):

use iroh::endpoint::presets;
use iroh::{Endpoint, SecretKey};
use iroh_ble_transport::BleTransport;

async fn bind_ble_endpoint() -> anyhow::Result<Endpoint> {
    let secret_key = SecretKey::generate();
    let ble = BleTransport::builder().build(secret_key.public()).await?;

    let endpoint = Endpoint::builder(presets::N0DisableRelay)
        .hooks(ble.dedup_hook())
        .add_custom_transport(ble.as_custom_transport())
        .address_lookup(ble.address_lookup())
        .secret_key(secret_key)
        .clear_ip_transports()
        .bind()
        .await?;

    Ok(endpoint)
}

See:

Demo

There is a Tauri-based (unencrypted, insecure) chat demo called BlewChat that works on iOS, Android, macOS, and Linux. For iOS, the easiest way to install is to install the latest release via TestFlight.

For other platforms, either build from source or download the release artifacts when they're made available.

License

This project is licensed under the GNU Affero General Public License v3.0 or later.

Commercial licenses are available for use cases where the AGPL is not suitable. Contact me@jakebot.org for details.

About

A cross-platform BLE transport for Iroh.

Resources

Stars

26 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages