BluetoothGattCallback
abstract class BluetoothGattCallback
kotlin.Any | |
↳ | android.bluetooth.BluetoothGattCallback |
This abstract class is used to implement BluetoothGatt
callbacks.
Summary
Public constructors | |
---|---|
Public methods | |
---|---|
open Unit |
onCharacteristicChanged(gatt: BluetoothGatt!, characteristic: BluetoothGattCharacteristic!) Callback triggered as a result of a remote characteristic notification. |
open Unit |
onCharacteristicChanged(gatt: BluetoothGatt, characteristic: BluetoothGattCharacteristic, value: ByteArray) Callback triggered as a result of a remote characteristic notification. |
open Unit |
onCharacteristicRead(gatt: BluetoothGatt!, characteristic: BluetoothGattCharacteristic!, status: Int) Callback reporting the result of a characteristic read operation. |
open Unit |
onCharacteristicRead(gatt: BluetoothGatt, characteristic: BluetoothGattCharacteristic, value: ByteArray, status: Int) Callback reporting the result of a characteristic read operation. |
open Unit |
onCharacteristicWrite(gatt: BluetoothGatt!, characteristic: BluetoothGattCharacteristic!, status: Int) Callback indicating the result of a characteristic write operation. |
open Unit |
onConnectionStateChange(gatt: BluetoothGatt!, status: Int, newState: Int) Callback indicating when GATT client has connected/disconnected to/from a remote GATT server. |
open Unit |
onDescriptorRead(gatt: BluetoothGatt!, descriptor: BluetoothGattDescriptor!, status: Int) Callback reporting the result of a descriptor read operation. |
open Unit |
onDescriptorRead(gatt: BluetoothGatt, descriptor: BluetoothGattDescriptor, status: Int, value: ByteArray) Callback reporting the result of a descriptor read operation. |
open Unit |
onDescriptorWrite(gatt: BluetoothGatt!, descriptor: BluetoothGattDescriptor!, status: Int) Callback indicating the result of a descriptor write operation. |
open Unit |
onMtuChanged(gatt: BluetoothGatt!, mtu: Int, status: Int) Callback indicating the MTU for a given device connection has changed. |
open Unit |
onPhyRead(gatt: BluetoothGatt!, txPhy: Int, rxPhy: Int, status: Int) Callback triggered as result of |
open Unit |
onPhyUpdate(gatt: BluetoothGatt!, txPhy: Int, rxPhy: Int, status: Int) Callback triggered as result of |
open Unit |
onReadRemoteRssi(gatt: BluetoothGatt!, rssi: Int, status: Int) Callback reporting the RSSI for a remote device connection. |
open Unit |
onReliableWriteCompleted(gatt: BluetoothGatt!, status: Int) Callback invoked when a reliable write transaction has been completed. |
open Unit |
onServiceChanged(gatt: BluetoothGatt) Callback indicating service changed event is received |
open Unit |
onServicesDiscovered(gatt: BluetoothGatt!, status: Int) Callback invoked when the list of remote services, characteristics and descriptors for the remote device have been updated, ie new services have been discovered. |
Public constructors
Public methods
onCharacteristicChanged
open funonCharacteristicChanged(
gatt: BluetoothGatt!,
characteristic: BluetoothGattCharacteristic!
): Unit
Deprecated: Use BluetoothGattCallback#onCharacteristicChanged(BluetoothGatt,
as it is memory safe by providing the characteristic value at the time of notification.
Callback triggered as a result of a remote characteristic notification.
Parameters | |
---|---|
gatt |
BluetoothGatt!: GATT client the characteristic is associated with |
characteristic |
BluetoothGattCharacteristic!: Characteristic that has been updated as a result of a remote notification event. |
onCharacteristicChanged
open fun onCharacteristicChanged(
gatt: BluetoothGatt,
characteristic: BluetoothGattCharacteristic,
value: ByteArray
): Unit
Callback triggered as a result of a remote characteristic notification. Note that the value within the characteristic object may have changed since receiving the remote characteristic notification, so check the parameter value for the value at the time of notification.
Parameters | |
---|---|
gatt |
BluetoothGatt: GATT client the characteristic is associated with This value cannot be null . |
characteristic |
BluetoothGattCharacteristic: Characteristic that has been updated as a result of a remote notification event. This value cannot be null . |
value |
ByteArray: notified characteristic value This value cannot be null . |
onCharacteristicRead
open funonCharacteristicRead(
gatt: BluetoothGatt!,
characteristic: BluetoothGattCharacteristic!,
status: Int
): Unit
Deprecated: Use BluetoothGattCallback#onCharacteristicRead(BluetoothGatt,
as it is memory safe
Callback reporting the result of a characteristic read operation.
Parameters | |
---|---|
gatt |
BluetoothGatt!: GATT client invoked android.bluetooth.BluetoothGatt#readCharacteristic(android.bluetooth.BluetoothGattCharacteristic) |
characteristic |
BluetoothGattCharacteristic!: Characteristic that was read from the associated remote device. |
status |
Int: BluetoothGatt#GATT_SUCCESS if the read operation was completed successfully. |
onCharacteristicRead
open fun onCharacteristicRead(
gatt: BluetoothGatt,
characteristic: BluetoothGattCharacteristic,
value: ByteArray,
status: Int
): Unit
Callback reporting the result of a characteristic read operation.
Parameters | |
---|---|
gatt |
BluetoothGatt: GATT client invoked android.bluetooth.BluetoothGatt#readCharacteristic(android.bluetooth.BluetoothGattCharacteristic) This value cannot be null . |
characteristic |
BluetoothGattCharacteristic: Characteristic that was read from the associated remote device. This value cannot be null . |
value |
ByteArray: the value of the characteristic This value cannot be null . |
status |
Int: BluetoothGatt#GATT_SUCCESS if the read operation was completed successfully. |
onCharacteristicWrite
open fun onCharacteristicWrite(
gatt: BluetoothGatt!,
characteristic: BluetoothGattCharacteristic!,
status: Int
): Unit
Callback indicating the result of a characteristic write operation.
If this callback is invoked while a reliable write transaction is in progress, the value of the characteristic represents the value reported by the remote device. An application should compare this value to the desired value to be written. If the values don't match, the application must abort the reliable write transaction.
Parameters | |
---|---|
gatt |
BluetoothGatt!: GATT client that invoked android.bluetooth.BluetoothGatt#writeCharacteristic(android.bluetooth.BluetoothGattCharacteristic,byte[],int) |
characteristic |
BluetoothGattCharacteristic!: Characteristic that was written to the associated remote device. |
status |
Int: The result of the write operation BluetoothGatt#GATT_SUCCESS if the operation succeeds. |
onConnectionStateChange
open fun onConnectionStateChange(
gatt: BluetoothGatt!,
status: Int,
newState: Int
): Unit
Callback indicating when GATT client has connected/disconnected to/from a remote GATT server.
Parameters | |
---|---|
gatt |
BluetoothGatt!: GATT client |
status |
Int: Status of the connect or disconnect operation. android.bluetooth.BluetoothGatt#GATT_SUCCESS if the operation succeeds. |
newState |
Int: Returns the new connection state. Can be one of android.bluetooth.BluetoothProfile#STATE_DISCONNECTED or BluetoothProfile#STATE_CONNECTED |
onDescriptorRead
open funonDescriptorRead(
gatt: BluetoothGatt!,
descriptor: BluetoothGattDescriptor!,
status: Int
): Unit
Deprecated: Use BluetoothGattCallback#onDescriptorRead(BluetoothGatt,
as it is memory safe by providing the descriptor value at the time it was read.
Callback reporting the result of a descriptor read operation.
Parameters | |
---|---|
gatt |
BluetoothGatt!: GATT client invoked BluetoothGatt#readDescriptor |
descriptor |
BluetoothGattDescriptor!: Descriptor that was read from the associated remote device. |
status |
Int: BluetoothGatt#GATT_SUCCESS if the read operation was completed successfully |
onDescriptorRead
open fun onDescriptorRead(
gatt: BluetoothGatt,
descriptor: BluetoothGattDescriptor,
status: Int,
value: ByteArray
): Unit
Callback reporting the result of a descriptor read operation.
Parameters | |
---|---|
gatt |
BluetoothGatt: GATT client invoked BluetoothGatt#readDescriptor This value cannot be null . |
descriptor |
BluetoothGattDescriptor: Descriptor that was read from the associated remote device. This value cannot be null . |
status |
Int: BluetoothGatt#GATT_SUCCESS if the read operation was completed successfully |
value |
ByteArray: the descriptor value at the time of the read operation This value cannot be null . |
onDescriptorWrite
open fun onDescriptorWrite(
gatt: BluetoothGatt!,
descriptor: BluetoothGattDescriptor!,
status: Int
): Unit
Callback indicating the result of a descriptor write operation.
Parameters | |
---|---|
gatt |
BluetoothGatt!: GATT client invoked android.bluetooth.BluetoothGatt#writeDescriptor |
descriptor |
BluetoothGattDescriptor!: Descriptor that was written to the associated remote device. |
status |
Int: The result of the write operation BluetoothGatt#GATT_SUCCESS if the operation succeeds. |
onMtuChanged
open fun onMtuChanged(
gatt: BluetoothGatt!,
mtu: Int,
status: Int
): Unit
Callback indicating the MTU for a given device connection has changed.
This callback is triggered in response to the BluetoothGatt#requestMtu
function, or in response to a connection event.
Parameters | |
---|---|
gatt |
BluetoothGatt!: GATT client invoked BluetoothGatt#requestMtu |
mtu |
Int: The new MTU size |
status |
Int: BluetoothGatt#GATT_SUCCESS if the MTU has been changed successfully |
onPhyRead
open fun onPhyRead(
gatt: BluetoothGatt!,
txPhy: Int,
rxPhy: Int,
status: Int
): Unit
Callback triggered as result of BluetoothGatt#readPhy
Parameters | |
---|---|
gatt |
BluetoothGatt!: GATT client |
txPhy |
Int: the transmitter PHY in use. One of BluetoothDevice#PHY_LE_1M , android.bluetooth.BluetoothDevice#PHY_LE_2M , and BluetoothDevice#PHY_LE_CODED . |
rxPhy |
Int: the receiver PHY in use. One of BluetoothDevice#PHY_LE_1M , android.bluetooth.BluetoothDevice#PHY_LE_2M , and BluetoothDevice#PHY_LE_CODED . |
status |
Int: Status of the PHY read operation. BluetoothGatt#GATT_SUCCESS if the operation succeeds. |
onPhyUpdate
open fun onPhyUpdate(
gatt: BluetoothGatt!,
txPhy: Int,
rxPhy: Int,
status: Int
): Unit
Callback triggered as result of BluetoothGatt#setPreferredPhy
, or as a result of remote device changing the PHY.
Parameters | |
---|---|
gatt |
BluetoothGatt!: GATT client |
txPhy |
Int: the transmitter PHY in use. One of BluetoothDevice#PHY_LE_1M , android.bluetooth.BluetoothDevice#PHY_LE_2M , and BluetoothDevice#PHY_LE_CODED . |
rxPhy |
Int: the receiver PHY in use. One of BluetoothDevice#PHY_LE_1M , android.bluetooth.BluetoothDevice#PHY_LE_2M , and BluetoothDevice#PHY_LE_CODED . |
status |
Int: Status of the PHY update operation. BluetoothGatt#GATT_SUCCESS if the operation succeeds. |
onReadRemoteRssi
open fun onReadRemoteRssi(
gatt: BluetoothGatt!,
rssi: Int,
status: Int
): Unit
Callback reporting the RSSI for a remote device connection.
This callback is triggered in response to the BluetoothGatt#readRemoteRssi
function.
Parameters | |
---|---|
gatt |
BluetoothGatt!: GATT client invoked BluetoothGatt#readRemoteRssi |
rssi |
Int: The RSSI value for the remote device |
status |
Int: BluetoothGatt#GATT_SUCCESS if the RSSI was read successfully |
onReliableWriteCompleted
open fun onReliableWriteCompleted(
gatt: BluetoothGatt!,
status: Int
): Unit
Callback invoked when a reliable write transaction has been completed.
Parameters | |
---|---|
gatt |
BluetoothGatt!: GATT client invoked BluetoothGatt#executeReliableWrite |
status |
Int: BluetoothGatt#GATT_SUCCESS if the reliable write transaction was executed successfully |
onServiceChanged
open fun onServiceChanged(gatt: BluetoothGatt): Unit
Callback indicating service changed event is received
Receiving this event means that the GATT database is out of sync with the remote device. BluetoothGatt#discoverServices
should be called to re-discover the services.
Parameters | |
---|---|
gatt |
BluetoothGatt: GATT client involved This value cannot be null . |
onServicesDiscovered
open fun onServicesDiscovered(
gatt: BluetoothGatt!,
status: Int
): Unit
Callback invoked when the list of remote services, characteristics and descriptors for the remote device have been updated, ie new services have been discovered.
Parameters | |
---|---|
gatt |
BluetoothGatt!: GATT client invoked BluetoothGatt#discoverServices |
status |
Int: BluetoothGatt#GATT_SUCCESS if the remote device has been explored successfully. |