Skip to main content

AdapterConfig

Struct AdapterConfig 

Source
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

Source

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_vm must be a valid JNI JavaVM pointer 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_manager must be a valid global reference to an android.bluetooth.BluetoothManager instance, from the java_vm VM.
  • The Adapter takes ownership of the global reference and will delete it with the DeleteGlobalRef JNI call when dropped. You must not do that yourself.
Source

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.

Source

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.

Trait Implementations§

Source§

impl Default for AdapterConfig

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.