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
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
fun connectToServer(serverDevice: MockServerDevice, clientDevice: MockClientDevice, client: GattClientAPI, options: BleGattConnectOptions)
Link copied to clipboard
fun disableCharacteristicNotification(clientDevice: ClientDevice, device: MockServerDevice, characteristic: IBluetoothGattCharacteristic): Boolean
Link copied to clipboard
Link copied to clipboard
fun enableCharacteristicNotification(clientDevice: ClientDevice, device: MockServerDevice, characteristic: IBluetoothGattCharacteristic): Boolean
Link copied to clipboard
Link copied to clipboard
fun notifyCharacteristicChanged(device: ClientDevice, characteristic: IBluetoothGattCharacteristic, confirm: Boolean, value: DataByteArray)
Link copied to clipboard
fun readCharacteristic(device: MockServerDevice, clientDevice: ClientDevice, characteristic: IBluetoothGattCharacteristic): Boolean
Link copied to clipboard
fun readDescriptor(device: MockServerDevice, clientDevice: ClientDevice, descriptor: IBluetoothGattDescriptor): Boolean
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
fun registerServer(server: GattServerAPI, device: MockServerDevice, services: List<IBluetoothGattService>)
Link copied to clipboard
fun requestConnectionPriority(clientDevice: ClientDevice, priority: BleGattConnectionPriority): Boolean
Link copied to clipboard
Link copied to clipboard
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
fun writeDescriptor(device: MockServerDevice, clientDevice: ClientDevice, descriptor: IBluetoothGattDescriptor, value: DataByteArray): Boolean