pub struct AdapterConfig { /* private fields */ }Expand description
Configuration for creating an interface to the default Bluetooth adapter of the system.
By deafult, ndk-context is used for
obtaining the JNI JavaVM pointer.
Implementations§
Source§impl AdapterConfig
impl AdapterConfig
Sourcepub unsafe fn new(java_vm: *mut JavaVM, bluetooth_manager: jobject) -> Self
pub unsafe fn new(java_vm: *mut JavaVM, bluetooth_manager: jobject) -> Self
Creates a config for the default Bluetooth adapter for the system.
You do not need to do this if you are using the android_activity crate for a native application.
§Safety
java_vmmust be a valid JNIJavaVMpointer to a VM that will stay alive for the current native library’s lifetime. This is true for any library used by an Android application.bluetooth_managermust be a valid global reference to anandroid.bluetooth.BluetoothManagerinstance, from thejava_vmVM.- The
Adaptertakes ownership of the global reference and will delete it with theDeleteGlobalRefJNI call when dropped. You must not do that yourself.
Sourcepub fn request_mtu_on_connect(self, enabled: bool) -> Self
pub fn request_mtu_on_connect(self, enabled: bool) -> Self
If enabled, this library will request the BLE ATT MTU to 517 bytes during Adapter::connect_device. See https://developer.android.com/about/versions/14/behavior-changes-all#mtu-set-to-517.
If disabled, crate::Characteristic::max_write_len may always return 18.
This is enabled by default; disable it if the firmware of the device to be connected is problematic.
Sourcepub fn allow_multiple_connections(self, enabled: bool) -> Self
pub fn allow_multiple_connections(self, enabled: bool) -> Self
If enabled, connections with devices already connected outside this library instance will
be permitted. Note that another android.bluetooth.BluetoothGatt object will not be created
if the device is already connected in the current library instance.
This is enabled by default; this should be okay on well-implemented Android API implementations, but disabling it might improve Android compatibility.