diff --git a/pump/danar/src/main/java/info/nightscout/androidaps/danar/SerialIOThread.java b/pump/danar/src/main/java/info/nightscout/androidaps/danar/SerialIOThread.java index 93c144b410..520d2bc91f 100644 --- a/pump/danar/src/main/java/info/nightscout/androidaps/danar/SerialIOThread.java +++ b/pump/danar/src/main/java/info/nightscout/androidaps/danar/SerialIOThread.java @@ -33,8 +33,6 @@ public class SerialIOThread extends Thread { private final MessageHashTableBase hashTable; private final DanaPump danaPump; - private final Object lock = new Object(); - public SerialIOThread(AAPSLogger aapsLogger, BluetoothSocket rfcommSocket, MessageHashTableBase hashTable, DanaPump danaPump) { super(); this.hashTable = hashTable; @@ -84,7 +82,7 @@ public class SerialIOThread extends Thread { // process the message content message.setReceived(true); message.handleMessage(extractedBuff); - synchronized (lock) { + synchronized (message) { message.notifyAll(); } } diff --git a/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/service/BLECommonService.kt b/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/service/BLECommonService.kt index a0622de82d..4a171a9209 100644 --- a/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/service/BLECommonService.kt +++ b/pump/diaconn/src/main/java/info/nightscout/pump/diaconn/service/BLECommonService.kt @@ -40,6 +40,7 @@ import java.util.concurrent.ScheduledFuture import javax.inject.Inject import javax.inject.Singleton +@Suppress("SpellCheckingInspection") @Singleton class BLECommonService @Inject internal constructor( private val injector: HasAndroidInjector, @@ -399,15 +400,15 @@ class BLECommonService @Inject internal constructor( } } - if (message != null) { - aapsLogger.debug(LTag.PUMPBTCOMM, "<<<<< " + message!!.friendlyName + " " + DiaconnG8Packet.toHex(data)) + message?.let { + aapsLogger.debug(LTag.PUMPBTCOMM, "<<<<< " + it.friendlyName + " " + DiaconnG8Packet.toHex(data)) // process received data - message!!.handleMessage(data) - message!!.setReceived() - synchronized(message!!) { + it.handleMessage(data) + it.setReceived() + synchronized(it) { // notify to sendMessage - message!!.notifyAll() + it.notifyAll() } - } else aapsLogger.error("Unknown message received " + DiaconnG8Packet.toHex(data)) + } ?: aapsLogger.error("Unknown message received " + DiaconnG8Packet.toHex(data)) } }