Skip to main content

Module bluetooth

Module bluetooth 

Source
Expand description

The Android BLE APIs, reached through JNI.

Shaped like the other backends’ sys layers: an Event enum, an EventSink to receive it, and a Central that owns the adapter. What differs is where the events come from — Android delivers them to callback objects, which is why crate::dex and crate::runtime exist.

§Threading

Callbacks arrive on binder threads the VM owns but Rust has never seen, so every entry point attaches, pushes a local frame, and pops it before returning. Without the frame, a scan that runs for a minute exhausts the 512-entry local reference table and aborts the process.

§Permissions

BLUETOOTH_SCAN and BLUETOOTH_CONNECT from API 31, and ACCESS_FINE_LOCATION for scanning on 23–30. A missing permission surfaces as a SecurityException from the framework — caught, cleared and reported rather than left pending.

Structs§

Ref
A retained Java object.

Enums§

Event
What Android tells us.
ManagerState
BluetoothAdapter.STATE_*, plus the cases that are not adapter states.

Traits§

EventSink
Where events go. Called on a binder thread, one at a time per callback.

Functions§

advertise_natives
The (name, signature, function) table for AdvertiseCallback.
bind_sink
Register a sink for a callback object.
gatt_natives
The (name, signature, function) table for GattCallback.
scan_natives
The (name, signature, function) table for ScanCallback.
server_natives
The (name, signature, function) table for BluetoothGattServerCallback.
unbind_sink