From 9797f6e5f469f2022d05c67ee67326849109ea40 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Fri, 2 Feb 2018 15:33:19 +0100 Subject: [PATCH] fix NPE --- .../plugins/PumpDanaRS/services/BLEComm.java | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/services/BLEComm.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/services/BLEComm.java index a892404929..2901c4b863 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/services/BLEComm.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/services/BLEComm.java @@ -278,16 +278,17 @@ public class BLEComm { } public void writeCharacteristic_NO_RESPONSE(final BluetoothGattCharacteristic characteristic, final byte[] data) { - if ((mBluetoothAdapter == null) || (mBluetoothGatt == null)) { - log.debug("BluetoothAdapter not initialized_ERROR"); - isConnecting = false; - isConnected = false; - return; - } - new Thread(new Runnable() { public void run() { SystemClock.sleep(WRITE_DELAY_MILLIS); + + if ((mBluetoothAdapter == null) || (mBluetoothGatt == null)) { + log.debug("BluetoothAdapter not initialized_ERROR"); + isConnecting = false; + isConnected = false; + return; + } + characteristic.setValue(data); characteristic.setWriteType(BluetoothGattCharacteristic.WRITE_TYPE_NO_RESPONSE); log.debug("writeCharacteristic:" + DanaRS_Packet.toHexString(data));