Skip to main content
Provision an ESP32 onto a WiFi network over Bluetooth with Espressif’s BluFi protocol. This is the flow that a phone app performs during onboarding, and a test drives it.

Handle

BluFi is a box-level capability, not a net, and it shares the box’s single Bluetooth adapter with BLE.

Methods

Types

Method Reference

scan(timeout: f64) -> Result<Vec<BleDevice>>

Scan for BluFi-capable devices advertising nearby.

connect(device_name: &str) -> Result<BlufiDeviceInfo>

Connect by advertised BLE name, not address. Returns firmware version and WiFi state.

provision(device_name: &str, ssid: &str, password: &str) -> Result<BlufiProvisionResult>

Provision the target onto a network. Fails as Error::Box when the target does not reach the connected state.

wifi_scan(device_name: &str) -> Result<Vec<BlufiNetwork>>

Ask the target to scan for networks it can see. This is the target’s radio reporting, not the box’s — which is the point when testing antenna placement.

status(device_name: &str) -> Result<BlufiStatus> and version(device_name: &str) -> Result<Option<String>>

The target’s current WiFi state, and its BluFi firmware version.

Examples

Provision a fresh device and confirm it joined

Notes

  • sta_conn == 0 means connected. Zero is success here, not failure, and the values run 0 connected, 1 failed, 2 connecting, 3 connected but no IP. A target at 3 is associated but has no DHCP lease, which is a different bug from a wrong password.
  • Every action except scan connects over BLE and negotiates BluFi security first, so the budgets are wide. The box-side connect timeout is 20 seconds, and the client adds its own allowance on top of that:
    • Most actions add 40 seconds.
    • provision adds 60 seconds, because end-to-end provisioning routinely takes over 30 seconds.
    • wifi_scan adds 30 seconds, because the target runs its own scan.
  • BluFi shares the box’s one Bluetooth adapter with BLE, and the box serializes them.
  • Devices are addressed by advertised name, unlike BLE, which uses the address.