call readyToRead on BleIOs

This commit is contained in:
Andrei Vereha 2021-03-28 23:14:41 +02:00
parent 2f87620050
commit 96b1b177a6
2 changed files with 7 additions and 5 deletions

View file

@ -1,6 +1,7 @@
<component name="ProjectCodeStyleConfiguration">
<code_scheme name="Project" version="173">
<option name="AUTODETECT_INDENTS" value="false" />
<option name="WRAP_WHEN_TYPING_REACHES_RIGHT_MARGIN" value="true" />
<JetCodeStyleSettings>
<option name="PACKAGES_TO_USE_STAR_IMPORTS">
<value>

View file

@ -52,19 +52,20 @@ class Connection(val podDevice: BluetoothDevice, private val aapsLogger: AAPSLog
private val discoveredCharacteristics = discoverer.discoverServices()
private val cmdBleIO = CmdBleIO(aapsLogger, discoveredCharacteristics[CharacteristicType.CMD]!!, incomingPackets
.cmdQueue, gattConnection, bleCommCallbacks)
private val dataBleIO = DataBleIO(aapsLogger, discoveredCharacteristics[CharacteristicType.DATA]!!, incomingPackets
.dataQueue, gattConnection, bleCommCallbacks)
val msgIO = MessageIO(aapsLogger, cmdBleIO, dataBleIO)
var session: Session? = null
init {
val sendResult = cmdBleIO.hello()
if (sendResult !is BleSendSuccess) {
throw FailedToConnectException("Could not send HELLO command to ${podDevice.address}")
}
cmdBleIO.readyToRead()
dataBleIO.readyToRead()
}
private val dataBleIO = DataBleIO(aapsLogger, discoveredCharacteristics[CharacteristicType.DATA]!!, incomingPackets
.dataQueue, gattConnection, bleCommCallbacks)
val msgIO = MessageIO(aapsLogger, cmdBleIO, dataBleIO)
var session: Session? = null
fun connect() {
if (!gattConnection.connect()) {
throw FailedToConnectException("connect() returned false")