Francis Mariano
07/14/2022, 7:24 PMoverride suspend fun dataOad(characteristic: Characteristic) : Flow<ByteArray> {
return peripheral.value.observe(characteristic)
.onStart { Log.debug { "AudioProcessorImpl - dataOad - onStart" } }
.onEach { Log.debug { "AudioProcessorImpl - dataOad - onEach" } }
.onCompletion { Log.debug { "AudioProcessorImpl - dataOad - onCompletion" } }
}
If I cancel the scope that calls dataOad and create it again the observe works fine. But if the peripheral close the connection and I reconnect, the observer does not work anymore 😞
It is necessary close the application and reopen it.travis
07/14/2022, 11:29 PMPeripheral
object (the peripheral
that is referenced in your example) to reconnect?
i.e. you’re not creating a new Peripheral
when you reconnect, right?Francis Mariano
07/15/2022, 1:34 PM2022-07-15 10:43:31.483 29445-29445/com.me.stxbt D/Kable/Peripheral: 54:6C:0E:35:75:17 setCharacteristicNotification
service: 00000427-0000-1000-8000-00805f9b34fb
characteristic: 00000430-0000-1000-8000-00805f9b34fb
value: true
2022-07-15 10:43:31.486 29445-29445/com.me.stxbt D/Kable/Peripheral: 54:6C:0E:35:75:17 write
service: 00000427-0000-1000-8000-00805f9b34fb
characteristic: 00000430-0000-1000-8000-00805f9b34fb
descriptor: 00002902-0000-1000-8000-00805f9b34fb
2022-07-15 10:43:31.535 29445-29739/com.me.stxbt D/Kable/Callback: 54:6C:0E:35:75:17 onDescriptorWrite
service: 00000427-0000-1000-8000-00805f9b34fb
characteristic: 00000430-0000-1000-8000-00805f9b34fb
descriptor: 00002902-0000-1000-8000-00805f9b34fb
status: GATT_SUCCESS(0)
When I cancel the scope :
2022-07-15 10:44:33.759 29445-29445/com.me.stxbt D/Kable/Peripheral: 54:6C:0E:35:75:17 write
service: 00000427-0000-1000-8000-00805f9b34fb
characteristic: 00000430-0000-1000-8000-00805f9b34fb
descriptor: 00002902-0000-1000-8000-00805f9b34fb
The characteristic notification is not disabled. when I recreate the scope and calling the observe again, the setCharacteristicNotification is not executed, but I received the onCharacteristicChanged
because it was not disabled previously.
But if the peripheral (hardware) close the connection (peripheral is turn off) its characteristic notification is disabled. So when I reconnect and calling the observe again, the the setCharacteristicNotification is not executed, in this case I do not receive the onCharacteristicChanged
.travis
07/17/2022, 7:14 AMFrancis Mariano
07/18/2022, 7:31 PM