public abstract class BluetoothGattServerCallback extends Object
BluetoothGattServer
callbacks.Constructor and Description |
---|
BluetoothGattServerCallback() |
Modifier and Type | Method and Description |
---|---|
void |
onCharacteristicReadRequest(BluetoothDevice device,
int requestId,
int offset,
BluetoothGattCharacteristic characteristic)
A remote client has requested to read a local characteristic.
|
void |
onCharacteristicWriteRequest(BluetoothDevice device,
int requestId,
BluetoothGattCharacteristic characteristic,
boolean preparedWrite,
boolean responseNeeded,
int offset,
byte[] value)
A remote client has requested to write to a local characteristic.
|
void |
onConnectionStateChange(BluetoothDevice device,
int status,
int newState)
Callback indicating when a remote device has been connected or disconnected.
|
void |
onDescriptorReadRequest(BluetoothDevice device,
int requestId,
int offset,
BluetoothGattDescriptor descriptor)
A remote client has requested to read a local descriptor.
|
void |
onDescriptorWriteRequest(BluetoothDevice device,
int requestId,
BluetoothGattDescriptor descriptor,
boolean preparedWrite,
boolean responseNeeded,
int offset,
byte[] value)
A remote client has requested to write to a local descriptor.
|
void |
onExecuteWrite(BluetoothDevice device,
int requestId,
boolean execute)
Execute all pending write operations for this device.
|
void |
onMtuChanged(BluetoothDevice device,
int mtu)
Callback indicating the MTU for a given device connection has changed.
|
void |
onNotificationSent(BluetoothDevice device,
int status)
Callback invoked when a notification or indication has been sent to
a remote device.
|
void |
onServiceAdded(int status,
BluetoothGattService service)
Indicates whether a local service has been added successfully.
|
public void onConnectionStateChange(BluetoothDevice device, int status, int newState)
device
- Remote device that has been connected or disconnected.status
- Status of the connect or disconnect operation.newState
- Returns the new connection state. Can be one of
BluetoothProfile.STATE_DISCONNECTED
or
BluetoothProfile.STATE_CONNECTED
public void onServiceAdded(int status, BluetoothGattService service)
status
- Returns BluetoothGatt.GATT_SUCCESS
if the service
was added successfully.service
- The service that has been addedpublic void onCharacteristicReadRequest(BluetoothDevice device, int requestId, int offset, BluetoothGattCharacteristic characteristic)
An application must call BluetoothGattServer.sendResponse(android.bluetooth.BluetoothDevice, int, int, int, byte[])
to complete the request.
device
- The remote device that has requested the read operationrequestId
- The Id of the requestoffset
- Offset into the value of the characteristiccharacteristic
- Characteristic to be readpublic void onCharacteristicWriteRequest(BluetoothDevice device, int requestId, BluetoothGattCharacteristic characteristic, boolean preparedWrite, boolean responseNeeded, int offset, byte[] value)
An application must call BluetoothGattServer.sendResponse(android.bluetooth.BluetoothDevice, int, int, int, byte[])
to complete the request.
device
- The remote device that has requested the write operationrequestId
- The Id of the requestcharacteristic
- Characteristic to be written to.preparedWrite
- true, if this write operation should be queued for
later execution.responseNeeded
- true, if the remote device requires a responseoffset
- The offset given for the valuevalue
- The value the client wants to assign to the characteristicpublic void onDescriptorReadRequest(BluetoothDevice device, int requestId, int offset, BluetoothGattDescriptor descriptor)
An application must call BluetoothGattServer.sendResponse(android.bluetooth.BluetoothDevice, int, int, int, byte[])
to complete the request.
device
- The remote device that has requested the read operationrequestId
- The Id of the requestoffset
- Offset into the value of the characteristicdescriptor
- Descriptor to be readpublic void onDescriptorWriteRequest(BluetoothDevice device, int requestId, BluetoothGattDescriptor descriptor, boolean preparedWrite, boolean responseNeeded, int offset, byte[] value)
An application must call BluetoothGattServer.sendResponse(android.bluetooth.BluetoothDevice, int, int, int, byte[])
to complete the request.
device
- The remote device that has requested the write operationrequestId
- The Id of the requestdescriptor
- Descriptor to be written to.preparedWrite
- true, if this write operation should be queued for
later execution.responseNeeded
- true, if the remote device requires a responseoffset
- The offset given for the valuevalue
- The value the client wants to assign to the descriptorpublic void onExecuteWrite(BluetoothDevice device, int requestId, boolean execute)
An application must call BluetoothGattServer.sendResponse(android.bluetooth.BluetoothDevice, int, int, int, byte[])
to complete the request.
device
- The remote device that has requested the write operationsrequestId
- The Id of the requestexecute
- Whether the pending writes should be executed (true) or
cancelled (false)public void onNotificationSent(BluetoothDevice device, int status)
When multiple notifications are to be sent, an application must wait for this callback to be received before sending additional notifications.
device
- The remote device the notification has been sent tostatus
- BluetoothGatt.GATT_SUCCESS
if the operation was successfulpublic void onMtuChanged(BluetoothDevice device, int mtu)
This callback will be invoked if a remote client has requested to change the MTU for a given connection.
device
- The remote device that requested the MTU changemtu
- The new MTU size