move the test code to "connect"
this is wrong, for now I just need an easy way to test the initial handshake
This commit is contained in:
parent
4664d21ddf
commit
9170cc6f76
2 changed files with 13 additions and 15 deletions
|
@ -31,19 +31,6 @@ class OmnipodDashBleManagerImpl @Inject constructor(private val context: Context
|
|||
private val bluetoothManager: BluetoothManager = context.getSystemService(Context.BLUETOOTH_SERVICE) as BluetoothManager
|
||||
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)
|
||||
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
|
||||
// For tests: this.podAddress = "B8:27:EB:1D:7E:BB";
|
||||
val bleIO = connect(podAddress)
|
||||
val msgIO = MessageIO(aapsLogger, bleIO)
|
||||
val ltkExchanger = LTKExchanger(aapsLogger, msgIO)
|
||||
val ltk = ltkExchanger.negociateLTKAndNonce()
|
||||
|
||||
aapsLogger.info(LTag.PUMPCOMM, "Got LTK and Nonce Prefix: ${ltk}")
|
||||
}
|
||||
|
||||
@Throws(FailedToConnectException::class, CouldNotSendBleException::class, InterruptedException::class, BleIOBusyException::class, TimeoutException::class, CouldNotConfirmWriteException::class, CouldNotEnableNotifications::class, DescriptorNotFoundException::class, CouldNotConfirmDescriptorWriteException::class)
|
||||
private fun connect(podAddress: String): BleIO {
|
||||
|
@ -84,8 +71,19 @@ class OmnipodDashBleManagerImpl @Inject constructor(private val context: Context
|
|||
TODO("not implemented")
|
||||
}
|
||||
|
||||
@Throws(InterruptedException::class, ScanFailException::class, FailedToConnectException::class, CouldNotSendBleException::class, BleIOBusyException::class, TimeoutException::class, CouldNotConfirmWriteException::class, CouldNotEnableNotifications::class, DescriptorNotFoundException::class, CouldNotConfirmDescriptorWriteException::class)
|
||||
override fun connect() {
|
||||
TODO("not implemented")
|
||||
// TODO: this is wrong and I know it
|
||||
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
|
||||
// For tests: this.podAddress = "B8:27:EB:1D:7E:BB";
|
||||
val bleIO = connect(podAddress)
|
||||
val msgIO = MessageIO(aapsLogger, bleIO)
|
||||
val ltkExchanger = LTKExchanger(aapsLogger, msgIO)
|
||||
val ltk = ltkExchanger.negociateLTKAndNonce()
|
||||
|
||||
aapsLogger.info(LTag.PUMPCOMM, "Got LTK and Nonce Prefix: ${ltk}")
|
||||
}
|
||||
|
||||
override fun disconnect() {
|
||||
|
|
|
@ -26,7 +26,7 @@ class DashInitializePodViewModel @Inject constructor(private val aapsLogger: AAP
|
|||
// TODO FIRST STEP OF ACTIVATION
|
||||
AsyncTask.execute {
|
||||
try {
|
||||
bleManager.activateNewPod()
|
||||
bleManager.connect()
|
||||
} catch (e: Exception) {
|
||||
aapsLogger.error(LTag.PUMP, "TEST ACTIVATE Exception" + e.toString() + ExceptionUtils.getStackTrace(e))
|
||||
|
||||
|
|
Loading…
Reference in a new issue