RS pairing improvement
This commit is contained in:
parent
04f074caf9
commit
65770ecbf6
|
@ -177,6 +177,7 @@
|
|||
|
||||
<!-- BlePreCheck-->
|
||||
<string name="ble_not_supported">Bluetooth Low Energy not supported.</string>
|
||||
<string name="ble_not_supported_or_not_paired">Bluetooth Low Energy not supported or device not paired.</string>
|
||||
<string name="ble_not_enabled">Bluetooth not enabled.</string>
|
||||
<string name="location_not_found_title">Location Is Not Enabled</string>
|
||||
<string name="location_not_found_message">For Bluetooth discovery to work on newer devices, location must be enabled. AAPS does not track your location and it can be disabled after pairing is successful.</string>
|
||||
|
|
|
@ -137,7 +137,7 @@ class DanaRSPlugin @Inject constructor(
|
|||
aapsLogger.debug(LTag.PUMP, "RS connect from: $reason")
|
||||
if (danaRSService != null && mDeviceAddress != "" && mDeviceName != "") {
|
||||
val success = danaRSService?.connect(reason, mDeviceAddress) ?: false
|
||||
if (!success) ToastUtils.showToastInUiThread(context, resourceHelper.gs(R.string.ble_not_supported))
|
||||
if (!success) ToastUtils.showToastInUiThread(context, resourceHelper.gs(R.string.ble_not_supported_or_not_paired))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -105,16 +105,21 @@ class BLEComm @Inject internal constructor(
|
|||
return false
|
||||
}
|
||||
|
||||
isConnected = false
|
||||
v3Encryption = false
|
||||
encryptedDataRead = false
|
||||
encryptedCommandSent = false
|
||||
isConnecting = true
|
||||
val device = bluetoothAdapter?.getRemoteDevice(address)
|
||||
if (device == null) {
|
||||
aapsLogger.error("Device not found. Unable to connect from: $from")
|
||||
return false
|
||||
}
|
||||
if (device.bondState == BluetoothDevice.BOND_NONE) {
|
||||
device.createBond()
|
||||
SystemClock.sleep(10000)
|
||||
return false
|
||||
}
|
||||
isConnected = false
|
||||
v3Encryption = false
|
||||
encryptedDataRead = false
|
||||
encryptedCommandSent = false
|
||||
isConnecting = true
|
||||
aapsLogger.debug(LTag.PUMPBTCOMM, "Trying to create a new connection from: $from")
|
||||
connectDeviceName = device.name
|
||||
bluetoothGatt = device.connectGatt(context, false, mGattCallback)
|
||||
|
|
Loading…
Reference in a new issue