Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
dioxus-blec
blec, the cross platform BLE (Bluetooth Low Energy) client, for
Dioxus 0.7.
use_ble()initializesbleconce for the app and mirrors its state into signals: ready, scanning, found devices, connected device. It has async methods for scanning, connecting, reading and writing.use_ble_notifications(characteristic, service)follows a characteristic for as long as the component lives, resubscribing after every reconnect.- On android the crate carries the bluetooth permissions and the Kotlin side of the BLE client as
a gradle module that
dxbuilds into the app, so there is no manifest to write and no gradle module to add.
The full blec API stays available through ble.handler() and the re-exported dioxus_blec::blec.
Usage
[]
= "0.16.0" # x-release-please-version
use *;
use ;
use ;
use ;
const CHARACTERISTIC: Uuid = uuid!;
Ble is Copy, like a signal. Reading one of its getters in a component subscribes the component
to that piece of state. The async methods spawn their forwarding tasks on the Dioxus runtime, so
call them from components and event handlers, not from a plain tokio task.
../../examples/dioxus-example is a complete app.
Android
The only android setting the app needs is the minimum sdk blec requires:
# Dioxus.toml
[]
= 26
Everything else is in this crate. #[manganis::ffi("android")] in src/lib.rs embeds the path of
the crate's android/ directory in the binary. dx picks it up when building for android, copies
the directory into the generated gradle project as a library module and builds it with the app. The
module's AndroidManifest.xml is merged into the app's; it declares the permissions with the
attributes [android.permissions] in Dioxus.toml cannot express (neverForLocation on
BLUETOOTH_SCAN, maxSdkVersion on the legacy BLUETOOTH) and the bluetooth_le feature. The
module's Kotlin is the android backend of blec, which finds it in the app's class loader at
startup. The directory is a symlink to crates/blec/android/lib, the one copy of that module; see
Android internals.
Runtime permissions are requested by the first scan, or explicitly with
ble.check_permissions(ask_if_denied).
Build for an attached phone with dx serve --platform android --device; without --device, dx
builds for the emulator (x86_64) even when none is running.
Without a bluetooth adapter
The mock feature (desktop only) replaces the platform backend with blec::mock, an in-process
simulation with no devices until the app adds some. See the mock section of the
blec README.
License
MIT or Apache-2.0, at your option.