Skip to Content
HardwareTransportFlutter (Native)

Flutter: Connect via Bluetooth (Native)

This guide builds on the Low-Level Transport Plugin for the BLE I/O interface and Protocol V1/V2 boundaries—read that first.

For Flutter apps that load a JS bundle via WebView or a JS engine and bridge to @onekeyfe/hd-common-connect-sdk using a low-level adapter.

Step 1. Choose a runtime

  • WebView: stable and broadly supported; bridge API identical to iOS/Android native shells
  • JS engine: e.g. flutter_js, run the built JS bundle directly in Dart

Step 2. Build the JS bundle

Build in the native examples under the hardware-js-sdk repository (see web/ directories) and produce web_dist/ assets.

Step 3. Load the JS bundle

Load the web_dist/ assets in Flutter (either via WebView or a JS engine).

Step 4. Implement the messaging bridge

Expose enumerate/connect/disconnect/send/receive from native to JS, keeping the same signatures. Forward unmodified BLE notification chunks as hex to a per-connection queue consumed by receive(uuid). The SDK handles V1/V2 framing and reassembly.

Step 5. Handle UI events

Show native dialogs for input requests and instructions for on-device prompts. Only input requests receive HardwareSDK.uiResponse; preserve their response correlation. Button confirmations and device-only PIN prompts are notifications. See UI wiring.

BLE UUIDs

  • serviceUuid = 00000001-0000-1000-8000-00805f9b34fb
  • writeCharacteristic = 00000002-0000-1000-8000-00805f9b34fb
  • notifyCharacteristic = 00000003-0000-1000-8000-00805f9b34fb

References

Once wired, the chain API usage is identical to WebUSB: provide connectId and (when required) deviceId.

Last updated on