PeripheralSpecEventHandler

This is the interface of a peripheral event handler.

The implementation should respond to various events occurring on the mock peripheral, such as connection requests, read/write requests, etc.

For example, a mock Blinky device can handle requests to turn on an LED or send notifications when a button was clicked.

Functions

Link copied to clipboard

Called when the connection is lost.

Link copied to clipboard
open fun onConnectionRequest(preferredPhy: List<Phy>): ConnectionResult

Called when a connection request is made to the mock peripheral.

Link copied to clipboard

Emulates an Execute Write request to the characteristic.

Link copied to clipboard
open fun onPrepareWriteRequest(characteristic: MockRemoteCharacteristic, value: ByteArray): PrepareWriteResponse

Emulates a prepared write to a characteristic.

open fun onPrepareWriteRequest(descriptor: MockRemoteDescriptor, value: ByteArray): PrepareWriteResponse
Link copied to clipboard
open fun onReadRequest(characteristic: MockRemoteCharacteristic): ReadResponse

A callback called when the client sends Read request to a characteristic.

open fun onReadRequest(descriptor: MockRemoteDescriptor): ReadResponse
Link copied to clipboard
open fun onReset()

Called when the peripheral is reset.

Link copied to clipboard

Called when a service discovery request is made to the mock peripheral.

Link copied to clipboard
open fun onWriteCommand(characteristic: MockRemoteCharacteristic, value: ByteArray)

A callback called when the client sends a Write Command (write without response) to a characteristic.

Link copied to clipboard
open fun onWriteRequest(characteristic: MockRemoteCharacteristic, value: ByteArray): WriteResponse

A callback called when the client sends a Write Request (write with response) to a characteristic.

open fun onWriteRequest(descriptor: MockRemoteDescriptor, value: ByteArray): WriteResponse