MockEngine

object MockEngine

An object responsible for connecting client with mocked servers. Each server can be started by setting MockServerDevice parameter. If so then instead of calling BLE API it will be communicating with client using MockEngine. All communication will happen locally, but API the server and client side will be using is the same as for BLE calls.

Generally this is a proxy object. It catches requests emitted by GattClientAPI and emits them as an ServerGattEvent on a server side. The server responds to those events using GattServerAPI which are mapped here to ClientGattEvent and send back to client.

Using this solution may be helpful for testing BLE communication before getting real BLE device or for local junit tests.

Functions

Link copied to clipboard
fun abortReliableWrite(serverDevice: MockServerDevice, clientDevice: ClientDevice)
Link copied to clipboard
Link copied to clipboard
fun beginReliableWrite(serverDevice: MockServerDevice, clientDevice: ClientDevice): Boolean
Link copied to clipboard
fun cancelConnection(serverDevice: MockServerDevice, clientDevice: ClientDevice)
Link copied to clipboard
fun clearServiceCache(serverDevice: MockServerDevice, clientDevice: ClientDevice)
Link copied to clipboard
fun close(serverDevice: MockServerDevice, clientDevice: ClientDevice)
Link copied to clipboard
Link copied to clipboard
fun connectToServer(serverDevice: MockServerDevice, clientDevice: MockClientDevice, client: GattClientAPI, options: BleGattConnectOptions)
Link copied to clipboard
Link copied to clipboard
fun executeReliableWrite(serverDevice: MockServerDevice, clientDevice: ClientDevice): Boolean
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
fun readPhy(device: ClientDevice)
fun readPhy(clientDevice: ClientDevice, device: MockServerDevice)
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
fun requestMtu(clientDevice: ClientDevice, serverDevice: MockServerDevice, mtu: Int): Boolean
Link copied to clipboard
fun requestPhy(device: ClientDevice, txPhy: BleGattPhy, rxPhy: BleGattPhy, phyOption: PhyOption)
Link copied to clipboard
fun sendResponse(device: ClientDevice, requestId: Int, status: Int, offset: Int, value: DataByteArray?)
Link copied to clipboard
fun setPreferredPhy(clientDevice: ClientDevice, serverDevice: MockServerDevice, txPhy: BleGattPhy, rxPhy: BleGattPhy, phyOption: PhyOption)
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
fun writeCharacteristic(serverDevice: ServerDevice, clientDevice: ClientDevice, characteristic: IBluetoothGattCharacteristic, value: DataByteArray, writeType: BleWriteType): Boolean
Link copied to clipboard