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 ofBluetoothGattServer.
-
-
Field Summary
Fields Modifier and Type Field Description protected org.robolectric.shadows.ShadowBluetoothGattServer.BluetoothGattServerReflectorbluetoothGattServerReflector
-
Constructor Summary
Constructors Constructor Description ShadowBluetoothGattServer()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidcancelConnection(BluetoothDevice device)Disconnects an established connection, or cancels a connection attempt currently in progress.voidclearResponses()Clear the list of responses.protected voidclose()Close this GATT server instance.org.robolectric.shadows.BluetoothConnectionManagergetBluetoothConnectionManager()BluetoothGattServerCallbackgetGattServerCallback()List<byte[]>getResponses()Get a copy of the list of responses that have been sent.booleanisClosed()Get whether server has been closed.booleanisConnectedToDevice(BluetoothDevice device)Returns true if the connection status of remote device is connectedbooleanisConnectionCancelled(BluetoothDevice device)Get whether the device's connection has been cancelled.voidnotifyConnection(BluetoothDevice device)Simulate a successful Gatt Server Connection withBluetoothConnectionManager.voidnotifyDisconnection(BluetoothDevice device)Simulate a successful Gatt Server Disconnection withBluetoothConnectionManager.protected booleansendResponse(BluetoothDevice device, int requestId, int status, int offset, byte[] value)Send a response to a read or write request to a remote device.voidsetGattServerCallback(BluetoothGattServerCallback callback)
-
-
-
Method Detail
-
close
@Implementation protected void close()
Close this GATT server instance.
-
cancelConnection
@Implementation protected void cancelConnection(BluetoothDevice device)
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)
-
notifyConnection
public void notifyConnection(BluetoothDevice device)
Simulate a successful Gatt Server Connection withBluetoothConnectionManager. Performs aBluetoothGattCallback#onConnectionStateChangeif available.- Parameters:
device- remote device
-
notifyDisconnection
public void notifyDisconnection(BluetoothDevice device)
Simulate a successful Gatt Server Disconnection withBluetoothConnectionManager. Performs aBluetoothGattCallback#onConnectionStateChangeif available, even when device was not connected initially.- Parameters:
device- remote device
-
isConnectionCancelled
public boolean isConnectionCancelled(BluetoothDevice device)
Get whether the device's connection has been cancelled.- Parameters:
device- remote device
-
isConnectedToDevice
public boolean isConnectedToDevice(BluetoothDevice device)
Returns true if the connection status of remote device is connected- Parameters:
device- remote device
-
getResponses
public List<byte[]> getResponses()
Get a copy of the list of responses that have been sent.
-
clearResponses
public void clearResponses()
Clear the list of responses.
-
isClosed
public boolean isClosed()
Get whether server has been closed.
-
setGattServerCallback
public void setGattServerCallback(BluetoothGattServerCallback callback)
-
getGattServerCallback
public BluetoothGattServerCallback getGattServerCallback()
-
getBluetoothConnectionManager
public org.robolectric.shadows.BluetoothConnectionManager getBluetoothConnectionManager()
-
-