diaconn: prevent NPE
This commit is contained in:
parent
9596c49968
commit
31458fb2ba
2 changed files with 4 additions and 1 deletions
|
@ -105,9 +105,11 @@ class BLECommonService @Inject internal constructor(
|
||||||
scheduledDisconnection?.cancel(false)
|
scheduledDisconnection?.cancel(false)
|
||||||
scheduledDisconnection = null
|
scheduledDisconnection = null
|
||||||
|
|
||||||
if (bluetoothAdapter == null || bluetoothGatt == null) {
|
if (bluetoothAdapter == null || bluetoothGatt == null || uartIndicate == null) {
|
||||||
aapsLogger.error("disconnect is not possible: (mBluetoothAdapter == null) " + (bluetoothAdapter == null))
|
aapsLogger.error("disconnect is not possible: (mBluetoothAdapter == null) " + (bluetoothAdapter == null))
|
||||||
aapsLogger.error("disconnect is not possible: (mBluetoothGatt == null) " + (bluetoothGatt == null))
|
aapsLogger.error("disconnect is not possible: (mBluetoothGatt == null) " + (bluetoothGatt == null))
|
||||||
|
aapsLogger.error("disconnect is not possible: (uartIndicate == null) " + (uartIndicate == null))
|
||||||
|
isConnected = false
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
bluetoothGatt?.setCharacteristicNotification(uartIndicate, false)
|
bluetoothGatt?.setCharacteristicNotification(uartIndicate, false)
|
||||||
|
|
|
@ -43,6 +43,7 @@ class RileyLinkBLE @Inject constructor(private val context: Context) {
|
||||||
private val gattDebugEnabled = true
|
private val gattDebugEnabled = true
|
||||||
private var manualDisconnect = false
|
private var manualDisconnect = false
|
||||||
|
|
||||||
|
//val bluetoothAdapter: BluetoothAdapter = BluetoothAdapter.getDefaultAdapter()
|
||||||
val bluetoothAdapter: BluetoothAdapter? get() = (context.getSystemService(Context.BLUETOOTH_SERVICE) as BluetoothManager?)?.adapter
|
val bluetoothAdapter: BluetoothAdapter? get() = (context.getSystemService(Context.BLUETOOTH_SERVICE) as BluetoothManager?)?.adapter
|
||||||
private val bluetoothGattCallback: BluetoothGattCallback
|
private val bluetoothGattCallback: BluetoothGattCallback
|
||||||
var rileyLinkDevice: BluetoothDevice? = null
|
var rileyLinkDevice: BluetoothDevice? = null
|
||||||
|
|
Loading…
Reference in a new issue