From a23c3f2cd860d1192359f945a62e5cf3155f7006 Mon Sep 17 00:00:00 2001 From: Andrei Vereha Date: Fri, 26 Feb 2021 13:33:13 +0100 Subject: [PATCH] Define OmnipodDashBleManager interface --- .../dash/driver/comm/OmnipodDashBleManager.kt | 13 +++++++++-- .../driver/comm/OmnipodDashBleManagerImpl.kt | 22 +++++++++++++++++-- .../driver/comm/status/ConnectionStatus.kt | 4 ++++ 3 files changed, 35 insertions(+), 4 deletions(-) create mode 100644 omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/status/ConnectionStatus.kt diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/OmnipodDashBleManager.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/OmnipodDashBleManager.kt index c90e0438b4..005fa74e45 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/OmnipodDashBleManager.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/OmnipodDashBleManager.kt @@ -1,7 +1,16 @@ package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm +import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.status.ConnectionStatus +import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command.base.Command +import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response.Response + interface OmnipodDashBleManager { - // TODO should we keep this method? - fun activateNewPod() + fun sendCommand(cmd: Command): Response; + + fun getStatus(): ConnectionStatus; + + fun connect() + + fun disconnect() } \ No newline at end of file diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/OmnipodDashBleManagerImpl.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/OmnipodDashBleManagerImpl.kt index 54a89a9b3b..f2d0936b90 100644 --- a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/OmnipodDashBleManagerImpl.kt +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/OmnipodDashBleManagerImpl.kt @@ -13,6 +13,9 @@ import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.command. import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.exceptions.* import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.io.BleIO import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.scan.PodScanner +import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.status.ConnectionStatus +import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.command.base.Command +import info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.pod.response.Response import java.util.concurrent.BlockingQueue import java.util.concurrent.LinkedBlockingDeque import java.util.concurrent.TimeoutException @@ -26,7 +29,7 @@ class OmnipodDashBleManagerImpl @Inject constructor(private val context: Context private val bluetoothAdapter: BluetoothAdapter = bluetoothManager.adapter @Throws(InterruptedException::class, ScanFailException::class, FailedToConnectException::class, CouldNotSendBleException::class, BleIOBusyException::class, TimeoutException::class, CouldNotConfirmWriteException::class, CouldNotEnableNotifications::class, DescriptorNotFoundException::class, CouldNotConfirmDescriptorWriteException::class) - override fun activateNewPod() { + fun activateNewPod() { aapsLogger.info(LTag.PUMPBTCOMM, "starting new pod activation") val podScanner = PodScanner(aapsLogger, bluetoothAdapter) val podAddress = podScanner.scanForPod(PodScanner.SCAN_FOR_SERVICE_UUID, PodScanner.POD_ID_NOT_ACTIVATED).scanResult.device.address @@ -64,8 +67,23 @@ class OmnipodDashBleManagerImpl @Inject constructor(private val context: Context bleIO.readyToRead() } - companion object { + override fun sendCommand(cmd: Command): Response { + TODO("not implemented") + } + override fun getStatus(): ConnectionStatus { + TODO("not implemented") + } + + override fun connect() { + TODO("not implemented") + } + + override fun disconnect() { + TODO("not implemented") + } + + companion object { private const val CONNECT_TIMEOUT_MS = 5000 private const val CONTROLLER_ID = 4242 // TODO read from preferences or somewhere else. } diff --git a/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/status/ConnectionStatus.kt b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/status/ConnectionStatus.kt new file mode 100644 index 0000000000..76d9ec5eed --- /dev/null +++ b/omnipod-dash/src/main/java/info/nightscout/androidaps/plugins/pump/omnipod/dash/driver/comm/status/ConnectionStatus.kt @@ -0,0 +1,4 @@ +package info.nightscout.androidaps.plugins.pump.omnipod.dash.driver.comm.status + +interface ConnectionStatus { +} \ No newline at end of file