BluetoothGattServerCallback
abstract class BluetoothGattServerCallback
kotlin.Any | |
↳ | android.bluetooth.BluetoothGattServerCallback |
This abstract class is used to implement BluetoothGattServer
callbacks.
Summary
Public constructors | |
---|---|
Public methods | |
---|---|
open Unit |
onCharacteristicReadRequest(device: BluetoothDevice!, requestId: Int, offset: Int, characteristic: BluetoothGattCharacteristic!) A remote client has requested to read a local characteristic. |
open Unit |
onCharacteristicWriteRequest(device: BluetoothDevice!, requestId: Int, characteristic: BluetoothGattCharacteristic!, preparedWrite: Boolean, responseNeeded: Boolean, offset: Int, value: ByteArray!) A remote client has requested to write to a local characteristic. |
open Unit |
onConnectionStateChange(device: BluetoothDevice!, status: Int, newState: Int) Callback indicating when a remote device has been connected or disconnected. |
open Unit |
onDescriptorReadRequest(device: BluetoothDevice!, requestId: Int, offset: Int, descriptor: BluetoothGattDescriptor!) A remote client has requested to read a local descriptor. |
open Unit |
onDescriptorWriteRequest(device: BluetoothDevice!, requestId: Int, descriptor: BluetoothGattDescriptor!, preparedWrite: Boolean, responseNeeded: Boolean, offset: Int, value: ByteArray!) A remote client has requested to write to a local descriptor. |
open Unit |
onExecuteWrite(device: BluetoothDevice!, requestId: Int, execute: Boolean) Execute all pending write operations for this device. |
open Unit |
onMtuChanged(device: BluetoothDevice!, mtu: Int) Callback indicating the MTU for a given device connection has changed. |
open Unit |
onNotificationSent(device: BluetoothDevice!, status: Int) Callback invoked when a notification or indication has been sent to a remote device. |
open Unit |
onPhyRead(device: BluetoothDevice!, txPhy: Int, rxPhy: Int, status: Int) Callback triggered as result of |
open Unit |
onPhyUpdate(device: BluetoothDevice!, txPhy: Int, rxPhy: Int, status: Int) Callback triggered as result of |
open Unit |
onServiceAdded(status: Int, service: BluetoothGattService!) Indicates whether a local service has been added successfully. |
Public constructors
Public methods
onCharacteristicReadRequest
open fun onCharacteristicReadRequest(
device: BluetoothDevice!,
requestId: Int,
offset: Int,
characteristic: BluetoothGattCharacteristic!
): Unit
A remote client has requested to read a local characteristic.
An application must call BluetoothGattServer.sendResponse
to complete the request.
Parameters | |
---|---|
device |
BluetoothDevice!: The remote device that has requested the read operation |
requestId |
Int: The Id of the request |
offset |
Int: Offset into the value of the characteristic |
characteristic |
BluetoothGattCharacteristic!: Characteristic to be read |
onCharacteristicWriteRequest
open fun onCharacteristicWriteRequest(
device: BluetoothDevice!,
requestId: Int,
characteristic: BluetoothGattCharacteristic!,
preparedWrite: Boolean,
responseNeeded: Boolean,
offset: Int,
value: ByteArray!
): Unit
A remote client has requested to write to a local characteristic.
An application must call BluetoothGattServer.sendResponse
to complete the request.
Parameters | |
---|---|
device |
BluetoothDevice!: The remote device that has requested the write operation |
requestId |
Int: The Id of the request |
characteristic |
BluetoothGattCharacteristic!: Characteristic to be written to. |
preparedWrite |
Boolean: true, if this write operation should be queued for later execution. |
responseNeeded |
Boolean: true, if the remote device requires a response |
offset |
Int: The offset given for the value |
value |
ByteArray!: The value the client wants to assign to the characteristic |
onConnectionStateChange
open fun onConnectionStateChange(
device: BluetoothDevice!,
status: Int,
newState: Int
): Unit
Callback indicating when a remote device has been connected or disconnected.
Parameters | |
---|---|
device |
BluetoothDevice!: Remote device that has been connected or disconnected. |
status |
Int: Status of the connect or disconnect operation. |
newState |
Int: Returns the new connection state. Can be one of android.bluetooth.BluetoothProfile#STATE_DISCONNECTED or BluetoothProfile.STATE_CONNECTED |
onDescriptorReadRequest
open fun onDescriptorReadRequest(
device: BluetoothDevice!,
requestId: Int,
offset: Int,
descriptor: BluetoothGattDescriptor!
): Unit
A remote client has requested to read a local descriptor.
An application must call BluetoothGattServer.sendResponse
to complete the request.
Parameters | |
---|---|
device |
BluetoothDevice!: The remote device that has requested the read operation |
requestId |
Int: The Id of the request |
offset |
Int: Offset into the value of the characteristic |
descriptor |
BluetoothGattDescriptor!: Descriptor to be read |
onDescriptorWriteRequest
open fun onDescriptorWriteRequest(
device: BluetoothDevice!,
requestId: Int,
descriptor: BluetoothGattDescriptor!,
preparedWrite: Boolean,
responseNeeded: Boolean,
offset: Int,
value: ByteArray!
): Unit
A remote client has requested to write to a local descriptor.
An application must call BluetoothGattServer.sendResponse
to complete the request.
Parameters | |
---|---|
device |
BluetoothDevice!: The remote device that has requested the write operation |
requestId |
Int: The Id of the request |
descriptor |
BluetoothGattDescriptor!: Descriptor to be written to. |
preparedWrite |
Boolean: true, if this write operation should be queued for later execution. |
responseNeeded |
Boolean: true, if the remote device requires a response |
offset |
Int: The offset given for the value |
value |
ByteArray!: The value the client wants to assign to the descriptor |
onExecuteWrite
open fun onExecuteWrite(
device: BluetoothDevice!,
requestId: Int,
execute: Boolean
): Unit
Execute all pending write operations for this device.
An application must call BluetoothGattServer.sendResponse
to complete the request.
Parameters | |
---|---|
device |
BluetoothDevice!: The remote device that has requested the write operations |
requestId |
Int: The Id of the request |
execute |
Boolean: Whether the pending writes should be executed (true) or cancelled (false) |
onMtuChanged
open fun onMtuChanged(
device: BluetoothDevice!,
mtu: Int
): Unit
Callback indicating the MTU for a given device connection has changed.
This callback will be invoked if a remote client has requested to change the MTU for a given connection.
Parameters | |
---|---|
device |
BluetoothDevice!: The remote device that requested the MTU change |
mtu |
Int: The new MTU size |
onNotificationSent
open fun onNotificationSent(
device: BluetoothDevice!,
status: Int
): Unit
Callback invoked when a notification or indication has been sent to a remote device.
When multiple notifications are to be sent, an application must wait for this callback to be received before sending additional notifications.
Parameters | |
---|---|
device |
BluetoothDevice!: The remote device the notification has been sent to |
status |
Int: BluetoothGatt.GATT_SUCCESS if the operation was successful |
onPhyRead
open fun onPhyRead(
device: BluetoothDevice!,
txPhy: Int,
rxPhy: Int,
status: Int
): Unit
Callback triggered as result of BluetoothGattServer.readPhy
Parameters | |
---|---|
device |
BluetoothDevice!: The remote device that requested the PHY read |
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(
device: BluetoothDevice!,
txPhy: Int,
rxPhy: Int,
status: Int
): Unit
Callback triggered as result of BluetoothGattServer.setPreferredPhy
, or as a result of remote device changing the PHY.
Parameters | |
---|---|
device |
BluetoothDevice!: The remote device |
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. |
onServiceAdded
open fun onServiceAdded(
status: Int,
service: BluetoothGattService!
): Unit
Indicates whether a local service has been added successfully.
Parameters | |
---|---|
status |
Int: Returns BluetoothGatt.GATT_SUCCESS if the service was added successfully. |
service |
BluetoothGattService!: The service that has been added |