Package-level declarations

Types

Link copied to clipboard
Link copied to clipboard
sealed class BleClientOperation

Abstract sealed class representing a type of BLE operation

Link copied to clipboard
sealed class BleServerOperation

Abstract sealed class representing a type of BLE operation

Link copied to clipboard
data class CharacteristicRead(val device: BluetoothDevice, val characteristicUuid: UUID) : BleClientOperation

Read the value of a characteristic represented by characteristicUuid

Link copied to clipboard
data class CharacteristicWrite(val device: BluetoothDevice, val characteristicUuid: UUID, val writeType: Int, val payload: ByteArray) : BleClientOperation

Write payload as the value of a characteristic represented by characteristicUuid

Link copied to clipboard
class CommandQueue<T>(handler: Handler, callbacks: CommandQueueCallback<T>, operationTimeout: Long) : ConcurrentLinkedQueue<T>
Link copied to clipboard
abstract class CommandQueueCallback<T>
Link copied to clipboard
data class Connect(val device: BluetoothDevice, val context: Context) : BleClientOperation

Connect to device and perform service discovery

Link copied to clipboard
data class ConnectL2CapSocket(val device: BluetoothDevice, val psm: Int) : BleClientOperation
Link copied to clipboard
data class DescriptorRead(val device: BluetoothDevice, val descriptorUuid: UUID) : BleClientOperation

Read the value of a descriptor represented by descriptorUuid

Link copied to clipboard
data class DescriptorWrite(val device: BluetoothDevice, val descriptorUuid: UUID, val payload: ByteArray) : BleClientOperation

Write payload as the value of a descriptor represented by descriptorUuid

Link copied to clipboard
data class DisableNotifications(val device: BluetoothDevice, val characteristicUuid: UUID) : BleClientOperation

Disable notifications/indications on a characteristic represented by characteristicUuid

Link copied to clipboard

Disconnect from device and release all connection resources

Link copied to clipboard

Disconnect from device and release all connection resources

Link copied to clipboard
class DittoBluetoothManager(val context: Context, dittoHandleWrapper: DittoHandle, val config: DittoBluetoothLeConfig)

Owns the BluetoothPlatform and references to the Rust-based BLE Client and Server transports. Previously these were long-lived instances but sometimes the Android BLE stack gums up and stops reporting events properly until the app is restarted. The nuclear solution of dropping and recreating the BluetoothPlatform resolves this situation. At the expense of background support, this manager class will track disabled/enabled events and fully stop or start the platform accordingly.

Link copied to clipboard
data class EnableNotifications(val device: BluetoothDevice, val characteristicUuid: UUID) : BleClientOperation

Enable notifications/indications on a characteristic represented by characteristicUuid

Link copied to clipboard
data class MtuRequest(val device: BluetoothDevice, val mtu: Int) : BleClientOperation

Request for an MTU of mtu

Link copied to clipboard
data class NotifyCharacteristicChanged(val device: BluetoothDevice, val characteristic: BluetoothGattCharacteristic, val confirm: Boolean, val data: ByteArray) : BleServerOperation
Link copied to clipboard
Link copied to clipboard
data class StartAdvertisingSet(val adSetParams: AdvertisingSetParameters, val advertisingData: AdvertiseData, val scanResponse: AdvertiseData) : BleServerOperation
Link copied to clipboard
data class StartLegacyAdvertising(val adSettings: AdvertiseSettings, val advertisingData: AdvertiseData, val scanResponse: AdvertiseData) : BleServerOperation

Properties

Link copied to clipboard
const val BLE_STATUS_ERR_UNKNOWN: Int = 2147483647

Added in API Level 31, equivalent to BluetoothStatusCodes.ERROR_UNKNOWN or Integer.MAX_VALUE.

Link copied to clipboard
const val BLE_STATUS_SUCCESS: Int = 0

Added in API Level 31, equivalent to BluetoothStatusCodes.SUCCESS.

Link copied to clipboard

UUID of the Client Characteristic Configuration Descriptor (CCCD, 0x2902). This is used to enable notifications or indications in BLE.

Link copied to clipboard

Characteristic for writing an announce string. This is used by the central to notify the peripheral that the connection is ready.

Link copied to clipboard

Characteristic for reading control data.

Link copied to clipboard

Characteristic for writing control data.

Link copied to clipboard

Characteristic for reading L2CAP PSM. This is needed by the central to connect to the L2CAP socket that the peripheral is listening on.

Link copied to clipboard

Characteristic for reading mesh data.

Link copied to clipboard

Characteristic for writing mesh data.

Link copied to clipboard

Functions

Link copied to clipboard
fun <K, V> ConcurrentHashMap<K, V>.computeIfPresentCompat(key: K & Any, computation: (K, V) -> V?)

Wraps ConcurrentHashMap.computeIfPresent in an SDK version agnostic API.

Link copied to clipboard

Check if a BluetoothGattDescriptor has a property bit flag.

Link copied to clipboard

Check if a BluetoothGattCharacteristic has a property bit flag.

Link copied to clipboard

Returns the first BluetoothGattCharacteristic with the given UUID, if any.

Link copied to clipboard

Returns the first BluetoothGattDescriptor with the given UUID, if any.

Link copied to clipboard

Convenience extension function that returns true if this BluetoothGattDescriptor is a Client Characteristic Configuration Descriptor.

Link copied to clipboard

Wraps ConcurrentLinkedQueue.removeIfCompat in an SDK version agnostic API.

Link copied to clipboard

Convert a MAC address String into a UUID byte array.

Link copied to clipboard

Convert a ByteArray representing a MAC address into a String.

Link copied to clipboard

Convert a ByteArray representing a UUID into a UUID.

Convenience function for converting a String into a UUID.

Link copied to clipboard

Wraps BluetoothGatt.writeCharacteristic in an SDK version agnostic API.

Link copied to clipboard

Wraps BluetoothGatt.writeDescriptor in an SDK version agnostic API.