public class UnitTestBluetoothServer extends java.lang.Object implements IBluetoothServer
IBluetoothServer.DefaultFactory, IBluetoothServer.Factory
DEFAULT_FACTORY
Constructor and Description |
---|
UnitTestBluetoothServer(IBleManager mgr)
Default constructor.
|
Modifier and Type | Method and Description |
---|---|
boolean |
addService(BleService service)
Called by the system when it wants to add a new
BleService to the BleServer instance. |
void |
cancelConnection(P_DeviceHolder device)
Called when attempting to disconnect a device from a
BleServer instance. |
void |
clearServices()
Called by the library when it wants to remove all
BleService s from this BleServer instance. |
void |
close()
Called when the system wants to shutdown the
BleServer instance. |
boolean |
connect(P_DeviceHolder device,
boolean autoConnect)
Called when the system wants to connect the
BleServer instance to a device. |
IBleManager |
getManager()
Returns the
IBleManager instance held by this class. |
android.bluetooth.BluetoothGattServer |
getNativeServer()
Returns
null , as in unit tests it's mocked. |
BleService |
getService(java.util.UUID uuid)
Returns a
BleService instance which has the given UUID . |
java.util.List<BleService> |
getServices()
Returns a List of
BleService s served by the BleServer instance. |
boolean |
isServerNull()
Returns
true if the server instance is null . |
boolean |
notifyCharacteristicChanged(P_DeviceHolder device,
BleCharacteristic characteristic,
boolean confirm)
Called by the system to say that a notification has changed.
|
boolean |
removeService(BleService service)
Called by the library when removing a
BleService . |
boolean |
sendResponse(P_DeviceHolder device,
int requestId,
int status,
int offset,
byte[] value)
Called by the system to send a response to a request from a connected device.
|
public UnitTestBluetoothServer(IBleManager mgr)
public boolean isServerNull()
true
if the server instance is null
. This method for now, always returns false
.isServerNull
in interface IBluetoothServer
public boolean addService(BleService service)
BleService
to the BleServer
instance.addService
in interface IBluetoothServer
public void cancelConnection(P_DeviceHolder device)
BleServer
instance.cancelConnection
in interface IBluetoothServer
public void clearServices()
BleService
s from this BleServer
instance.clearServices
in interface IBluetoothServer
public void close()
BleServer
instance.close
in interface IBluetoothServer
public boolean connect(P_DeviceHolder device, boolean autoConnect)
BleServer
instance to a device.connect
in interface IBluetoothServer
public BleService getService(java.util.UUID uuid)
BleService
instance which has the given UUID
. If none are found, BleService.NULL
is
returned.getService
in interface IBluetoothServer
public java.util.List<BleService> getServices()
BleService
s served by the BleServer
instance.getServices
in interface IBluetoothServer
public boolean notifyCharacteristicChanged(P_DeviceHolder device, BleCharacteristic characteristic, boolean confirm)
notifyCharacteristicChanged
in interface IBluetoothServer
public boolean removeService(BleService service)
BleService
.removeService
in interface IBluetoothServer
public boolean sendResponse(P_DeviceHolder device, int requestId, int status, int offset, byte[] value)
sendResponse
in interface IBluetoothServer
public android.bluetooth.BluetoothGattServer getNativeServer()
null
, as in unit tests it's mocked.getNativeServer
in interface IBluetoothServer
public IBleManager getManager()
IBleManager
instance held by this class.