initialize
This method should initialize the profile.
This method is called after prepare if that method completed successfully.
The context of this method is the profile coroutine scope, which will automatically be canceled when the device gets disconnected or the services will get invalidated. Use a finally block to release whatever the profile acquired for this connection.
Example
override suspend fun CoroutineScope.initialize(peripheral: Peripheral<*, *>) {
// Subscribe to button characteristic.
txCharacteristic
.subscribe()
.map { value -> String(value) }
.onEach {
println("Received: $it")
}
.launchIn(this)
}Content copied to clipboard
Parameters
peripheral
The peripheral the profile is being resolved on.