Package org.robolectric.shadows
Class ShadowBluetoothGattServer
java.lang.Object
org.robolectric.shadows.ShadowBluetoothGattServer
@Implements(value=android.bluetooth.BluetoothGattServer.class,
minSdk=26)
public class ShadowBluetoothGattServer
extends Object
Shadow of
BluetoothGattServer
.-
Field Summary
Modifier and TypeFieldDescriptionprotected org.robolectric.shadows.ShadowBluetoothGattServer.BluetoothGattServerReflector
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
addService
(BluetoothGattService service) Add a service to the GATT server.protected void
cancelConnection
(BluetoothDevice device) Disconnects an established connection, or cancels a connection attempt currently in progress.void
Clear the list of responses.protected void
Remove all services from the list of provided services.void
Clear the list of written bytes.protected void
close()
Close this GATT server instance.org.robolectric.shadows.BluetoothConnectionManager
List<byte[]>
Get a copy of the list of responses that have been sent.protected BluetoothGattService
getService
(UUID uuid) Returns aBluetoothGattService
from the list of services offered by this device.protected List<BluetoothGattService>
Returns a list of GATT services offered by this device.List<byte[]>
Get a copy of the list of bytes that have been received.boolean
isClosed()
Get whether server has been closed.boolean
isConnectedToDevice
(BluetoothDevice device) Returns true if the connection status of remote device is connectedboolean
isConnectionCancelled
(BluetoothDevice device) Get whether the device's connection has been cancelled.void
notifyConnection
(BluetoothDevice device) Simulate a successful Gatt Server Connection withBluetoothConnectionManager
.void
notifyDisconnection
(BluetoothDevice device) Simulate a successful Gatt Server Disconnection withBluetoothConnectionManager
.boolean
notifyOnCharacteristicWriteRequest
(BluetoothDevice device, int requestId, BluetoothGattCharacteristic characteristic, Boolean preparedWrite, Boolean responseNeeded, int offset, byte[] value) Simulate a Gatt characteristic write request to the Gatt Server by triggering the server callback.protected boolean
removeService
(BluetoothGattService service) Remove a service from the GATT server.protected boolean
sendResponse
(BluetoothDevice device, int requestId, int status, int offset, byte[] value) Send a response to a read or write request to a remote device.void
-
Field Details
-
bluetoothGattServerReflector
@ReflectorObject protected org.robolectric.shadows.ShadowBluetoothGattServer.BluetoothGattServerReflector bluetoothGattServerReflector
-
-
Constructor Details
-
ShadowBluetoothGattServer
public ShadowBluetoothGattServer()
-
-
Method Details
-
close
Close this GATT server instance. -
cancelConnection
Disconnects an established connection, or cancels a connection attempt currently in progress.- Parameters:
device
- Remote device
-
sendResponse
@Implementation protected boolean sendResponse(BluetoothDevice device, int requestId, int status, int offset, byte[] value) Send a response to a read or write request to a remote device.- Parameters:
device
- The remote device to send this response torequestId
- The ID of the request that was received with the callbackstatus
- The status of the request to be sent to the remote devicesoffset
- Value offset for partial read/write responsevalue
- The value of the attribute that was read/written (optional)
-
addService
Add a service to the GATT server.- Parameters:
service
- service to be added to GattServer
-
removeService
Remove a service from the GATT server.- Parameters:
service
- service to be removed from GattServer
-
clearServices
Remove all services from the list of provided services. -
getServices
Returns a list of GATT services offered by this device. -
getService
Returns aBluetoothGattService
from the list of services offered by this device.If multiple instances of the same service (as identified by UUID) exist, the first instance of the service is returned.
- Parameters:
uuid
- uuid of service
-
notifyConnection
Simulate a successful Gatt Server Connection withBluetoothConnectionManager
. Performs aBluetoothGattCallback#onConnectionStateChange
if available.- Parameters:
device
- remote device
-
notifyDisconnection
Simulate a successful Gatt Server Disconnection withBluetoothConnectionManager
. Performs aBluetoothGattCallback#onConnectionStateChange
if available, even when device was not connected initially.- Parameters:
device
- remote device
-
notifyOnCharacteristicWriteRequest
public boolean notifyOnCharacteristicWriteRequest(BluetoothDevice device, int requestId, BluetoothGattCharacteristic characteristic, Boolean preparedWrite, Boolean responseNeeded, int offset, byte[] value) Simulate a Gatt characteristic write request to the Gatt Server by triggering the server callback.- Parameters:
device
- remote devicerequestId
- id of the requestcharacteristic
- characteristic to be written topreparedWrite
- true, if this write operation should be queued for later executionresponseNeeded
- true, if the remote device requires a responseoffset
- the offset given for the valuevalue
- the value the client wants to assign to the characteristic
-
isConnectionCancelled
Get whether the device's connection has been cancelled.- Parameters:
device
- remote device
-
isConnectedToDevice
Returns true if the connection status of remote device is connected- Parameters:
device
- remote device
-
getResponses
Get a copy of the list of responses that have been sent. -
clearResponses
public void clearResponses()Clear the list of responses. -
getWrittenBytes
Get a copy of the list of bytes that have been received. -
clearWrittenBytes
public void clearWrittenBytes()Clear the list of written bytes. -
isClosed
public boolean isClosed()Get whether server has been closed. -
setGattServerCallback
-
getGattServerCallback
-
getBluetoothConnectionManager
public org.robolectric.shadows.BluetoothConnectionManager getBluetoothConnectionManager()
-