Skip to content

Latest commit

 

History

History

dioxus-example

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

README.md

blec in a Dioxus app

The same scan / connect / write / read / subscribe flow as ../plugin-blec-example, but without tauri: this app uses the dioxus-blec hooks on top of the blec crate.

src/main.rs holds the BLE calls, src/components.rs the UI. Found devices are cards that unfold on a click to show what the advertisement carried (services, manufacturer and service data, signal strength).

Run ../test-server on another machine to have something to talk to.

Desktop

dx serve

Android

dx serve --platform android --device

--device makes dx build for the phone attached over adb. Without it dx builds for the emulator (x86_64) even when no emulator is running, and the install fails on an arm64 phone with INSTALL_FAILED_NO_MATCHING_ABIS.

There is nothing to set up for bluetooth. Dioxus.toml only declares min_sdk = 26; the permissions and the Kotlin side of the BLE client come with dioxus-blec as a gradle module that dx builds into the app. See the android section of the dioxus-blec README.

"Check permissions" asks the user for the bluetooth permissions; on a fresh install the system dialog also appears by itself on the first scan. If the user denied them before, android will not show the dialog again and the button sends them to the app settings instead.

Without a bluetooth adapter

dx serve --features mock

replaces the platform backend with blec::mock, which has no devices until the app adds some — see the mock section of the blec README.