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