Upgrade RS encryption library
This commit is contained in:
parent
4716b04972
commit
7b0bc81c47
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -8,7 +8,6 @@
|
||||||
build/
|
build/
|
||||||
.idea/*
|
.idea/*
|
||||||
!.idea/codeStyles/
|
!.idea/codeStyles/
|
||||||
app/src/main/jniLibs
|
|
||||||
full/
|
full/
|
||||||
debug/
|
debug/
|
||||||
release/
|
release/
|
||||||
|
|
|
@ -340,30 +340,6 @@ dependencies {
|
||||||
androidTestImplementation 'androidx.test.uiautomator:uiautomator:2.2.0'
|
androidTestImplementation 'androidx.test.uiautomator:uiautomator:2.2.0'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
task downloadZipFile(type: Download) {
|
|
||||||
src 'https://github.com/MilosKozak/danars-support-lib/archive/master.zip'
|
|
||||||
dest new File(buildDir, 'danars.zip')
|
|
||||||
}
|
|
||||||
|
|
||||||
task downloadAndUnzipFile(dependsOn: downloadZipFile, type: Copy) {
|
|
||||||
from zipTree(downloadZipFile.dest)
|
|
||||||
def outputDir = file("${buildDir}/unpacked/dist")
|
|
||||||
into outputDir
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
task copyLibs(dependsOn: downloadAndUnzipFile, type: Copy) {
|
|
||||||
def src = file("${buildDir}/unpacked/dist/danars-support-lib-master")
|
|
||||||
def target = file("src/main/jniLibs/")
|
|
||||||
|
|
||||||
from src
|
|
||||||
into target
|
|
||||||
}
|
|
||||||
|
|
||||||
task full_clean(type: Delete) {
|
|
||||||
delete file("src/main/jniLibs")
|
|
||||||
}
|
|
||||||
/*
|
/*
|
||||||
// Run 'adb' shell command to clear application data of main app for 'debug' variant
|
// Run 'adb' shell command to clear application data of main app for 'debug' variant
|
||||||
task clearMainAppData(type: Exec) {
|
task clearMainAppData(type: Exec) {
|
||||||
|
@ -395,8 +371,6 @@ tasks.whenTaskAdded { task ->
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
clean.dependsOn full_clean
|
|
||||||
preBuild.dependsOn copyLibs
|
|
||||||
|
|
||||||
printf('--------------\n')
|
printf('--------------\n')
|
||||||
printf('isMaster: %s\n', isMaster().toString())
|
printf('isMaster: %s\n', isMaster().toString())
|
||||||
|
|
|
@ -195,9 +195,7 @@ public class DanaRSPlugin extends PumpPluginBase implements PumpInterface, DanaR
|
||||||
public void connect(String from) {
|
public void connect(String from) {
|
||||||
getAapsLogger().debug(LTag.PUMP, "RS connect from: " + from);
|
getAapsLogger().debug(LTag.PUMP, "RS connect from: " + from);
|
||||||
if (danaRSService != null && !mDeviceAddress.equals("") && !mDeviceName.equals("")) {
|
if (danaRSService != null && !mDeviceAddress.equals("") && !mDeviceName.equals("")) {
|
||||||
final Object o = new Object();
|
danaRSService.connect(from, mDeviceAddress);
|
||||||
|
|
||||||
danaRSService.connect(from, mDeviceAddress, o);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,9 +3,8 @@ package info.nightscout.androidaps.plugins.pump.danaRS.comm;
|
||||||
import android.annotation.TargetApi;
|
import android.annotation.TargetApi;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
|
|
||||||
import com.cozmo.danar.util.BleCommandUtil;
|
import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
@ -21,7 +20,7 @@ public class DanaRS_Packet {
|
||||||
|
|
||||||
private boolean received;
|
private boolean received;
|
||||||
public boolean failed;
|
public boolean failed;
|
||||||
protected int type = BleCommandUtil.DANAR_PACKET__TYPE_RESPONSE; // most of the messages, should be changed for others
|
protected int type = BleEncryption.DANAR_PACKET__TYPE_RESPONSE; // most of the messages, should be changed for others
|
||||||
protected int opCode;
|
protected int opCode;
|
||||||
|
|
||||||
public DanaRS_Packet() {
|
public DanaRS_Packet() {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
||||||
|
|
||||||
import com.cozmo.danar.util.BleCommandUtil
|
import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.logging.LTag
|
import info.nightscout.androidaps.logging.LTag
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ class DanaRS_Packet_APS_Basal_Set_Temporary_Basal(
|
||||||
var error = 0
|
var error = 0
|
||||||
|
|
||||||
init {
|
init {
|
||||||
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BASAL__APS_SET_TEMPORARY_BASAL
|
opCode = BleEncryption.DANAR_PACKET__OPCODE_BASAL__APS_SET_TEMPORARY_BASAL
|
||||||
aapsLogger.debug(LTag.PUMPCOMM, "New message: percent: $percent")
|
aapsLogger.debug(LTag.PUMPCOMM, "New message: percent: $percent")
|
||||||
|
|
||||||
if (percent < 0) percent = 0
|
if (percent < 0) percent = 0
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
||||||
|
|
||||||
import com.cozmo.danar.util.BleCommandUtil
|
import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption
|
||||||
import info.nightscout.androidaps.R
|
import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.data.DetailedBolusInfo
|
import info.nightscout.androidaps.data.DetailedBolusInfo
|
||||||
import info.nightscout.androidaps.db.ExtendedBolus
|
import info.nightscout.androidaps.db.ExtendedBolus
|
||||||
|
@ -36,7 +36,7 @@ open class DanaRS_Packet_APS_History_Events(
|
||||||
private var sec = 0
|
private var sec = 0
|
||||||
|
|
||||||
init {
|
init {
|
||||||
opCode = BleCommandUtil.DANAR_PACKET__OPCODE__APS_HISTORY_EVENTS
|
opCode = BleEncryption.DANAR_PACKET__OPCODE__APS_HISTORY_EVENTS
|
||||||
val cal = GregorianCalendar()
|
val cal = GregorianCalendar()
|
||||||
if (from > DateUtil.now()) {
|
if (from > DateUtil.now()) {
|
||||||
aapsLogger.debug(LTag.PUMPCOMM, "Asked to load from the future")
|
aapsLogger.debug(LTag.PUMPCOMM, "Asked to load from the future")
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
||||||
|
|
||||||
import com.cozmo.danar.util.BleCommandUtil
|
import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.logging.LTag
|
import info.nightscout.androidaps.logging.LTag
|
||||||
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump
|
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump
|
||||||
|
@ -16,7 +16,7 @@ class DanaRS_Packet_APS_Set_Event_History(
|
||||||
) : DanaRS_Packet() {
|
) : DanaRS_Packet() {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
opCode = BleCommandUtil.DANAR_PACKET__OPCODE__APS_SET_EVENT_HISTORY
|
opCode = BleEncryption.DANAR_PACKET__OPCODE__APS_SET_EVENT_HISTORY
|
||||||
if ((packetType == DanaRPump.CARBS || packetType == DanaRPump.BOLUS) && param1 <= 0) this.param1 = 0
|
if ((packetType == DanaRPump.CARBS || packetType == DanaRPump.BOLUS) && param1 <= 0) this.param1 = 0
|
||||||
aapsLogger.debug(LTag.PUMPCOMM, "Set history entry: " + DateUtil.dateAndTimeString(time) + " type: " + packetType + " param1: " + param1 + " param2: " + param2)
|
aapsLogger.debug(LTag.PUMPCOMM, "Set history entry: " + DateUtil.dateAndTimeString(time) + " type: " + packetType + " param1: " + param1 + " param2: " + param2)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
||||||
|
|
||||||
import com.cozmo.danar.util.BleCommandUtil
|
import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption
|
||||||
import info.nightscout.androidaps.R
|
import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.logging.LTag
|
import info.nightscout.androidaps.logging.LTag
|
||||||
|
@ -20,7 +20,7 @@ class DanaRS_Packet_Basal_Get_Basal_Rate(
|
||||||
) : DanaRS_Packet() {
|
) : DanaRS_Packet() {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BASAL__GET_BASAL_RATE
|
opCode = BleEncryption.DANAR_PACKET__OPCODE_BASAL__GET_BASAL_RATE
|
||||||
aapsLogger.debug(LTag.PUMPCOMM, "Requesting basal rates")
|
aapsLogger.debug(LTag.PUMPCOMM, "Requesting basal rates")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
||||||
|
|
||||||
import com.cozmo.danar.util.BleCommandUtil
|
import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.logging.LTag
|
import info.nightscout.androidaps.logging.LTag
|
||||||
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump
|
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump
|
||||||
|
@ -13,7 +13,7 @@ open class DanaRS_Packet_Basal_Get_Profile_Basal_Rate(
|
||||||
) : DanaRS_Packet() {
|
) : DanaRS_Packet() {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BASAL__GET_PROFILE_BASAL_RATE
|
opCode = BleEncryption.DANAR_PACKET__OPCODE_BASAL__GET_PROFILE_BASAL_RATE
|
||||||
aapsLogger.debug(LTag.PUMPCOMM, "Requesting basal rates for profile $profileNumber")
|
aapsLogger.debug(LTag.PUMPCOMM, "Requesting basal rates for profile $profileNumber")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
||||||
|
|
||||||
import com.cozmo.danar.util.BleCommandUtil
|
import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.logging.LTag
|
import info.nightscout.androidaps.logging.LTag
|
||||||
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump
|
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump
|
||||||
|
@ -11,7 +11,7 @@ class DanaRS_Packet_Basal_Get_Profile_Number(
|
||||||
) : DanaRS_Packet() {
|
) : DanaRS_Packet() {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BASAL__GET_PROFILE_NUMBER
|
opCode = BleEncryption.DANAR_PACKET__OPCODE_BASAL__GET_PROFILE_NUMBER
|
||||||
aapsLogger.debug(LTag.PUMPCOMM, "Requesting active profile")
|
aapsLogger.debug(LTag.PUMPCOMM, "Requesting active profile")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
||||||
|
|
||||||
import com.cozmo.danar.util.BleCommandUtil
|
import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.logging.LTag
|
import info.nightscout.androidaps.logging.LTag
|
||||||
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump
|
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump
|
||||||
|
@ -13,7 +13,7 @@ class DanaRS_Packet_Basal_Get_Temporary_Basal_State(
|
||||||
) : DanaRS_Packet() {
|
) : DanaRS_Packet() {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BASAL__TEMPORARY_BASAL_STATE
|
opCode = BleEncryption.DANAR_PACKET__OPCODE_BASAL__TEMPORARY_BASAL_STATE
|
||||||
aapsLogger.debug(LTag.PUMPCOMM, "Requesting temporary basal status")
|
aapsLogger.debug(LTag.PUMPCOMM, "Requesting temporary basal status")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
||||||
|
|
||||||
import com.cozmo.danar.util.BleCommandUtil
|
import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.logging.LTag
|
import info.nightscout.androidaps.logging.LTag
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ class DanaRS_Packet_Basal_Set_Basal_Rate(
|
||||||
|
|
||||||
|
|
||||||
init {
|
init {
|
||||||
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BASAL__SET_BASAL_RATE
|
opCode = BleEncryption.DANAR_PACKET__OPCODE_BASAL__SET_BASAL_RATE
|
||||||
aapsLogger.debug(LTag.PUMPCOMM, "Setting new basal rates")
|
aapsLogger.debug(LTag.PUMPCOMM, "Setting new basal rates")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
||||||
|
|
||||||
import com.cozmo.danar.util.BleCommandUtil
|
import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.logging.LTag
|
import info.nightscout.androidaps.logging.LTag
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ class DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal(
|
||||||
) : DanaRS_Packet() {
|
) : DanaRS_Packet() {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BASAL__CANCEL_TEMPORARY_BASAL
|
opCode = BleEncryption.DANAR_PACKET__OPCODE_BASAL__CANCEL_TEMPORARY_BASAL
|
||||||
aapsLogger.debug(LTag.PUMPCOMM, "Canceling temp basal")
|
aapsLogger.debug(LTag.PUMPCOMM, "Canceling temp basal")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
||||||
|
|
||||||
import com.cozmo.danar.util.BleCommandUtil
|
import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.logging.LTag
|
import info.nightscout.androidaps.logging.LTag
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ class DanaRS_Packet_Basal_Set_Profile_Basal_Rate(
|
||||||
) : DanaRS_Packet() {
|
) : DanaRS_Packet() {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BASAL__SET_PROFILE_BASAL_RATE
|
opCode = BleEncryption.DANAR_PACKET__OPCODE_BASAL__SET_PROFILE_BASAL_RATE
|
||||||
aapsLogger.debug(LTag.PUMPCOMM, "Setting new basal rates for profile $profileNumber")
|
aapsLogger.debug(LTag.PUMPCOMM, "Setting new basal rates for profile $profileNumber")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
||||||
|
|
||||||
import com.cozmo.danar.util.BleCommandUtil
|
import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.logging.LTag
|
import info.nightscout.androidaps.logging.LTag
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ class DanaRS_Packet_Basal_Set_Profile_Number(
|
||||||
) : DanaRS_Packet() {
|
) : DanaRS_Packet() {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BASAL__SET_PROFILE_NUMBER
|
opCode = BleEncryption.DANAR_PACKET__OPCODE_BASAL__SET_PROFILE_NUMBER
|
||||||
aapsLogger.debug(LTag.PUMPCOMM, "Setting profile number $profileNumber")
|
aapsLogger.debug(LTag.PUMPCOMM, "Setting profile number $profileNumber")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
||||||
|
|
||||||
import com.cozmo.danar.util.BleCommandUtil
|
import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.logging.LTag
|
import info.nightscout.androidaps.logging.LTag
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ class DanaRS_Packet_Basal_Set_Suspend_Off(
|
||||||
) : DanaRS_Packet() {
|
) : DanaRS_Packet() {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BASAL__SET_SUSPEND_OFF
|
opCode = BleEncryption.DANAR_PACKET__OPCODE_BASAL__SET_SUSPEND_OFF
|
||||||
aapsLogger.debug(LTag.PUMPCOMM, "Turning off suspend")
|
aapsLogger.debug(LTag.PUMPCOMM, "Turning off suspend")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
||||||
|
|
||||||
import com.cozmo.danar.util.BleCommandUtil
|
import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.logging.LTag
|
import info.nightscout.androidaps.logging.LTag
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ class DanaRS_Packet_Basal_Set_Suspend_On(
|
||||||
) : DanaRS_Packet() {
|
) : DanaRS_Packet() {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BASAL__SET_SUSPEND_ON
|
opCode = BleEncryption.DANAR_PACKET__OPCODE_BASAL__SET_SUSPEND_ON
|
||||||
aapsLogger.debug(LTag.PUMPCOMM, "Turning on suspend")
|
aapsLogger.debug(LTag.PUMPCOMM, "Turning on suspend")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
||||||
|
|
||||||
import com.cozmo.danar.util.BleCommandUtil
|
import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.logging.LTag
|
import info.nightscout.androidaps.logging.LTag
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ open class DanaRS_Packet_Basal_Set_Temporary_Basal(
|
||||||
) : DanaRS_Packet() {
|
) : DanaRS_Packet() {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BASAL__SET_TEMPORARY_BASAL
|
opCode = BleEncryption.DANAR_PACKET__OPCODE_BASAL__SET_TEMPORARY_BASAL
|
||||||
aapsLogger.debug(LTag.PUMPCOMM, "Setting temporary basal of $temporaryBasalRatio% for $temporaryBasalDuration hours")
|
aapsLogger.debug(LTag.PUMPCOMM, "Setting temporary basal of $temporaryBasalRatio% for $temporaryBasalDuration hours")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
||||||
|
|
||||||
import com.cozmo.danar.util.BleCommandUtil
|
import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption
|
||||||
import info.nightscout.androidaps.R
|
import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.logging.LTag
|
import info.nightscout.androidaps.logging.LTag
|
||||||
|
@ -20,7 +20,7 @@ class DanaRS_Packet_Bolus_Get_Bolus_Option(
|
||||||
) : DanaRS_Packet() {
|
) : DanaRS_Packet() {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BOLUS__GET_BOLUS_OPTION
|
opCode = BleEncryption.DANAR_PACKET__OPCODE_BOLUS__GET_BOLUS_OPTION
|
||||||
aapsLogger.debug(LTag.PUMPCOMM, "New message")
|
aapsLogger.debug(LTag.PUMPCOMM, "New message")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
||||||
|
|
||||||
import com.cozmo.danar.util.BleCommandUtil
|
import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.logging.LTag
|
import info.nightscout.androidaps.logging.LTag
|
||||||
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump
|
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump
|
||||||
|
@ -11,7 +11,7 @@ class DanaRS_Packet_Bolus_Get_CIR_CF_Array(
|
||||||
) : DanaRS_Packet() {
|
) : DanaRS_Packet() {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BOLUS__GET_CIR_CF_ARRAY
|
opCode = BleEncryption.DANAR_PACKET__OPCODE_BOLUS__GET_CIR_CF_ARRAY
|
||||||
aapsLogger.debug(LTag.PUMPCOMM, "New message")
|
aapsLogger.debug(LTag.PUMPCOMM, "New message")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
||||||
|
|
||||||
import com.cozmo.danar.util.BleCommandUtil
|
import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.logging.LTag
|
import info.nightscout.androidaps.logging.LTag
|
||||||
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump
|
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump
|
||||||
|
@ -12,7 +12,7 @@ class DanaRS_Packet_Bolus_Get_Calculation_Information(
|
||||||
|
|
||||||
|
|
||||||
init {
|
init {
|
||||||
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BOLUS__GET_CALCULATION_INFORMATION
|
opCode = BleEncryption.DANAR_PACKET__OPCODE_BOLUS__GET_CALCULATION_INFORMATION
|
||||||
aapsLogger.debug(LTag.PUMPCOMM, "New message")
|
aapsLogger.debug(LTag.PUMPCOMM, "New message")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
||||||
|
|
||||||
import com.cozmo.danar.util.BleCommandUtil
|
import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.logging.LTag
|
import info.nightscout.androidaps.logging.LTag
|
||||||
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump
|
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump
|
||||||
|
@ -11,7 +11,7 @@ class DanaRS_Packet_Bolus_Get_Carbohydrate_Calculation_Information(
|
||||||
) : DanaRS_Packet() {
|
) : DanaRS_Packet() {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BOLUS__GET_CARBOHYDRATE_CALCULATION_INFORMATION
|
opCode = BleEncryption.DANAR_PACKET__OPCODE_BOLUS__GET_CARBOHYDRATE_CALCULATION_INFORMATION
|
||||||
aapsLogger.debug(LTag.PUMPCOMM, "New message")
|
aapsLogger.debug(LTag.PUMPCOMM, "New message")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
||||||
|
|
||||||
import com.cozmo.danar.util.BleCommandUtil
|
import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.logging.LTag
|
import info.nightscout.androidaps.logging.LTag
|
||||||
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump
|
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump
|
||||||
|
@ -11,7 +11,7 @@ class DanaRS_Packet_Bolus_Get_Dual_Bolus(
|
||||||
) : DanaRS_Packet() {
|
) : DanaRS_Packet() {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BOLUS__GET_DUAL_BOLUS
|
opCode = BleEncryption.DANAR_PACKET__OPCODE_BOLUS__GET_DUAL_BOLUS
|
||||||
aapsLogger.debug(LTag.PUMPCOMM, "New message")
|
aapsLogger.debug(LTag.PUMPCOMM, "New message")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
||||||
|
|
||||||
import com.cozmo.danar.util.BleCommandUtil
|
import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.logging.LTag
|
import info.nightscout.androidaps.logging.LTag
|
||||||
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump
|
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump
|
||||||
|
@ -11,7 +11,7 @@ class DanaRS_Packet_Bolus_Get_Extended_Bolus(
|
||||||
) : DanaRS_Packet() {
|
) : DanaRS_Packet() {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BOLUS__GET_EXTENDED_BOLUS
|
opCode = BleEncryption.DANAR_PACKET__OPCODE_BOLUS__GET_EXTENDED_BOLUS
|
||||||
aapsLogger.debug(LTag.PUMPCOMM, "New message")
|
aapsLogger.debug(LTag.PUMPCOMM, "New message")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
||||||
|
|
||||||
import com.cozmo.danar.util.BleCommandUtil
|
import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.logging.LTag
|
import info.nightscout.androidaps.logging.LTag
|
||||||
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump
|
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump
|
||||||
|
@ -11,7 +11,7 @@ class DanaRS_Packet_Bolus_Get_Extended_Bolus_State(
|
||||||
) : DanaRS_Packet() {
|
) : DanaRS_Packet() {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BOLUS__GET_EXTENDED_BOLUS_STATE
|
opCode = BleEncryption.DANAR_PACKET__OPCODE_BOLUS__GET_EXTENDED_BOLUS_STATE
|
||||||
aapsLogger.debug(LTag.PUMPCOMM, "New message")
|
aapsLogger.debug(LTag.PUMPCOMM, "New message")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
||||||
|
|
||||||
import com.cozmo.danar.util.BleCommandUtil
|
import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.logging.LTag
|
import info.nightscout.androidaps.logging.LTag
|
||||||
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump
|
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump
|
||||||
|
@ -11,7 +11,7 @@ class DanaRS_Packet_Bolus_Get_Extended_Menu_Option_State(
|
||||||
) : DanaRS_Packet() {
|
) : DanaRS_Packet() {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BOLUS__GET_EXTENDED_MENU_OPTION_STATE
|
opCode = BleEncryption.DANAR_PACKET__OPCODE_BOLUS__GET_EXTENDED_MENU_OPTION_STATE
|
||||||
aapsLogger.debug(LTag.PUMPCOMM, "New message")
|
aapsLogger.debug(LTag.PUMPCOMM, "New message")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
||||||
|
|
||||||
import com.cozmo.danar.util.BleCommandUtil
|
import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.logging.LTag
|
import info.nightscout.androidaps.logging.LTag
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ class DanaRS_Packet_Bolus_Get_Initial_Bolus(
|
||||||
) : DanaRS_Packet() {
|
) : DanaRS_Packet() {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BOLUS__GET_BOLUS_RATE
|
opCode = BleEncryption.DANAR_PACKET__OPCODE_BOLUS__GET_BOLUS_RATE
|
||||||
aapsLogger.debug(LTag.PUMPCOMM, "New message")
|
aapsLogger.debug(LTag.PUMPCOMM, "New message")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
||||||
|
|
||||||
import com.cozmo.danar.util.BleCommandUtil
|
import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.logging.LTag
|
import info.nightscout.androidaps.logging.LTag
|
||||||
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump
|
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump
|
||||||
|
@ -13,7 +13,7 @@ class DanaRS_Packet_Bolus_Get_Step_Bolus_Information(
|
||||||
) : DanaRS_Packet() {
|
) : DanaRS_Packet() {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BOLUS__GET_STEP_BOLUS_INFORMATION
|
opCode = BleEncryption.DANAR_PACKET__OPCODE_BOLUS__GET_STEP_BOLUS_INFORMATION
|
||||||
aapsLogger.debug(LTag.PUMPCOMM, "New message")
|
aapsLogger.debug(LTag.PUMPCOMM, "New message")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
||||||
|
|
||||||
import com.cozmo.danar.util.BleCommandUtil
|
import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.logging.LTag
|
import info.nightscout.androidaps.logging.LTag
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ class DanaRS_Packet_Bolus_Set_Bolus_Option(
|
||||||
) : DanaRS_Packet() {
|
) : DanaRS_Packet() {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BOLUS__SET_BOLUS_OPTION
|
opCode = BleEncryption.DANAR_PACKET__OPCODE_BOLUS__SET_BOLUS_OPTION
|
||||||
aapsLogger.debug(LTag.PUMPCOMM, "Setting bolus options")
|
aapsLogger.debug(LTag.PUMPCOMM, "Setting bolus options")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
||||||
|
|
||||||
import com.cozmo.danar.util.BleCommandUtil
|
import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.logging.LTag
|
import info.nightscout.androidaps.logging.LTag
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ class DanaRS_Packet_Bolus_Set_CIR_CF_Array(
|
||||||
) : DanaRS_Packet() {
|
) : DanaRS_Packet() {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BOLUS__SET_CIR_CF_ARRAY
|
opCode = BleEncryption.DANAR_PACKET__OPCODE_BOLUS__SET_CIR_CF_ARRAY
|
||||||
aapsLogger.debug(LTag.PUMPCOMM, "New message")
|
aapsLogger.debug(LTag.PUMPCOMM, "New message")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
||||||
|
|
||||||
import com.cozmo.danar.util.BleCommandUtil
|
import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.logging.LTag
|
import info.nightscout.androidaps.logging.LTag
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ class DanaRS_Packet_Bolus_Set_Dual_Bolus(
|
||||||
|
|
||||||
|
|
||||||
init {
|
init {
|
||||||
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BOLUS__SET_DUAL_BOLUS
|
opCode = BleEncryption.DANAR_PACKET__OPCODE_BOLUS__SET_DUAL_BOLUS
|
||||||
aapsLogger.debug(LTag.PUMPCOMM, "Dual bolus start : $amount U extended: $extendedAmount U halfhours: $extendedBolusDurationInHalfHours")
|
aapsLogger.debug(LTag.PUMPCOMM, "Dual bolus start : $amount U extended: $extendedAmount U halfhours: $extendedBolusDurationInHalfHours")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
||||||
|
|
||||||
import com.cozmo.danar.util.BleCommandUtil
|
import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.logging.LTag
|
import info.nightscout.androidaps.logging.LTag
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ class DanaRS_Packet_Bolus_Set_Extended_Bolus(
|
||||||
|
|
||||||
|
|
||||||
init {
|
init {
|
||||||
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BOLUS__SET_EXTENDED_BOLUS
|
opCode = BleEncryption.DANAR_PACKET__OPCODE_BOLUS__SET_EXTENDED_BOLUS
|
||||||
aapsLogger.debug(LTag.PUMPCOMM, "Extended bolus start : $extendedAmount U halfhours: $extendedBolusDurationInHalfHours")
|
aapsLogger.debug(LTag.PUMPCOMM, "Extended bolus start : $extendedAmount U halfhours: $extendedBolusDurationInHalfHours")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
||||||
|
|
||||||
import com.cozmo.danar.util.BleCommandUtil
|
import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.logging.LTag
|
import info.nightscout.androidaps.logging.LTag
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ class DanaRS_Packet_Bolus_Set_Extended_Bolus_Cancel(
|
||||||
) : DanaRS_Packet() {
|
) : DanaRS_Packet() {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BOLUS__SET_EXTENDED_BOLUS_CANCEL
|
opCode = BleEncryption.DANAR_PACKET__OPCODE_BOLUS__SET_EXTENDED_BOLUS_CANCEL
|
||||||
aapsLogger.debug(LTag.PUMPCOMM, "Cancel extended bolus")
|
aapsLogger.debug(LTag.PUMPCOMM, "Cancel extended bolus")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
||||||
|
|
||||||
import com.cozmo.danar.util.BleCommandUtil
|
import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.logging.LTag
|
import info.nightscout.androidaps.logging.LTag
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ class DanaRS_Packet_Bolus_Set_Initial_Bolus(
|
||||||
) : DanaRS_Packet() {
|
) : DanaRS_Packet() {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BOLUS__SET_BOLUS_RATE
|
opCode = BleEncryption.DANAR_PACKET__OPCODE_BOLUS__SET_BOLUS_RATE
|
||||||
aapsLogger.debug(LTag.PUMPCOMM, "New message")
|
aapsLogger.debug(LTag.PUMPCOMM, "New message")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
||||||
|
|
||||||
import com.cozmo.danar.util.BleCommandUtil
|
import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption
|
||||||
import info.nightscout.androidaps.interfaces.Constraint
|
import info.nightscout.androidaps.interfaces.Constraint
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.logging.LTag
|
import info.nightscout.androidaps.logging.LTag
|
||||||
|
@ -17,7 +17,7 @@ class DanaRS_Packet_Bolus_Set_Step_Bolus_Start(
|
||||||
|
|
||||||
|
|
||||||
init {
|
init {
|
||||||
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BOLUS__SET_STEP_BOLUS_START
|
opCode = BleEncryption.DANAR_PACKET__OPCODE_BOLUS__SET_STEP_BOLUS_START
|
||||||
// Speed 0 => 12 sec/U, 1 => 30 sec/U, 2 => 60 sec/U
|
// Speed 0 => 12 sec/U, 1 => 30 sec/U, 2 => 60 sec/U
|
||||||
// HARDCODED LIMIT - if there is one that could be created
|
// HARDCODED LIMIT - if there is one that could be created
|
||||||
amount = constraintChecker.applyBolusConstraints(Constraint(amount)).value()
|
amount = constraintChecker.applyBolusConstraints(Constraint(amount)).value()
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
||||||
|
|
||||||
import com.cozmo.danar.util.BleCommandUtil
|
import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption
|
||||||
import info.nightscout.androidaps.R
|
import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.logging.LTag
|
import info.nightscout.androidaps.logging.LTag
|
||||||
|
@ -18,7 +18,7 @@ open class DanaRS_Packet_Bolus_Set_Step_Bolus_Stop(
|
||||||
|
|
||||||
|
|
||||||
init {
|
init {
|
||||||
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BOLUS__SET_STEP_BOLUS_STOP
|
opCode = BleEncryption.DANAR_PACKET__OPCODE_BOLUS__SET_STEP_BOLUS_STOP
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun handleMessage(data: ByteArray) {
|
override fun handleMessage(data: ByteArray) {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
||||||
|
|
||||||
import com.cozmo.danar.util.BleCommandUtil
|
import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.logging.LTag
|
import info.nightscout.androidaps.logging.LTag
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ class DanaRS_Packet_Etc_Keep_Connection(
|
||||||
) : DanaRS_Packet() {
|
) : DanaRS_Packet() {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_ETC__KEEP_CONNECTION
|
opCode = BleEncryption.DANAR_PACKET__OPCODE_ETC__KEEP_CONNECTION
|
||||||
aapsLogger.debug(LTag.PUMPCOMM, "New message")
|
aapsLogger.debug(LTag.PUMPCOMM, "New message")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
||||||
|
|
||||||
import com.cozmo.danar.util.BleCommandUtil
|
import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.logging.LTag
|
import info.nightscout.androidaps.logging.LTag
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ class DanaRS_Packet_Etc_Set_History_Save(
|
||||||
|
|
||||||
|
|
||||||
init {
|
init {
|
||||||
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_ETC__SET_HISTORY_SAVE
|
opCode = BleEncryption.DANAR_PACKET__OPCODE_ETC__SET_HISTORY_SAVE
|
||||||
aapsLogger.debug(LTag.PUMPCOMM, "New message")
|
aapsLogger.debug(LTag.PUMPCOMM, "New message")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
||||||
|
|
||||||
import com.cozmo.danar.util.BleCommandUtil
|
import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.logging.LTag
|
import info.nightscout.androidaps.logging.LTag
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ class DanaRS_Packet_General_Delivery_Status(
|
||||||
) : DanaRS_Packet() {
|
) : DanaRS_Packet() {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__DELIVERY_STATUS
|
opCode = BleEncryption.DANAR_PACKET__OPCODE_REVIEW__DELIVERY_STATUS
|
||||||
aapsLogger.debug(LTag.PUMPCOMM, "New message")
|
aapsLogger.debug(LTag.PUMPCOMM, "New message")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
||||||
|
|
||||||
import com.cozmo.danar.util.BleCommandUtil
|
import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.logging.LTag
|
import info.nightscout.androidaps.logging.LTag
|
||||||
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump
|
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump
|
||||||
|
@ -13,7 +13,7 @@ class DanaRS_Packet_General_Get_More_Information(
|
||||||
) : DanaRS_Packet() {
|
) : DanaRS_Packet() {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__GET_MORE_INFORMATION
|
opCode = BleEncryption.DANAR_PACKET__OPCODE_REVIEW__GET_MORE_INFORMATION
|
||||||
aapsLogger.debug(LTag.PUMPCOMM, "New message")
|
aapsLogger.debug(LTag.PUMPCOMM, "New message")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
||||||
|
|
||||||
import com.cozmo.danar.util.BleCommandUtil
|
import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.logging.LTag
|
import info.nightscout.androidaps.logging.LTag
|
||||||
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump
|
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump
|
||||||
|
@ -11,7 +11,7 @@ class DanaRS_Packet_General_Get_Password(
|
||||||
) : DanaRS_Packet() {
|
) : DanaRS_Packet() {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__GET_PASSWORD
|
opCode = BleEncryption.DANAR_PACKET__OPCODE_REVIEW__GET_PASSWORD
|
||||||
aapsLogger.debug(LTag.PUMPCOMM, "New message")
|
aapsLogger.debug(LTag.PUMPCOMM, "New message")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
||||||
|
|
||||||
import com.cozmo.danar.util.BleCommandUtil
|
import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption
|
||||||
import info.nightscout.androidaps.R
|
import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.logging.LTag
|
import info.nightscout.androidaps.logging.LTag
|
||||||
|
@ -18,7 +18,7 @@ class DanaRS_Packet_General_Get_Pump_Check(
|
||||||
) : DanaRS_Packet() {
|
) : DanaRS_Packet() {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__GET_PUMP_CHECK
|
opCode = BleEncryption.DANAR_PACKET__OPCODE_REVIEW__GET_PUMP_CHECK
|
||||||
aapsLogger.debug(LTag.PUMPCOMM, "New message")
|
aapsLogger.debug(LTag.PUMPCOMM, "New message")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
||||||
|
|
||||||
import com.cozmo.danar.util.BleCommandUtil
|
import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.logging.LTag
|
import info.nightscout.androidaps.logging.LTag
|
||||||
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump
|
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump
|
||||||
|
@ -12,7 +12,7 @@ class DanaRS_Packet_General_Get_Shipping_Information(
|
||||||
) : DanaRS_Packet() {
|
) : DanaRS_Packet() {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__GET_SHIPPING_INFORMATION
|
opCode = BleEncryption.DANAR_PACKET__OPCODE_REVIEW__GET_SHIPPING_INFORMATION
|
||||||
aapsLogger.debug(LTag.PUMPCOMM, "New message")
|
aapsLogger.debug(LTag.PUMPCOMM, "New message")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
||||||
|
|
||||||
import com.cozmo.danar.util.BleCommandUtil
|
import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.logging.LTag
|
import info.nightscout.androidaps.logging.LTag
|
||||||
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump
|
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump
|
||||||
|
@ -11,7 +11,7 @@ class DanaRS_Packet_General_Get_Today_Delivery_Total(
|
||||||
) : DanaRS_Packet() {
|
) : DanaRS_Packet() {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__GET_TODAY_DELIVERY_TOTAL
|
opCode = BleEncryption.DANAR_PACKET__OPCODE_REVIEW__GET_TODAY_DELIVERY_TOTAL
|
||||||
aapsLogger.debug(LTag.PUMPCOMM, "New message")
|
aapsLogger.debug(LTag.PUMPCOMM, "New message")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
||||||
|
|
||||||
import com.cozmo.danar.util.BleCommandUtil
|
import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.logging.LTag
|
import info.nightscout.androidaps.logging.LTag
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ class DanaRS_Packet_General_Get_User_Time_Change_Flag(
|
||||||
) : DanaRS_Packet() {
|
) : DanaRS_Packet() {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__GET_USER_TIME_CHANGE_FLAG
|
opCode = BleEncryption.DANAR_PACKET__OPCODE_REVIEW__GET_USER_TIME_CHANGE_FLAG
|
||||||
aapsLogger.debug(LTag.PUMPCOMM, "New message")
|
aapsLogger.debug(LTag.PUMPCOMM, "New message")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
||||||
|
|
||||||
import com.cozmo.danar.util.BleCommandUtil
|
import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.logging.LTag
|
import info.nightscout.androidaps.logging.LTag
|
||||||
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump
|
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump
|
||||||
|
@ -11,8 +11,8 @@ class DanaRS_Packet_General_Initial_Screen_Information(
|
||||||
) : DanaRS_Packet() {
|
) : DanaRS_Packet() {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
type = BleCommandUtil.DANAR_PACKET__TYPE_RESPONSE
|
type = BleEncryption.DANAR_PACKET__TYPE_RESPONSE
|
||||||
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__INITIAL_SCREEN_INFORMATION
|
opCode = BleEncryption.DANAR_PACKET__OPCODE_REVIEW__INITIAL_SCREEN_INFORMATION
|
||||||
aapsLogger.debug(LTag.PUMPCOMM, "New message")
|
aapsLogger.debug(LTag.PUMPCOMM, "New message")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
||||||
|
|
||||||
import com.cozmo.danar.util.BleCommandUtil
|
import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.logging.LTag
|
import info.nightscout.androidaps.logging.LTag
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ class DanaRS_Packet_General_Set_History_Upload_Mode(
|
||||||
) : DanaRS_Packet() {
|
) : DanaRS_Packet() {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__SET_HISTORY_UPLOAD_MODE
|
opCode = BleEncryption.DANAR_PACKET__OPCODE_REVIEW__SET_HISTORY_UPLOAD_MODE
|
||||||
aapsLogger.debug(LTag.PUMPCOMM, "New message: mode: $mode")
|
aapsLogger.debug(LTag.PUMPCOMM, "New message: mode: $mode")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,18 +1,15 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
||||||
|
|
||||||
import com.cozmo.danar.util.BleCommandUtil
|
import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.logging.L
|
|
||||||
import info.nightscout.androidaps.logging.L.isEnabled
|
|
||||||
import info.nightscout.androidaps.logging.LTag
|
import info.nightscout.androidaps.logging.LTag
|
||||||
import org.slf4j.LoggerFactory
|
|
||||||
|
|
||||||
class DanaRS_Packet_General_Set_User_Time_Change_Flag_Clear(
|
class DanaRS_Packet_General_Set_User_Time_Change_Flag_Clear(
|
||||||
private val aapsLogger: AAPSLogger
|
private val aapsLogger: AAPSLogger
|
||||||
) : DanaRS_Packet() {
|
) : DanaRS_Packet() {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__SET_USER_TIME_CHANGE_FLAG_CLEAR
|
opCode = BleEncryption.DANAR_PACKET__OPCODE_REVIEW__SET_USER_TIME_CHANGE_FLAG_CLEAR
|
||||||
aapsLogger.debug(LTag.PUMPCOMM, "New message")
|
aapsLogger.debug(LTag.PUMPCOMM, "New message")
|
||||||
}
|
}
|
||||||
override fun handleMessage(data: ByteArray) {
|
override fun handleMessage(data: ByteArray) {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
||||||
|
|
||||||
import com.cozmo.danar.util.BleCommandUtil
|
import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.logging.LTag
|
import info.nightscout.androidaps.logging.LTag
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
|
@ -12,7 +12,7 @@ class DanaRS_Packet_History_Alarm @JvmOverloads constructor(
|
||||||
) : DanaRS_Packet_History_(aapsLogger, rxBus, from) {
|
) : DanaRS_Packet_History_(aapsLogger, rxBus, from) {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__ALARM
|
opCode = BleEncryption.DANAR_PACKET__OPCODE_REVIEW__ALARM
|
||||||
aapsLogger.debug(LTag.PUMPCOMM, "New message")
|
aapsLogger.debug(LTag.PUMPCOMM, "New message")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
||||||
|
|
||||||
import com.cozmo.danar.util.BleCommandUtil
|
import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.logging.LTag
|
import info.nightscout.androidaps.logging.LTag
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
|
@ -12,7 +12,7 @@ class DanaRS_Packet_History_All_History(
|
||||||
) : DanaRS_Packet_History_(aapsLogger, rxBus, from) {
|
) : DanaRS_Packet_History_(aapsLogger, rxBus, from) {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__ALL_HISTORY
|
opCode = BleEncryption.DANAR_PACKET__OPCODE_REVIEW__ALL_HISTORY
|
||||||
aapsLogger.debug(LTag.PUMPCOMM, "New message")
|
aapsLogger.debug(LTag.PUMPCOMM, "New message")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
||||||
|
|
||||||
import com.cozmo.danar.util.BleCommandUtil
|
import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.logging.LTag
|
import info.nightscout.androidaps.logging.LTag
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
|
@ -12,7 +12,7 @@ class DanaRS_Packet_History_Basal @JvmOverloads constructor(
|
||||||
) : DanaRS_Packet_History_(aapsLogger, rxBus, from) {
|
) : DanaRS_Packet_History_(aapsLogger, rxBus, from) {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__BASAL
|
opCode = BleEncryption.DANAR_PACKET__OPCODE_REVIEW__BASAL
|
||||||
aapsLogger.debug(LTag.PUMPCOMM, "New message")
|
aapsLogger.debug(LTag.PUMPCOMM, "New message")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
||||||
|
|
||||||
import com.cozmo.danar.util.BleCommandUtil
|
import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.logging.LTag
|
import info.nightscout.androidaps.logging.LTag
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
|
@ -12,7 +12,7 @@ class DanaRS_Packet_History_Blood_Glucose @JvmOverloads constructor(
|
||||||
) : DanaRS_Packet_History_(aapsLogger, rxBus, from) {
|
) : DanaRS_Packet_History_(aapsLogger, rxBus, from) {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__BLOOD_GLUCOSE
|
opCode = BleEncryption.DANAR_PACKET__OPCODE_REVIEW__BLOOD_GLUCOSE
|
||||||
aapsLogger.debug(LTag.PUMPCOMM, "New message")
|
aapsLogger.debug(LTag.PUMPCOMM, "New message")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
||||||
|
|
||||||
import com.cozmo.danar.util.BleCommandUtil
|
import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.logging.LTag
|
import info.nightscout.androidaps.logging.LTag
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
|
@ -12,7 +12,7 @@ class DanaRS_Packet_History_Bolus @JvmOverloads constructor(
|
||||||
) : DanaRS_Packet_History_(aapsLogger, rxBus, from) {
|
) : DanaRS_Packet_History_(aapsLogger, rxBus, from) {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__BOLUS
|
opCode = BleEncryption.DANAR_PACKET__OPCODE_REVIEW__BOLUS
|
||||||
aapsLogger.debug(LTag.PUMPCOMM, "New message")
|
aapsLogger.debug(LTag.PUMPCOMM, "New message")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
||||||
|
|
||||||
import com.cozmo.danar.util.BleCommandUtil
|
import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.logging.LTag
|
import info.nightscout.androidaps.logging.LTag
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
|
@ -12,7 +12,7 @@ class DanaRS_Packet_History_Carbohydrate @JvmOverloads constructor(
|
||||||
) : DanaRS_Packet_History_(aapsLogger, rxBus, from) {
|
) : DanaRS_Packet_History_(aapsLogger, rxBus, from) {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__CARBOHYDRATE
|
opCode = BleEncryption.DANAR_PACKET__OPCODE_REVIEW__CARBOHYDRATE
|
||||||
aapsLogger.debug(LTag.PUMPCOMM, "New message")
|
aapsLogger.debug(LTag.PUMPCOMM, "New message")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
||||||
|
|
||||||
import com.cozmo.danar.util.BleCommandUtil
|
import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.logging.LTag
|
import info.nightscout.androidaps.logging.LTag
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
|
@ -12,7 +12,7 @@ class DanaRS_Packet_History_Daily @JvmOverloads constructor(
|
||||||
) : DanaRS_Packet_History_(aapsLogger, rxBus, from) {
|
) : DanaRS_Packet_History_(aapsLogger, rxBus, from) {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__DAILY
|
opCode = BleEncryption.DANAR_PACKET__OPCODE_REVIEW__DAILY
|
||||||
aapsLogger.debug(LTag.PUMPCOMM, "New message")
|
aapsLogger.debug(LTag.PUMPCOMM, "New message")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
||||||
|
|
||||||
import com.cozmo.danar.util.BleCommandUtil
|
import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.logging.LTag
|
import info.nightscout.androidaps.logging.LTag
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
|
@ -12,7 +12,7 @@ class DanaRS_Packet_History_Prime @JvmOverloads constructor(
|
||||||
) : DanaRS_Packet_History_(aapsLogger, rxBus, from) {
|
) : DanaRS_Packet_History_(aapsLogger, rxBus, from) {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__PRIME
|
opCode = BleEncryption.DANAR_PACKET__OPCODE_REVIEW__PRIME
|
||||||
aapsLogger.debug(LTag.PUMPCOMM, "New message")
|
aapsLogger.debug(LTag.PUMPCOMM, "New message")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
||||||
|
|
||||||
import com.cozmo.danar.util.BleCommandUtil
|
import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.logging.LTag
|
import info.nightscout.androidaps.logging.LTag
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
|
@ -12,7 +12,7 @@ class DanaRS_Packet_History_Refill @JvmOverloads constructor(
|
||||||
) : DanaRS_Packet_History_(aapsLogger, rxBus, from) {
|
) : DanaRS_Packet_History_(aapsLogger, rxBus, from) {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__REFILL
|
opCode = BleEncryption.DANAR_PACKET__OPCODE_REVIEW__REFILL
|
||||||
aapsLogger.debug(LTag.PUMPCOMM, "New message")
|
aapsLogger.debug(LTag.PUMPCOMM, "New message")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
||||||
|
|
||||||
import com.cozmo.danar.util.BleCommandUtil
|
import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.logging.LTag
|
import info.nightscout.androidaps.logging.LTag
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
|
@ -12,7 +12,7 @@ class DanaRS_Packet_History_Suspend @JvmOverloads constructor(
|
||||||
) : DanaRS_Packet_History_(aapsLogger, rxBus, from) {
|
) : DanaRS_Packet_History_(aapsLogger, rxBus, from) {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__SUSPEND
|
opCode = BleEncryption.DANAR_PACKET__OPCODE_REVIEW__SUSPEND
|
||||||
aapsLogger.debug(LTag.PUMPCOMM, "New message")
|
aapsLogger.debug(LTag.PUMPCOMM, "New message")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
||||||
|
|
||||||
import com.cozmo.danar.util.BleCommandUtil
|
import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.logging.LTag
|
import info.nightscout.androidaps.logging.LTag
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
|
@ -12,7 +12,7 @@ class DanaRS_Packet_History_Temporary(
|
||||||
) : DanaRS_Packet_History_(aapsLogger, rxBus, from) {
|
) : DanaRS_Packet_History_(aapsLogger, rxBus, from) {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__TEMPORARY
|
opCode = BleEncryption.DANAR_PACKET__OPCODE_REVIEW__TEMPORARY
|
||||||
aapsLogger.debug(LTag.PUMPCOMM, "New message")
|
aapsLogger.debug(LTag.PUMPCOMM, "New message")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
||||||
|
|
||||||
import com.cozmo.danar.util.BleCommandUtil
|
import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption
|
||||||
import info.nightscout.androidaps.R
|
import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.logging.LTag
|
import info.nightscout.androidaps.logging.LTag
|
||||||
|
@ -13,8 +13,8 @@ class DanaRS_Packet_Notify_Alarm(
|
||||||
) : DanaRS_Packet() {
|
) : DanaRS_Packet() {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
type = BleCommandUtil.DANAR_PACKET__TYPE_NOTIFY
|
type = BleEncryption.DANAR_PACKET__TYPE_NOTIFY
|
||||||
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_NOTIFY__ALARM
|
opCode = BleEncryption.DANAR_PACKET__OPCODE_NOTIFY__ALARM
|
||||||
aapsLogger.debug(LTag.PUMPCOMM, "New message")
|
aapsLogger.debug(LTag.PUMPCOMM, "New message")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
||||||
|
|
||||||
import com.cozmo.danar.util.BleCommandUtil
|
import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption
|
||||||
import info.nightscout.androidaps.R
|
import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.logging.LTag
|
import info.nightscout.androidaps.logging.LTag
|
||||||
|
@ -18,8 +18,8 @@ class DanaRS_Packet_Notify_Delivery_Complete(
|
||||||
) : DanaRS_Packet() {
|
) : DanaRS_Packet() {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
type = BleCommandUtil.DANAR_PACKET__TYPE_NOTIFY
|
type = BleEncryption.DANAR_PACKET__TYPE_NOTIFY
|
||||||
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_NOTIFY__DELIVERY_COMPLETE
|
opCode = BleEncryption.DANAR_PACKET__OPCODE_NOTIFY__DELIVERY_COMPLETE
|
||||||
aapsLogger.debug(LTag.PUMPCOMM, "New message")
|
aapsLogger.debug(LTag.PUMPCOMM, "New message")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
||||||
|
|
||||||
import com.cozmo.danar.util.BleCommandUtil
|
import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption
|
||||||
import info.nightscout.androidaps.R
|
import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.logging.LTag
|
import info.nightscout.androidaps.logging.LTag
|
||||||
|
@ -19,8 +19,8 @@ class DanaRS_Packet_Notify_Delivery_Rate_Display(
|
||||||
|
|
||||||
|
|
||||||
init {
|
init {
|
||||||
type = BleCommandUtil.DANAR_PACKET__TYPE_NOTIFY
|
type = BleEncryption.DANAR_PACKET__TYPE_NOTIFY
|
||||||
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_NOTIFY__DELIVERY_RATE_DISPLAY
|
opCode = BleEncryption.DANAR_PACKET__OPCODE_NOTIFY__DELIVERY_RATE_DISPLAY
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun handleMessage(data: ByteArray) {
|
override fun handleMessage(data: ByteArray) {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
||||||
|
|
||||||
import com.cozmo.danar.util.BleCommandUtil
|
import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.logging.LTag
|
import info.nightscout.androidaps.logging.LTag
|
||||||
|
|
||||||
|
@ -9,8 +9,8 @@ class DanaRS_Packet_Notify_Missed_Bolus_Alarm(
|
||||||
) : DanaRS_Packet() {
|
) : DanaRS_Packet() {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
type = BleCommandUtil.DANAR_PACKET__TYPE_NOTIFY
|
type = BleEncryption.DANAR_PACKET__TYPE_NOTIFY
|
||||||
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_NOTIFY__MISSED_BOLUS_ALARM
|
opCode = BleEncryption.DANAR_PACKET__OPCODE_NOTIFY__MISSED_BOLUS_ALARM
|
||||||
aapsLogger.debug(LTag.PUMPCOMM, "New message")
|
aapsLogger.debug(LTag.PUMPCOMM, "New message")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
||||||
|
|
||||||
import com.cozmo.danar.util.BleCommandUtil
|
import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.logging.LTag
|
import info.nightscout.androidaps.logging.LTag
|
||||||
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump
|
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump
|
||||||
|
@ -13,7 +13,7 @@ class DanaRS_Packet_Option_Get_Pump_Time(
|
||||||
) : DanaRS_Packet() {
|
) : DanaRS_Packet() {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_OPTION__GET_PUMP_TIME
|
opCode = BleEncryption.DANAR_PACKET__OPCODE_OPTION__GET_PUMP_TIME
|
||||||
aapsLogger.debug(LTag.PUMPCOMM, "Requesting pump time")
|
aapsLogger.debug(LTag.PUMPCOMM, "Requesting pump time")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
||||||
|
|
||||||
import com.cozmo.danar.util.BleCommandUtil
|
import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.logging.LTag
|
import info.nightscout.androidaps.logging.LTag
|
||||||
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump
|
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump
|
||||||
|
@ -11,7 +11,7 @@ class DanaRS_Packet_Option_Get_User_Option(
|
||||||
) : DanaRS_Packet() {
|
) : DanaRS_Packet() {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_OPTION__GET_USER_OPTION
|
opCode = BleEncryption.DANAR_PACKET__OPCODE_OPTION__GET_USER_OPTION
|
||||||
aapsLogger.debug(LTag.PUMPCOMM, "Requesting user settings")
|
aapsLogger.debug(LTag.PUMPCOMM, "Requesting user settings")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
||||||
|
|
||||||
import com.cozmo.danar.util.BleCommandUtil
|
import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.logging.LTag
|
import info.nightscout.androidaps.logging.LTag
|
||||||
import info.nightscout.androidaps.utils.DateUtil
|
import info.nightscout.androidaps.utils.DateUtil
|
||||||
|
@ -14,7 +14,7 @@ class DanaRS_Packet_Option_Set_Pump_Time(
|
||||||
var error = 0
|
var error = 0
|
||||||
|
|
||||||
init {
|
init {
|
||||||
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_OPTION__SET_PUMP_TIME
|
opCode = BleEncryption.DANAR_PACKET__OPCODE_OPTION__SET_PUMP_TIME
|
||||||
aapsLogger.debug(LTag.PUMPCOMM, "Setting pump time " + DateUtil.dateAndTimeString(time))
|
aapsLogger.debug(LTag.PUMPCOMM, "Setting pump time " + DateUtil.dateAndTimeString(time))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
||||||
|
|
||||||
import com.cozmo.danar.util.BleCommandUtil
|
import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.logging.LTag
|
import info.nightscout.androidaps.logging.LTag
|
||||||
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump
|
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump
|
||||||
|
@ -12,7 +12,7 @@ class DanaRS_Packet_Option_Set_User_Option(
|
||||||
|
|
||||||
|
|
||||||
init {
|
init {
|
||||||
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_OPTION__SET_USER_OPTION
|
opCode = BleEncryption.DANAR_PACKET__OPCODE_OPTION__SET_USER_OPTION
|
||||||
aapsLogger.debug(LTag.PUMPCOMM, "Setting user settings")
|
aapsLogger.debug(LTag.PUMPCOMM, "Setting user settings")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
||||||
|
|
||||||
import com.cozmo.danar.util.BleCommandUtil
|
import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.logging.LTag
|
import info.nightscout.androidaps.logging.LTag
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ class DanaRS_Packet_Review_Bolus_Avg(
|
||||||
) : DanaRS_Packet() {
|
) : DanaRS_Packet() {
|
||||||
|
|
||||||
init {
|
init {
|
||||||
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_REVIEW__BOLUS_AVG
|
opCode = BleEncryption.DANAR_PACKET__OPCODE_REVIEW__BOLUS_AVG
|
||||||
aapsLogger.debug(LTag.PUMPCOMM, "New message")
|
aapsLogger.debug(LTag.PUMPCOMM, "New message")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,18 @@
|
||||||
package com.cozmo.danar.util;
|
package info.nightscout.androidaps.plugins.pump.danaRS.encryption;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
|
||||||
import info.nightscout.androidaps.MainApp;
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
|
@Singleton
|
||||||
|
public class BleEncryption {
|
||||||
|
private Context context;
|
||||||
|
|
||||||
|
@Inject BleEncryption(Context context) {
|
||||||
|
this.context = context;
|
||||||
|
}
|
||||||
|
|
||||||
public class BleCommandUtil {
|
|
||||||
public static final int DANAR_PACKET__TYPE_ENCRYPTION_REQUEST = 0x01;
|
public static final int DANAR_PACKET__TYPE_ENCRYPTION_REQUEST = 0x01;
|
||||||
public static final int DANAR_PACKET__TYPE_ENCRYPTION_RESPONSE = 0x02;
|
public static final int DANAR_PACKET__TYPE_ENCRYPTION_RESPONSE = 0x02;
|
||||||
public static final int DANAR_PACKET__TYPE_COMMAND = 0xA1;
|
public static final int DANAR_PACKET__TYPE_COMMAND = 0xA1;
|
||||||
|
@ -12,10 +20,13 @@ public class BleCommandUtil {
|
||||||
public static final int DANAR_PACKET__TYPE_NOTIFY = 0xC3;
|
public static final int DANAR_PACKET__TYPE_NOTIFY = 0xC3;
|
||||||
|
|
||||||
public static final int DANAR_PACKET__OPCODE_ENCRYPTION__PUMP_CHECK = 0x00;
|
public static final int DANAR_PACKET__OPCODE_ENCRYPTION__PUMP_CHECK = 0x00;
|
||||||
|
public static final int DANAR_PACKET__OPCODE_ENCRYPTION__TIME_INFORMATION = 0x01;
|
||||||
public static final int DANAR_PACKET__OPCODE_ENCRYPTION__CHECK_PASSKEY = 0xD0;
|
public static final int DANAR_PACKET__OPCODE_ENCRYPTION__CHECK_PASSKEY = 0xD0;
|
||||||
public static final int DANAR_PACKET__OPCODE_ENCRYPTION__PASSKEY_REQUEST = 0xD1;
|
public static final int DANAR_PACKET__OPCODE_ENCRYPTION__PASSKEY_REQUEST = 0xD1;
|
||||||
public static final int DANAR_PACKET__OPCODE_ENCRYPTION__PASSKEY_RETURN = 0xD2;
|
public static final int DANAR_PACKET__OPCODE_ENCRYPTION__PASSKEY_RETURN = 0xD2;
|
||||||
public static final int DANAR_PACKET__OPCODE_ENCRYPTION__TIME_INFORMATION = 0x01;
|
// Easy Mode
|
||||||
|
public static final int DANAR_PACKET__OPCODE_ENCRYPTION__GET_PUMP_CHECK = 0xF3;
|
||||||
|
public static final int DANAR_PACKET__OPCODE_ENCRYPTION__GET_EASYMENU_CHECK = 0xF4;
|
||||||
|
|
||||||
public static final int DANAR_PACKET__OPCODE_NOTIFY__DELIVERY_COMPLETE = 0x01;
|
public static final int DANAR_PACKET__OPCODE_NOTIFY__DELIVERY_COMPLETE = 0x01;
|
||||||
public static final int DANAR_PACKET__OPCODE_NOTIFY__DELIVERY_RATE_DISPLAY = 0x02;
|
public static final int DANAR_PACKET__OPCODE_NOTIFY__DELIVERY_RATE_DISPLAY = 0x02;
|
||||||
|
@ -86,35 +97,50 @@ public class BleCommandUtil {
|
||||||
public static final int DANAR_PACKET__OPCODE__APS_HISTORY_EVENTS = 0xC2;
|
public static final int DANAR_PACKET__OPCODE__APS_HISTORY_EVENTS = 0xC2;
|
||||||
public static final int DANAR_PACKET__OPCODE__APS_SET_EVENT_HISTORY = 0xC3;
|
public static final int DANAR_PACKET__OPCODE__APS_SET_EVENT_HISTORY = 0xC3;
|
||||||
|
|
||||||
|
// Easy Mode
|
||||||
|
public static final int DANAR_PACKET__OPCODE_OPTION__GET_EASY_MENU_OPTION = 0x74;
|
||||||
|
public static final int DANAR_PACKET__OPCODE_OPTION__SET_EASY_MENU_OPTION = 0x75;
|
||||||
|
|
||||||
public static final int DANAR_PACKET__OPCODE_ETC__SET_HISTORY_SAVE = 0xE0;
|
public static final int DANAR_PACKET__OPCODE_ETC__SET_HISTORY_SAVE = 0xE0;
|
||||||
public static final int DANAR_PACKET__OPCODE_ETC__KEEP_CONNECTION = 0xFF;
|
public static final int DANAR_PACKET__OPCODE_ETC__KEEP_CONNECTION = 0xFF;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
System.loadLibrary("BleCommandUtil");
|
System.loadLibrary("BleEncryption");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static native byte[] getEncryptedPacketJni(Object context, int opcode, byte[] bytes, String deviceName);
|
private static native byte[] encryptPacketJni(Object context, int opcode, byte[] bytes, String deviceName);
|
||||||
|
|
||||||
private static native byte[] getDecryptedPacketJni(Object context, byte[] bytes);
|
private static native byte[] decryptPacketJni(Object context, byte[] bytes);
|
||||||
|
|
||||||
// ---------------------------------------------------------
|
private static native void setPairingKeysJni(byte[] pairingKey, byte[] randomPairingKey, byte randomSyncKey);
|
||||||
|
|
||||||
private static BleCommandUtil mInstance = null;
|
private static native void setEnhancedEncryptionJni(boolean isSecurityVersion);
|
||||||
|
|
||||||
public static BleCommandUtil getInstance() {
|
private static native byte[] encryptSecondLevelPacketJni(Object context, byte[] bytes);
|
||||||
if (mInstance == null) {
|
|
||||||
mInstance = new BleCommandUtil();
|
|
||||||
}
|
|
||||||
return mInstance;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---------------------------------------------------------
|
private static native byte[] decryptSecondLevelPacketJni(Object context, byte[] bytes);
|
||||||
|
|
||||||
public byte[] getEncryptedPacket(int opcode, byte[] bytes, String deviceName) {
|
public byte[] getEncryptedPacket(int opcode, byte[] bytes, String deviceName) {
|
||||||
return getEncryptedPacketJni(MainApp.instance().getApplicationContext(), opcode, bytes, deviceName);
|
return encryptPacketJni(context, opcode, bytes, deviceName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte[] getDecryptedPacket(byte[] bytes) {
|
public byte[] getDecryptedPacket(byte[] bytes) {
|
||||||
return getDecryptedPacketJni(MainApp.instance().getApplicationContext(), bytes);
|
return decryptPacketJni(context, bytes);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPairingKeys(byte[] pairingKey, byte[] randomPairingKey, byte randomSyncKey) {
|
||||||
|
setPairingKeysJni(pairingKey, randomPairingKey, randomSyncKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEnhancedEncryption(boolean isSecureVersion) {
|
||||||
|
setEnhancedEncryptionJni(isSecureVersion);
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte[] encryptSecondLevelPacket(byte[] bytes) {
|
||||||
|
return encryptSecondLevelPacketJni(context, bytes);
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte[] ecryptSecondLevelPacket(byte[] bytes) {
|
||||||
|
return decryptSecondLevelPacketJni(context, bytes);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,681 +0,0 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaRS.services;
|
|
||||||
|
|
||||||
import android.bluetooth.BluetoothAdapter;
|
|
||||||
import android.bluetooth.BluetoothDevice;
|
|
||||||
import android.bluetooth.BluetoothGatt;
|
|
||||||
import android.bluetooth.BluetoothGattCallback;
|
|
||||||
import android.bluetooth.BluetoothGattCharacteristic;
|
|
||||||
import android.bluetooth.BluetoothGattService;
|
|
||||||
import android.bluetooth.BluetoothManager;
|
|
||||||
import android.bluetooth.BluetoothProfile;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.os.SystemClock;
|
|
||||||
|
|
||||||
import com.cozmo.danar.util.BleCommandUtil;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.UUID;
|
|
||||||
import java.util.concurrent.ScheduledFuture;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.MainApp;
|
|
||||||
import info.nightscout.androidaps.R;
|
|
||||||
import info.nightscout.androidaps.events.EventPumpStatusChanged;
|
|
||||||
import info.nightscout.androidaps.logging.L;
|
|
||||||
import info.nightscout.androidaps.logging.StacktraceLoggerWrapper;
|
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBus;
|
|
||||||
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload;
|
|
||||||
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification;
|
|
||||||
import info.nightscout.androidaps.plugins.general.overview.notifications.Notification;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.danaRS.DanaRSPlugin;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.danaRS.activities.PairingHelperActivity;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.danaRS.comm.DanaRSMessageHashTable;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.danaRS.comm.DanaRS_Packet;
|
|
||||||
import info.nightscout.androidaps.plugins.pump.danaRS.events.EventDanaRSPairingSuccess;
|
|
||||||
import info.nightscout.androidaps.utils.SP;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by mike on 23.09.2017.
|
|
||||||
*/
|
|
||||||
|
|
||||||
public class BLEComm {
|
|
||||||
private Logger log = StacktraceLoggerWrapper.getLogger(L.PUMPBTCOMM);
|
|
||||||
|
|
||||||
private final long WRITE_DELAY_MILLIS = 50;
|
|
||||||
|
|
||||||
private String UART_READ_UUID = "0000fff1-0000-1000-8000-00805f9b34fb";
|
|
||||||
private String UART_WRITE_UUID = "0000fff2-0000-1000-8000-00805f9b34fb";
|
|
||||||
|
|
||||||
private final byte PACKET_START_BYTE = (byte) 0xA5;
|
|
||||||
private final byte PACKET_END_BYTE = (byte) 0x5A;
|
|
||||||
private Context context;
|
|
||||||
private DanaRPump danaRPump;
|
|
||||||
private DanaRSMessageHashTable danaRSMessageHashTable;
|
|
||||||
|
|
||||||
public BLEComm(Context context, DanaRSMessageHashTable danaRSMessageHashTable, DanaRPump danaRPump) {
|
|
||||||
this.context = context;
|
|
||||||
this.danaRPump = danaRPump;
|
|
||||||
this.danaRSMessageHashTable = danaRSMessageHashTable;
|
|
||||||
initialize();
|
|
||||||
}
|
|
||||||
|
|
||||||
private ScheduledFuture<?> scheduledDisconnection = null;
|
|
||||||
|
|
||||||
private DanaRS_Packet processsedMessage = null;
|
|
||||||
private final ArrayList<byte[]> mSendQueue = new ArrayList<>();
|
|
||||||
|
|
||||||
private BluetoothManager mBluetoothManager = null;
|
|
||||||
private BluetoothAdapter mBluetoothAdapter = null;
|
|
||||||
private String mBluetoothDeviceName = null;
|
|
||||||
private BluetoothGatt mBluetoothGatt = null;
|
|
||||||
|
|
||||||
protected boolean isConnected = false;
|
|
||||||
protected boolean isConnecting = false;
|
|
||||||
|
|
||||||
private BluetoothGattCharacteristic UART_Read;
|
|
||||||
private BluetoothGattCharacteristic UART_Write;
|
|
||||||
|
|
||||||
private boolean initialize() {
|
|
||||||
if (L.isEnabled(L.PUMPBTCOMM))
|
|
||||||
log.debug("Initializing BLEComm.");
|
|
||||||
|
|
||||||
if (mBluetoothManager == null) {
|
|
||||||
mBluetoothManager = ((BluetoothManager) MainApp.instance().getApplicationContext().getSystemService(Context.BLUETOOTH_SERVICE));
|
|
||||||
if (mBluetoothManager == null) {
|
|
||||||
log.error("Unable to initialize BluetoothManager.");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
mBluetoothAdapter = mBluetoothManager.getAdapter();
|
|
||||||
if (mBluetoothAdapter == null) {
|
|
||||||
log.error("Unable to obtain a BluetoothAdapter.");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isConnected() {
|
|
||||||
return isConnected;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isConnecting() {
|
|
||||||
return isConnecting;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean connect(String from, String address, Object confirmConnect) {
|
|
||||||
BluetoothManager tBluetoothManager = ((BluetoothManager) MainApp.instance().getApplicationContext().getSystemService(Context.BLUETOOTH_SERVICE));
|
|
||||||
if (tBluetoothManager == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
BluetoothAdapter tBluetoothAdapter = tBluetoothManager.getAdapter();
|
|
||||||
if (tBluetoothAdapter == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mBluetoothAdapter == null) {
|
|
||||||
if (!initialize()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (address == null) {
|
|
||||||
log.error("unspecified address.");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
isConnecting = true;
|
|
||||||
|
|
||||||
BluetoothDevice device = mBluetoothAdapter.getRemoteDevice(address);
|
|
||||||
if (device == null) {
|
|
||||||
log.error("Device not found. Unable to connect from: " + from);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (L.isEnabled(L.PUMPBTCOMM))
|
|
||||||
log.debug("Trying to create a new connection from: " + from);
|
|
||||||
mBluetoothDeviceName = device.getName();
|
|
||||||
mBluetoothGatt = device.connectGatt(context, false, mGattCallback);
|
|
||||||
setCharacteristicNotification(getUARTReadBTGattChar(), true);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void stopConnecting() {
|
|
||||||
isConnecting = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public synchronized void disconnect(String from) {
|
|
||||||
if (L.isEnabled(L.PUMPBTCOMM))
|
|
||||||
log.debug("disconnect from: " + from);
|
|
||||||
|
|
||||||
// cancel previous scheduled disconnection to prevent closing upcomming connection
|
|
||||||
if (scheduledDisconnection != null)
|
|
||||||
scheduledDisconnection.cancel(false);
|
|
||||||
scheduledDisconnection = null;
|
|
||||||
|
|
||||||
if ((mBluetoothAdapter == null) || (mBluetoothGatt == null)) {
|
|
||||||
log.error("disconnect not possible: (mBluetoothAdapter == null) " + (mBluetoothAdapter == null));
|
|
||||||
log.error("disconnect not possible: (mBluetoothGatt == null) " + (mBluetoothGatt == null));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
setCharacteristicNotification(getUARTReadBTGattChar(), false);
|
|
||||||
mBluetoothGatt.disconnect();
|
|
||||||
isConnected = false;
|
|
||||||
SystemClock.sleep(2000);
|
|
||||||
}
|
|
||||||
|
|
||||||
public synchronized void close() {
|
|
||||||
if (L.isEnabled(L.PUMPBTCOMM))
|
|
||||||
log.debug("BluetoothAdapter close");
|
|
||||||
if (mBluetoothGatt == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
mBluetoothGatt.close();
|
|
||||||
mBluetoothGatt = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private String getConnectDeviceName() {
|
|
||||||
return mBluetoothDeviceName;
|
|
||||||
}
|
|
||||||
|
|
||||||
private final BluetoothGattCallback mGattCallback = new BluetoothGattCallback() {
|
|
||||||
public void onConnectionStateChange(BluetoothGatt gatt, int status, int newState) {
|
|
||||||
onConnectionStateChangeSynchronized(gatt, status, newState); // call it synchronized
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onServicesDiscovered(BluetoothGatt gatt, int status) {
|
|
||||||
if (L.isEnabled(L.PUMPBTCOMM))
|
|
||||||
log.debug("onServicesDiscovered");
|
|
||||||
if (status == BluetoothGatt.GATT_SUCCESS) {
|
|
||||||
findCharacteristic();
|
|
||||||
}
|
|
||||||
SendPumpCheck();
|
|
||||||
// 1st message sent to pump after connect
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onCharacteristicRead(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, int status) {
|
|
||||||
if (L.isEnabled(L.PUMPBTCOMM))
|
|
||||||
log.debug("onCharacteristicRead" + (characteristic != null ? ":" + DanaRS_Packet.toHexString(characteristic.getValue()) : ""));
|
|
||||||
addToReadBuffer(characteristic.getValue());
|
|
||||||
readDataParsing();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onCharacteristicChanged(BluetoothGatt gatt, final BluetoothGattCharacteristic characteristic) {
|
|
||||||
if (L.isEnabled(L.PUMPBTCOMM))
|
|
||||||
log.debug("onCharacteristicChanged" + (characteristic != null ? ":" + DanaRS_Packet.toHexString(characteristic.getValue()) : ""));
|
|
||||||
addToReadBuffer(characteristic.getValue());
|
|
||||||
new Thread(() -> readDataParsing()).start();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onCharacteristicWrite(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, int status) {
|
|
||||||
if (L.isEnabled(L.PUMPBTCOMM))
|
|
||||||
log.debug("onCharacteristicWrite" + (characteristic != null ? ":" + DanaRS_Packet.toHexString(characteristic.getValue()) : ""));
|
|
||||||
new Thread(() -> {
|
|
||||||
synchronized (mSendQueue) {
|
|
||||||
// after message sent, check if there is the rest of the message waiting and send it
|
|
||||||
if (mSendQueue.size() > 0) {
|
|
||||||
byte[] bytes = mSendQueue.get(0);
|
|
||||||
mSendQueue.remove(0);
|
|
||||||
writeCharacteristic_NO_RESPONSE(getUARTWriteBTGattChar(), bytes);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}).start();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
private synchronized void setCharacteristicNotification(BluetoothGattCharacteristic characteristic, boolean enabled) {
|
|
||||||
if (L.isEnabled(L.PUMPBTCOMM))
|
|
||||||
log.debug("setCharacteristicNotification");
|
|
||||||
if ((mBluetoothAdapter == null) || (mBluetoothGatt == null)) {
|
|
||||||
log.error("BluetoothAdapter not initialized_ERROR");
|
|
||||||
isConnecting = false;
|
|
||||||
isConnected = false;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
mBluetoothGatt.setCharacteristicNotification(characteristic, enabled);
|
|
||||||
}
|
|
||||||
|
|
||||||
public synchronized void readCharacteristic(BluetoothGattCharacteristic characteristic) {
|
|
||||||
if (L.isEnabled(L.PUMPBTCOMM))
|
|
||||||
log.debug("readCharacteristic");
|
|
||||||
if ((mBluetoothAdapter == null) || (mBluetoothGatt == null)) {
|
|
||||||
log.error("BluetoothAdapter not initialized_ERROR");
|
|
||||||
isConnecting = false;
|
|
||||||
isConnected = false;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
mBluetoothGatt.readCharacteristic(characteristic);
|
|
||||||
}
|
|
||||||
|
|
||||||
private synchronized void writeCharacteristic_NO_RESPONSE(final BluetoothGattCharacteristic characteristic, final byte[] data) {
|
|
||||||
new Thread(() -> {
|
|
||||||
SystemClock.sleep(WRITE_DELAY_MILLIS);
|
|
||||||
|
|
||||||
if ((mBluetoothAdapter == null) || (mBluetoothGatt == null)) {
|
|
||||||
log.error("BluetoothAdapter not initialized_ERROR");
|
|
||||||
isConnecting = false;
|
|
||||||
isConnected = false;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
characteristic.setValue(data);
|
|
||||||
characteristic.setWriteType(BluetoothGattCharacteristic.WRITE_TYPE_NO_RESPONSE);
|
|
||||||
if (L.isEnabled(L.PUMPBTCOMM))
|
|
||||||
log.debug("writeCharacteristic:" + DanaRS_Packet.toHexString(data));
|
|
||||||
mBluetoothGatt.writeCharacteristic(characteristic);
|
|
||||||
}).start();
|
|
||||||
}
|
|
||||||
|
|
||||||
private BluetoothGattCharacteristic getUARTReadBTGattChar() {
|
|
||||||
if (UART_Read == null) {
|
|
||||||
UART_Read = new BluetoothGattCharacteristic(UUID.fromString(UART_READ_UUID), BluetoothGattCharacteristic.PROPERTY_READ | BluetoothGattCharacteristic.PROPERTY_NOTIFY, 0);
|
|
||||||
}
|
|
||||||
return UART_Read;
|
|
||||||
}
|
|
||||||
|
|
||||||
private BluetoothGattCharacteristic getUARTWriteBTGattChar() {
|
|
||||||
if (UART_Write == null) {
|
|
||||||
UART_Write = new BluetoothGattCharacteristic(UUID.fromString(UART_WRITE_UUID), BluetoothGattCharacteristic.PROPERTY_WRITE_NO_RESPONSE, 0);
|
|
||||||
}
|
|
||||||
return UART_Write;
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<BluetoothGattService> getSupportedGattServices() {
|
|
||||||
if (L.isEnabled(L.PUMPBTCOMM))
|
|
||||||
log.debug("getSupportedGattServices");
|
|
||||||
if ((mBluetoothAdapter == null) || (mBluetoothGatt == null)) {
|
|
||||||
log.error("BluetoothAdapter not initialized_ERROR");
|
|
||||||
isConnecting = false;
|
|
||||||
isConnected = false;
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return mBluetoothGatt.getServices();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void findCharacteristic() {
|
|
||||||
List<BluetoothGattService> gattServices = getSupportedGattServices();
|
|
||||||
|
|
||||||
if (gattServices == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
String uuid;
|
|
||||||
|
|
||||||
for (BluetoothGattService gattService : gattServices) {
|
|
||||||
List<BluetoothGattCharacteristic> gattCharacteristics = gattService.getCharacteristics();
|
|
||||||
for (BluetoothGattCharacteristic gattCharacteristic : gattCharacteristics) {
|
|
||||||
uuid = gattCharacteristic.getUuid().toString();
|
|
||||||
if (UART_READ_UUID.equals(uuid)) {
|
|
||||||
UART_Read = gattCharacteristic;
|
|
||||||
setCharacteristicNotification(UART_Read, true);
|
|
||||||
}
|
|
||||||
if (UART_WRITE_UUID.equals(uuid)) {
|
|
||||||
UART_Write = gattCharacteristic;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private synchronized void onConnectionStateChangeSynchronized(BluetoothGatt gatt, int status, int newState) {
|
|
||||||
if (L.isEnabled(L.PUMPBTCOMM))
|
|
||||||
log.debug("onConnectionStateChange");
|
|
||||||
|
|
||||||
if (newState == BluetoothProfile.STATE_CONNECTED) {
|
|
||||||
mBluetoothGatt.discoverServices();
|
|
||||||
} else if (newState == BluetoothProfile.STATE_DISCONNECTED) {
|
|
||||||
close();
|
|
||||||
isConnected = false;
|
|
||||||
isConnecting = false;
|
|
||||||
RxBus.Companion.getINSTANCE().send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTED));
|
|
||||||
if (L.isEnabled(L.PUMPBTCOMM))
|
|
||||||
log.debug("Device was disconnected " + gatt.getDevice().getName());//Device was disconnected
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private final byte[] readBuffer = new byte[1024];
|
|
||||||
private int bufferLength = 0;
|
|
||||||
|
|
||||||
private void addToReadBuffer(byte[] buffer) {
|
|
||||||
//log.debug("addToReadBuffer " + DanaRS_Packet.toHexString(buffer));
|
|
||||||
if (buffer == null || buffer.length == 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
synchronized (readBuffer) {
|
|
||||||
// Append incomming data to input buffer
|
|
||||||
System.arraycopy(buffer, 0, readBuffer, bufferLength, buffer.length);
|
|
||||||
bufferLength += buffer.length;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void readDataParsing() {
|
|
||||||
boolean startSignatureFound = false, packetIsValid = false;
|
|
||||||
boolean isProcessing;
|
|
||||||
|
|
||||||
isProcessing = true;
|
|
||||||
|
|
||||||
while (isProcessing) {
|
|
||||||
int length = 0;
|
|
||||||
byte[] inputBuffer = null;
|
|
||||||
synchronized (readBuffer) {
|
|
||||||
// Find packet start [A5 A5]
|
|
||||||
if (bufferLength >= 6) {
|
|
||||||
for (int idxStartByte = 0; idxStartByte < bufferLength - 2; idxStartByte++) {
|
|
||||||
if ((readBuffer[idxStartByte] == PACKET_START_BYTE) && (readBuffer[idxStartByte + 1] == PACKET_START_BYTE)) {
|
|
||||||
if (idxStartByte > 0) {
|
|
||||||
// if buffer doesn't start with signature remove the leading trash
|
|
||||||
if (L.isEnabled(L.PUMPBTCOMM))
|
|
||||||
log.debug("Shifting the input buffer by " + idxStartByte + " bytes");
|
|
||||||
System.arraycopy(readBuffer, idxStartByte, readBuffer, 0, bufferLength - idxStartByte);
|
|
||||||
bufferLength -= idxStartByte;
|
|
||||||
}
|
|
||||||
startSignatureFound = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// A5 A5 LEN TYPE CODE PARAMS CHECKSUM1 CHECKSUM2 5A 5A
|
|
||||||
// ^---- LEN -----^
|
|
||||||
// total packet length 2 + 1 + readBuffer[2] + 2 + 2
|
|
||||||
if (startSignatureFound) {
|
|
||||||
length = readBuffer[2];
|
|
||||||
// test if there is enough data loaded
|
|
||||||
if (length + 7 > bufferLength)
|
|
||||||
return;
|
|
||||||
// Verify packed end [5A 5A]
|
|
||||||
if ((readBuffer[length + 5] == PACKET_END_BYTE) && (readBuffer[length + 6] == PACKET_END_BYTE)) {
|
|
||||||
packetIsValid = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (packetIsValid) {
|
|
||||||
inputBuffer = new byte[length + 7];
|
|
||||||
// copy packet to input buffer
|
|
||||||
System.arraycopy(readBuffer, 0, inputBuffer, 0, length + 7);
|
|
||||||
// Cut off the message from readBuffer
|
|
||||||
try {
|
|
||||||
System.arraycopy(readBuffer, length + 7, readBuffer, 0, bufferLength - (length + 7));
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error("length: " + length + "bufferLength: " + bufferLength);
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
bufferLength -= (length + 7);
|
|
||||||
// now we have encrypted packet in inputBuffer
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (packetIsValid) {
|
|
||||||
try {
|
|
||||||
// decrypt the packet
|
|
||||||
inputBuffer = BleCommandUtil.getInstance().getDecryptedPacket(inputBuffer);
|
|
||||||
|
|
||||||
if (inputBuffer == null) {
|
|
||||||
log.error("Null decryptedInputBuffer");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (inputBuffer[0]) {
|
|
||||||
// initial handshake packet
|
|
||||||
case (byte) BleCommandUtil.DANAR_PACKET__TYPE_ENCRYPTION_RESPONSE:
|
|
||||||
switch (inputBuffer[1]) {
|
|
||||||
// 1st packet
|
|
||||||
case (byte) BleCommandUtil.DANAR_PACKET__OPCODE_ENCRYPTION__PUMP_CHECK:
|
|
||||||
if (inputBuffer.length == 4 && inputBuffer[2] == 'O' && inputBuffer[3] == 'K') {
|
|
||||||
if (L.isEnabled(L.PUMPBTCOMM))
|
|
||||||
log.debug("<<<<< " + "ENCRYPTION__PUMP_CHECK (OK)" + " " + DanaRS_Packet.toHexString(inputBuffer));
|
|
||||||
// Grab pairing key from preferences if exists
|
|
||||||
String pairingKey = SP.getString(MainApp.gs(R.string.key_danars_pairingkey) + DanaRSPlugin.mDeviceName, null);
|
|
||||||
if (L.isEnabled(L.PUMPBTCOMM))
|
|
||||||
log.debug("Using stored pairing key: " + pairingKey);
|
|
||||||
if (pairingKey != null) {
|
|
||||||
byte[] encodedPairingKey = DanaRS_Packet.hexToBytes(pairingKey);
|
|
||||||
byte[] bytes = BleCommandUtil.getInstance().getEncryptedPacket(BleCommandUtil.DANAR_PACKET__OPCODE_ENCRYPTION__CHECK_PASSKEY, encodedPairingKey, null);
|
|
||||||
if (L.isEnabled(L.PUMPBTCOMM))
|
|
||||||
log.debug(">>>>> " + "ENCRYPTION__CHECK_PASSKEY" + " " + DanaRS_Packet.toHexString(bytes));
|
|
||||||
writeCharacteristic_NO_RESPONSE(getUARTWriteBTGattChar(), bytes);
|
|
||||||
} else {
|
|
||||||
// Stored pairing key does not exists, request pairing
|
|
||||||
SendPairingRequest();
|
|
||||||
}
|
|
||||||
|
|
||||||
} else if (inputBuffer.length == 6 && inputBuffer[2] == 'P' && inputBuffer[3] == 'U' && inputBuffer[4] == 'M' && inputBuffer[5] == 'P') {
|
|
||||||
if (L.isEnabled(L.PUMPBTCOMM))
|
|
||||||
log.debug("<<<<< " + "ENCRYPTION__PUMP_CHECK (PUMP)" + " " + DanaRS_Packet.toHexString(inputBuffer));
|
|
||||||
mSendQueue.clear();
|
|
||||||
RxBus.Companion.getINSTANCE().send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTED, MainApp.gs(R.string.pumperror)));
|
|
||||||
NSUpload.uploadError(MainApp.gs(R.string.pumperror));
|
|
||||||
Notification n = new Notification(Notification.PUMPERROR, MainApp.gs(R.string.pumperror), Notification.URGENT);
|
|
||||||
RxBus.Companion.getINSTANCE().send(new EventNewNotification(n));
|
|
||||||
} else if (inputBuffer.length == 6 && inputBuffer[2] == 'B' && inputBuffer[3] == 'U' && inputBuffer[4] == 'S' && inputBuffer[5] == 'Y') {
|
|
||||||
if (L.isEnabled(L.PUMPBTCOMM))
|
|
||||||
log.debug("<<<<< " + "ENCRYPTION__PUMP_CHECK (BUSY)" + " " + DanaRS_Packet.toHexString(inputBuffer));
|
|
||||||
mSendQueue.clear();
|
|
||||||
RxBus.Companion.getINSTANCE().send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTED, MainApp.gs(R.string.pumpbusy)));
|
|
||||||
} else {
|
|
||||||
// ERROR in response, wrong serial number
|
|
||||||
if (L.isEnabled(L.PUMPBTCOMM))
|
|
||||||
log.debug("<<<<< " + "ENCRYPTION__PUMP_CHECK (ERROR)" + " " + DanaRS_Packet.toHexString(inputBuffer));
|
|
||||||
mSendQueue.clear();
|
|
||||||
RxBus.Companion.getINSTANCE().send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTED, MainApp.gs(R.string.connectionerror)));
|
|
||||||
SP.remove(MainApp.gs(R.string.key_danars_pairingkey) + DanaRSPlugin.mDeviceName);
|
|
||||||
Notification n = new Notification(Notification.WRONGSERIALNUMBER, MainApp.gs(R.string.wrongpassword), Notification.URGENT);
|
|
||||||
RxBus.Companion.getINSTANCE().send(new EventNewNotification(n));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
// 2nd packet, pairing key
|
|
||||||
case (byte) BleCommandUtil.DANAR_PACKET__OPCODE_ENCRYPTION__CHECK_PASSKEY:
|
|
||||||
if (L.isEnabled(L.PUMPBTCOMM))
|
|
||||||
log.debug("<<<<< " + "ENCRYPTION__CHECK_PASSKEY" + " " + DanaRS_Packet.toHexString(inputBuffer));
|
|
||||||
if (inputBuffer[2] == (byte) 0x00) {
|
|
||||||
// Paring is not requested, sending time info
|
|
||||||
SendTimeInfo();
|
|
||||||
} else {
|
|
||||||
// Pairing on pump is requested
|
|
||||||
SendPairingRequest();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case (byte) BleCommandUtil.DANAR_PACKET__OPCODE_ENCRYPTION__PASSKEY_REQUEST:
|
|
||||||
if (L.isEnabled(L.PUMPBTCOMM))
|
|
||||||
log.debug("<<<<< " + "ENCRYPTION__PASSKEY_REQUEST " + DanaRS_Packet.toHexString(inputBuffer));
|
|
||||||
if (inputBuffer[2] != (byte) 0x00) {
|
|
||||||
disconnect("passkey request failed");
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
// Paring response, OK button on pump pressed
|
|
||||||
case (byte) BleCommandUtil.DANAR_PACKET__OPCODE_ENCRYPTION__PASSKEY_RETURN:
|
|
||||||
if (L.isEnabled(L.PUMPBTCOMM))
|
|
||||||
log.debug("<<<<< " + "ENCRYPTION__PASSKEY_RETURN " + DanaRS_Packet.toHexString(inputBuffer));
|
|
||||||
// Paring is successfull, sending time info
|
|
||||||
RxBus.Companion.getINSTANCE().send(new EventDanaRSPairingSuccess());
|
|
||||||
SendTimeInfo();
|
|
||||||
byte[] pairingKey = {inputBuffer[2], inputBuffer[3]};
|
|
||||||
// store pairing key to preferences
|
|
||||||
SP.putString(MainApp.gs(R.string.key_danars_pairingkey) + DanaRSPlugin.mDeviceName, DanaRS_Packet.bytesToHex(pairingKey));
|
|
||||||
if (L.isEnabled(L.PUMPBTCOMM))
|
|
||||||
log.debug("Got pairing key: " + DanaRS_Packet.bytesToHex(pairingKey));
|
|
||||||
break;
|
|
||||||
// time and user password information. last packet in handshake
|
|
||||||
case (byte) BleCommandUtil.DANAR_PACKET__OPCODE_ENCRYPTION__TIME_INFORMATION:
|
|
||||||
if (L.isEnabled(L.PUMPBTCOMM))
|
|
||||||
log.debug("<<<<< " + "ENCRYPTION__TIME_INFORMATION " + /*message.getMessageName() + " " + */ DanaRS_Packet.toHexString(inputBuffer));
|
|
||||||
int size = inputBuffer.length;
|
|
||||||
int pass = ((inputBuffer[size - 1] & 0x000000FF) << 8) + ((inputBuffer[size - 2] & 0x000000FF));
|
|
||||||
pass = pass ^ 3463;
|
|
||||||
danaRPump.setRsPassword(Integer.toHexString(pass));
|
|
||||||
if (L.isEnabled(L.PUMPBTCOMM))
|
|
||||||
log.debug("Pump user password: " + Integer.toHexString(pass));
|
|
||||||
|
|
||||||
RxBus.Companion.getINSTANCE().send(new EventPumpStatusChanged(EventPumpStatusChanged.Status.CONNECTED));
|
|
||||||
isConnected = true;
|
|
||||||
isConnecting = false;
|
|
||||||
if (L.isEnabled(L.PUMPBTCOMM))
|
|
||||||
log.debug("RS connected and status read");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
// common data packet
|
|
||||||
default:
|
|
||||||
DanaRS_Packet message;
|
|
||||||
// Retrieve message code from received buffer and last message sent
|
|
||||||
int originalCommand = processsedMessage != null ? processsedMessage.getCommand() : 0xFFFF;
|
|
||||||
int receivedCommand = DanaRS_Packet.getCommand(inputBuffer);
|
|
||||||
if (originalCommand == receivedCommand) {
|
|
||||||
// it's response to last message
|
|
||||||
message = processsedMessage;
|
|
||||||
} else {
|
|
||||||
// it's not response to last message, create new instance
|
|
||||||
message = danaRSMessageHashTable.findMessage(receivedCommand);
|
|
||||||
}
|
|
||||||
if (message != null) {
|
|
||||||
if (L.isEnabled(L.PUMPBTCOMM))
|
|
||||||
log.debug("<<<<< " + message.getFriendlyName() + " " + DanaRS_Packet.toHexString(inputBuffer));
|
|
||||||
// process received data
|
|
||||||
message.handleMessage(inputBuffer);
|
|
||||||
message.setReceived();
|
|
||||||
synchronized (message) {
|
|
||||||
// notify to sendMessage
|
|
||||||
message.notify();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
log.error("Unknown message received " + DanaRS_Packet.toHexString(inputBuffer));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.error("Unhandled exception", e);
|
|
||||||
}
|
|
||||||
startSignatureFound = false;
|
|
||||||
packetIsValid = false;
|
|
||||||
if (bufferLength < 6) {
|
|
||||||
// stop the loop
|
|
||||||
isProcessing = false;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// stop the loop
|
|
||||||
isProcessing = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void sendMessage(DanaRS_Packet message) {
|
|
||||||
processsedMessage = message;
|
|
||||||
if (message == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
byte[] command = {(byte) message.getType(), (byte) message.getOpCode()};
|
|
||||||
byte[] params = message.getRequestParams();
|
|
||||||
if (L.isEnabled(L.PUMPBTCOMM))
|
|
||||||
log.debug(">>>>> " + message.getFriendlyName() + " " + DanaRS_Packet.toHexString(command) + " " + DanaRS_Packet.toHexString(params));
|
|
||||||
byte[] bytes = BleCommandUtil.getInstance().getEncryptedPacket(message.getOpCode(), params, null);
|
|
||||||
// If there is another message not completely sent, add to queue only
|
|
||||||
if (mSendQueue.size() > 0) {
|
|
||||||
// Split to parts per 20 bytes max
|
|
||||||
for (; ; ) {
|
|
||||||
if (bytes.length > 20) {
|
|
||||||
byte[] addBytes = new byte[20];
|
|
||||||
System.arraycopy(bytes, 0, addBytes, 0, addBytes.length);
|
|
||||||
byte[] reBytes = new byte[bytes.length - addBytes.length];
|
|
||||||
System.arraycopy(bytes, addBytes.length, reBytes, 0, reBytes.length);
|
|
||||||
bytes = reBytes;
|
|
||||||
synchronized (mSendQueue) {
|
|
||||||
mSendQueue.add(addBytes);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
synchronized (mSendQueue) {
|
|
||||||
mSendQueue.add(bytes);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
if (bytes.length > 20) {
|
|
||||||
// Cut first 20 bytes
|
|
||||||
byte[] sendBytes = new byte[20];
|
|
||||||
System.arraycopy(bytes, 0, sendBytes, 0, sendBytes.length);
|
|
||||||
byte[] reBytes = new byte[bytes.length - sendBytes.length];
|
|
||||||
System.arraycopy(bytes, sendBytes.length, reBytes, 0, reBytes.length);
|
|
||||||
bytes = reBytes;
|
|
||||||
// and send
|
|
||||||
writeCharacteristic_NO_RESPONSE(getUARTWriteBTGattChar(), sendBytes);
|
|
||||||
// The rest split to parts per 20 bytes max
|
|
||||||
for (; ; ) {
|
|
||||||
if (bytes.length > 20) {
|
|
||||||
byte[] addBytes = new byte[20];
|
|
||||||
System.arraycopy(bytes, 0, addBytes, 0, addBytes.length);
|
|
||||||
reBytes = new byte[bytes.length - addBytes.length];
|
|
||||||
System.arraycopy(bytes, addBytes.length, reBytes, 0, reBytes.length);
|
|
||||||
bytes = reBytes;
|
|
||||||
synchronized (mSendQueue) {
|
|
||||||
mSendQueue.add(addBytes);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
synchronized (mSendQueue) {
|
|
||||||
mSendQueue.add(bytes);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
writeCharacteristic_NO_RESPONSE(getUARTWriteBTGattChar(), bytes);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// The rest from queue is send from onCharasteristicWrite (after sending 1st part)
|
|
||||||
synchronized (message) {
|
|
||||||
try {
|
|
||||||
message.wait(5000);
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
log.error("sendMessage InterruptedException", e);
|
|
||||||
log.error("Unhandled exception", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//SystemClock.sleep(200);
|
|
||||||
if (!message.isReceived()) {
|
|
||||||
log.warn("Reply not received " + message.getFriendlyName());
|
|
||||||
message.handleMessageNotReceived();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void SendPairingRequest() {
|
|
||||||
// Start activity which is waiting 20sec
|
|
||||||
// On pump pairing request is displayed and is waiting for conformation
|
|
||||||
Intent i = new Intent();
|
|
||||||
i.setClass(MainApp.instance(), PairingHelperActivity.class);
|
|
||||||
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
|
||||||
MainApp.instance().startActivity(i);
|
|
||||||
|
|
||||||
byte[] bytes = BleCommandUtil.getInstance().getEncryptedPacket(BleCommandUtil.DANAR_PACKET__OPCODE_ENCRYPTION__PASSKEY_REQUEST, null, null);
|
|
||||||
if (L.isEnabled(L.PUMPBTCOMM))
|
|
||||||
log.debug(">>>>> " + "ENCRYPTION__PASSKEY_REQUEST" + " " + DanaRS_Packet.toHexString(bytes));
|
|
||||||
writeCharacteristic_NO_RESPONSE(getUARTWriteBTGattChar(), bytes);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void SendPumpCheck() {
|
|
||||||
// 1st message sent to pump after connect
|
|
||||||
String devicename = getConnectDeviceName();
|
|
||||||
if (devicename == null || devicename.equals("")) {
|
|
||||||
Notification n = new Notification(Notification.DEVICENOTPAIRED, MainApp.gs(R.string.pairfirst), Notification.URGENT);
|
|
||||||
RxBus.Companion.getINSTANCE().send(new EventNewNotification(n));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
byte[] bytes = BleCommandUtil.getInstance().getEncryptedPacket(BleCommandUtil.DANAR_PACKET__OPCODE_ENCRYPTION__PUMP_CHECK, null, devicename);
|
|
||||||
if (L.isEnabled(L.PUMPBTCOMM))
|
|
||||||
log.debug(">>>>> " + "ENCRYPTION__PUMP_CHECK (0x00)" + " " + DanaRS_Packet.toHexString(bytes));
|
|
||||||
writeCharacteristic_NO_RESPONSE(getUARTWriteBTGattChar(), bytes);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void SendTimeInfo() {
|
|
||||||
byte[] bytes = BleCommandUtil.getInstance().getEncryptedPacket(BleCommandUtil.DANAR_PACKET__OPCODE_ENCRYPTION__TIME_INFORMATION, null, null);
|
|
||||||
if (L.isEnabled(L.PUMPBTCOMM))
|
|
||||||
log.debug(">>>>> " + "ENCRYPTION__TIME_INFORMATION" + " " + DanaRS_Packet.toHexString(bytes));
|
|
||||||
writeCharacteristic_NO_RESPONSE(getUARTWriteBTGattChar(), bytes);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -0,0 +1,556 @@
|
||||||
|
package info.nightscout.androidaps.plugins.pump.danaRS.services
|
||||||
|
|
||||||
|
import android.bluetooth.*
|
||||||
|
import android.content.Context
|
||||||
|
import android.content.Intent
|
||||||
|
import android.os.SystemClock
|
||||||
|
import info.nightscout.androidaps.R
|
||||||
|
import info.nightscout.androidaps.events.EventPumpStatusChanged
|
||||||
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
|
import info.nightscout.androidaps.logging.LTag
|
||||||
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
|
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload
|
||||||
|
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification
|
||||||
|
import info.nightscout.androidaps.plugins.general.overview.notifications.Notification
|
||||||
|
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPump
|
||||||
|
import info.nightscout.androidaps.plugins.pump.danaRS.DanaRSPlugin
|
||||||
|
import info.nightscout.androidaps.plugins.pump.danaRS.activities.PairingHelperActivity
|
||||||
|
import info.nightscout.androidaps.plugins.pump.danaRS.comm.DanaRSMessageHashTable
|
||||||
|
import info.nightscout.androidaps.plugins.pump.danaRS.comm.DanaRS_Packet
|
||||||
|
import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption
|
||||||
|
import info.nightscout.androidaps.plugins.pump.danaRS.events.EventDanaRSPairingSuccess
|
||||||
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
|
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||||
|
import okhttp3.internal.notify
|
||||||
|
import okhttp3.internal.waitMillis
|
||||||
|
import java.util.*
|
||||||
|
import java.util.concurrent.ScheduledFuture
|
||||||
|
import javax.inject.Inject
|
||||||
|
import javax.inject.Singleton
|
||||||
|
|
||||||
|
@Singleton
|
||||||
|
class BLEComm @Inject internal constructor(
|
||||||
|
private val aapsLogger: AAPSLogger,
|
||||||
|
private val resourceHelper: ResourceHelper,
|
||||||
|
private val context: Context,
|
||||||
|
private val rxBus: RxBusWrapper,
|
||||||
|
private val sp: SP,
|
||||||
|
private val danaRSMessageHashTable: DanaRSMessageHashTable,
|
||||||
|
private val danaRPump: DanaRPump,
|
||||||
|
private val bleEncryption: BleEncryption
|
||||||
|
) {
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
private const val WRITE_DELAY_MILLIS: Long = 50
|
||||||
|
private const val UART_READ_UUID = "0000fff1-0000-1000-8000-00805f9b34fb"
|
||||||
|
private const val UART_WRITE_UUID = "0000fff2-0000-1000-8000-00805f9b34fb"
|
||||||
|
|
||||||
|
private const val PACKET_START_BYTE = 0xA5.toByte()
|
||||||
|
private const val PACKET_END_BYTE = 0x5A.toByte()
|
||||||
|
}
|
||||||
|
|
||||||
|
private var scheduledDisconnection: ScheduledFuture<*>? = null
|
||||||
|
private var processedMessage: DanaRS_Packet? = null
|
||||||
|
private val mSendQueue = ArrayList<ByteArray>()
|
||||||
|
private var mBluetoothManager: BluetoothManager? = null
|
||||||
|
private var mBluetoothAdapter: BluetoothAdapter? = null
|
||||||
|
private var connectDeviceName: String? = null
|
||||||
|
private var mBluetoothGatt: BluetoothGatt? = null
|
||||||
|
|
||||||
|
var isConnected = false
|
||||||
|
var isConnecting = false
|
||||||
|
private var uartRead: BluetoothGattCharacteristic? = null
|
||||||
|
private var uartWrite: BluetoothGattCharacteristic? = null
|
||||||
|
|
||||||
|
init {
|
||||||
|
initialize()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun initialize(): Boolean {
|
||||||
|
aapsLogger.debug(LTag.PUMPBTCOMM, "Initializing BLEComm.")
|
||||||
|
if (mBluetoothManager == null) {
|
||||||
|
mBluetoothManager = context.getSystemService(Context.BLUETOOTH_SERVICE) as BluetoothManager
|
||||||
|
if (mBluetoothManager == null) {
|
||||||
|
aapsLogger.error("Unable to initialize BluetoothManager.")
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mBluetoothAdapter = mBluetoothManager?.adapter
|
||||||
|
if (mBluetoothAdapter == null) {
|
||||||
|
aapsLogger.error("Unable to obtain a BluetoothAdapter.")
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
fun connect(from: String, address: String?): Boolean {
|
||||||
|
// test existing BT device
|
||||||
|
val tBluetoothManager = context.getSystemService(Context.BLUETOOTH_SERVICE) as BluetoothManager?
|
||||||
|
?: return false
|
||||||
|
tBluetoothManager.adapter ?: return false
|
||||||
|
|
||||||
|
if (address == null) {
|
||||||
|
aapsLogger.error("unspecified address.")
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mBluetoothAdapter == null) {
|
||||||
|
if (!initialize()) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
isConnecting = true
|
||||||
|
val device = mBluetoothAdapter?.getRemoteDevice(address)
|
||||||
|
if (device == null) {
|
||||||
|
aapsLogger.error("Device not found. Unable to connect from: $from")
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
aapsLogger.debug(LTag.PUMPBTCOMM, "Trying to create a new connection from: $from")
|
||||||
|
connectDeviceName = device.name
|
||||||
|
mBluetoothGatt = device.connectGatt(context, false, mGattCallback)
|
||||||
|
setCharacteristicNotification(uartReadBTGattChar, true)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
fun stopConnecting() {
|
||||||
|
isConnecting = false
|
||||||
|
}
|
||||||
|
|
||||||
|
@Synchronized
|
||||||
|
fun disconnect(from: String) {
|
||||||
|
aapsLogger.debug(LTag.PUMPBTCOMM, "disconnect from: $from")
|
||||||
|
|
||||||
|
// cancel previous scheduled disconnection to prevent closing upcoming connection
|
||||||
|
scheduledDisconnection?.cancel(false)
|
||||||
|
scheduledDisconnection = null
|
||||||
|
|
||||||
|
if (mBluetoothAdapter == null || mBluetoothGatt == null) {
|
||||||
|
aapsLogger.error("disconnect not possible: (mBluetoothAdapter == null) " + (mBluetoothAdapter == null))
|
||||||
|
aapsLogger.error("disconnect not possible: (mBluetoothGatt == null) " + (mBluetoothGatt == null))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
setCharacteristicNotification(uartReadBTGattChar, false)
|
||||||
|
mBluetoothGatt?.disconnect()
|
||||||
|
isConnected = false
|
||||||
|
SystemClock.sleep(2000)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Synchronized fun close() {
|
||||||
|
aapsLogger.debug(LTag.PUMPBTCOMM, "BluetoothAdapter close")
|
||||||
|
mBluetoothGatt?.close()
|
||||||
|
mBluetoothGatt = null
|
||||||
|
}
|
||||||
|
|
||||||
|
private val mGattCallback: BluetoothGattCallback = object : BluetoothGattCallback() {
|
||||||
|
override fun onConnectionStateChange(gatt: BluetoothGatt, status: Int, newState: Int) {
|
||||||
|
onConnectionStateChangeSynchronized(gatt, newState) // call it synchronized
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onServicesDiscovered(gatt: BluetoothGatt, status: Int) {
|
||||||
|
aapsLogger.debug(LTag.PUMPBTCOMM, "onServicesDiscovered")
|
||||||
|
if (status == BluetoothGatt.GATT_SUCCESS) {
|
||||||
|
findCharacteristic()
|
||||||
|
}
|
||||||
|
sendPumpCheck()
|
||||||
|
// 1st message sent to pump after connect
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onCharacteristicRead(gatt: BluetoothGatt, characteristic: BluetoothGattCharacteristic, status: Int) {
|
||||||
|
aapsLogger.debug(LTag.PUMPBTCOMM, "onCharacteristicRead: " + DanaRS_Packet.toHexString(characteristic.value))
|
||||||
|
addToReadBuffer(characteristic.value)
|
||||||
|
readDataParsing()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onCharacteristicChanged(gatt: BluetoothGatt, characteristic: BluetoothGattCharacteristic) {
|
||||||
|
aapsLogger.debug(LTag.PUMPBTCOMM, "onCharacteristicChanged: " + DanaRS_Packet.toHexString(characteristic.value))
|
||||||
|
addToReadBuffer(characteristic.value)
|
||||||
|
Thread(Runnable { readDataParsing() }).start()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onCharacteristicWrite(gatt: BluetoothGatt, characteristic: BluetoothGattCharacteristic, status: Int) {
|
||||||
|
aapsLogger.debug(LTag.PUMPBTCOMM, "onCharacteristicWrite: " + DanaRS_Packet.toHexString(characteristic.value))
|
||||||
|
Thread(Runnable {
|
||||||
|
synchronized(mSendQueue) {
|
||||||
|
// after message sent, check if there is the rest of the message waiting and send it
|
||||||
|
if (mSendQueue.size > 0) {
|
||||||
|
val bytes = mSendQueue[0]
|
||||||
|
mSendQueue.removeAt(0)
|
||||||
|
writeCharacteristicNoResponse(uartWriteBTGattChar, bytes)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}).start()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Synchronized
|
||||||
|
private fun setCharacteristicNotification(characteristic: BluetoothGattCharacteristic?, enabled: Boolean) {
|
||||||
|
aapsLogger.debug(LTag.PUMPBTCOMM, "setCharacteristicNotification")
|
||||||
|
if (mBluetoothAdapter == null || mBluetoothGatt == null) {
|
||||||
|
aapsLogger.error("BluetoothAdapter not initialized_ERROR")
|
||||||
|
isConnecting = false
|
||||||
|
isConnected = false
|
||||||
|
return
|
||||||
|
}
|
||||||
|
mBluetoothGatt!!.setCharacteristicNotification(characteristic, enabled)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Synchronized
|
||||||
|
private fun writeCharacteristicNoResponse(characteristic: BluetoothGattCharacteristic, data: ByteArray) {
|
||||||
|
Thread(Runnable {
|
||||||
|
SystemClock.sleep(WRITE_DELAY_MILLIS)
|
||||||
|
if (mBluetoothAdapter == null || mBluetoothGatt == null) {
|
||||||
|
aapsLogger.error("BluetoothAdapter not initialized_ERROR")
|
||||||
|
isConnecting = false
|
||||||
|
isConnected = false
|
||||||
|
return@Runnable
|
||||||
|
}
|
||||||
|
characteristic.value = data
|
||||||
|
characteristic.writeType = BluetoothGattCharacteristic.WRITE_TYPE_NO_RESPONSE
|
||||||
|
aapsLogger.debug("writeCharacteristic:" + DanaRS_Packet.toHexString(data))
|
||||||
|
mBluetoothGatt!!.writeCharacteristic(characteristic)
|
||||||
|
}).start()
|
||||||
|
}
|
||||||
|
|
||||||
|
private val uartReadBTGattChar: BluetoothGattCharacteristic
|
||||||
|
get() = uartRead
|
||||||
|
?: BluetoothGattCharacteristic(UUID.fromString(UART_READ_UUID), BluetoothGattCharacteristic.PROPERTY_READ or BluetoothGattCharacteristic.PROPERTY_NOTIFY, 0).also { uartRead = it }
|
||||||
|
|
||||||
|
private val uartWriteBTGattChar: BluetoothGattCharacteristic
|
||||||
|
get() = uartWrite
|
||||||
|
?: BluetoothGattCharacteristic(UUID.fromString(UART_WRITE_UUID), BluetoothGattCharacteristic.PROPERTY_WRITE_NO_RESPONSE, 0).also { uartWrite = it }
|
||||||
|
|
||||||
|
private fun getSupportedGattServices(): List<BluetoothGattService>? {
|
||||||
|
aapsLogger.debug(LTag.PUMPBTCOMM, "getSupportedGattServices")
|
||||||
|
if (mBluetoothAdapter == null || mBluetoothGatt == null) {
|
||||||
|
aapsLogger.error("BluetoothAdapter not initialized_ERROR")
|
||||||
|
isConnecting = false
|
||||||
|
isConnected = false
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
return mBluetoothGatt?.services
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun findCharacteristic() {
|
||||||
|
val gattServices = getSupportedGattServices() ?: return
|
||||||
|
var uuid: String
|
||||||
|
for (gattService in gattServices) {
|
||||||
|
val gattCharacteristics = gattService.characteristics
|
||||||
|
for (gattCharacteristic in gattCharacteristics) {
|
||||||
|
uuid = gattCharacteristic.uuid.toString()
|
||||||
|
if (UART_READ_UUID == uuid) {
|
||||||
|
uartRead = gattCharacteristic
|
||||||
|
setCharacteristicNotification(uartRead, true)
|
||||||
|
}
|
||||||
|
if (UART_WRITE_UUID == uuid) {
|
||||||
|
uartWrite = gattCharacteristic
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Synchronized
|
||||||
|
private fun onConnectionStateChangeSynchronized(gatt: BluetoothGatt, newState: Int) {
|
||||||
|
aapsLogger.debug(LTag.PUMPBTCOMM, "onConnectionStateChange")
|
||||||
|
if (newState == BluetoothProfile.STATE_CONNECTED) {
|
||||||
|
gatt.discoverServices()
|
||||||
|
} else if (newState == BluetoothProfile.STATE_DISCONNECTED) {
|
||||||
|
close()
|
||||||
|
isConnected = false
|
||||||
|
isConnecting = false
|
||||||
|
rxBus.send(EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTED))
|
||||||
|
aapsLogger.debug(LTag.PUMPBTCOMM, "Device was disconnected " + gatt.device.name) //Device was disconnected
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private val readBuffer = ByteArray(1024)
|
||||||
|
private var bufferLength = 0
|
||||||
|
|
||||||
|
private fun addToReadBuffer(buffer: ByteArray) {
|
||||||
|
//log.debug("addToReadBuffer " + DanaRS_Packet.toHexString(buffer));
|
||||||
|
if (buffer.isEmpty()) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
synchronized(readBuffer) {
|
||||||
|
// Append incoming data to input buffer
|
||||||
|
System.arraycopy(buffer, 0, readBuffer, bufferLength, buffer.size)
|
||||||
|
bufferLength += buffer.size
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun readDataParsing() {
|
||||||
|
var startSignatureFound = false
|
||||||
|
var packetIsValid = false
|
||||||
|
var isProcessing: Boolean
|
||||||
|
isProcessing = true
|
||||||
|
var inputBuffer: ByteArray? = null
|
||||||
|
|
||||||
|
while (isProcessing) {
|
||||||
|
var length = 0
|
||||||
|
synchronized(readBuffer) {
|
||||||
|
|
||||||
|
// Find packet start [A5 A5]
|
||||||
|
if (bufferLength >= 6) {
|
||||||
|
for (idxStartByte in 0 until bufferLength - 2) {
|
||||||
|
if (readBuffer[idxStartByte] == PACKET_START_BYTE && readBuffer[idxStartByte + 1] == PACKET_START_BYTE) {
|
||||||
|
if (idxStartByte > 0) {
|
||||||
|
// if buffer doesn't start with signature remove the leading trash
|
||||||
|
aapsLogger.debug(LTag.PUMPBTCOMM, "Shifting the input buffer by $idxStartByte bytes")
|
||||||
|
System.arraycopy(readBuffer, idxStartByte, readBuffer, 0, bufferLength - idxStartByte)
|
||||||
|
bufferLength -= idxStartByte
|
||||||
|
}
|
||||||
|
startSignatureFound = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// A5 A5 LEN TYPE CODE PARAMS CHECKSUM1 CHECKSUM2 5A 5A
|
||||||
|
// ^---- LEN -----^
|
||||||
|
// total packet length 2 + 1 + readBuffer[2] + 2 + 2
|
||||||
|
if (startSignatureFound) {
|
||||||
|
length = readBuffer[2].toInt()
|
||||||
|
// test if there is enough data loaded
|
||||||
|
if (length + 7 > bufferLength) return
|
||||||
|
// Verify packed end [5A 5A]
|
||||||
|
if (readBuffer[length + 5] == PACKET_END_BYTE && readBuffer[length + 6] == PACKET_END_BYTE) {
|
||||||
|
packetIsValid = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (packetIsValid) {
|
||||||
|
inputBuffer = ByteArray(length + 7)
|
||||||
|
// copy packet to input buffer
|
||||||
|
System.arraycopy(readBuffer, 0, inputBuffer, 0, length + 7)
|
||||||
|
// Cut off the message from readBuffer
|
||||||
|
try {
|
||||||
|
System.arraycopy(readBuffer, length + 7, readBuffer, 0, bufferLength - (length + 7))
|
||||||
|
} catch (e: Exception) {
|
||||||
|
aapsLogger.error("length: " + length + "bufferLength: " + bufferLength)
|
||||||
|
throw e
|
||||||
|
}
|
||||||
|
bufferLength -= length + 7
|
||||||
|
// now we have encrypted packet in inputBuffer
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (packetIsValid) {
|
||||||
|
try {
|
||||||
|
// decrypt the packet
|
||||||
|
bleEncryption.getDecryptedPacket(inputBuffer)?.let { decryptedBuffer ->
|
||||||
|
when (decryptedBuffer[0]) {
|
||||||
|
BleEncryption.DANAR_PACKET__TYPE_ENCRYPTION_RESPONSE.toByte() -> when (decryptedBuffer[1]) {
|
||||||
|
BleEncryption.DANAR_PACKET__OPCODE_ENCRYPTION__PUMP_CHECK.toByte() -> if (decryptedBuffer.size == 4 && decryptedBuffer[2] == 'O'.toByte() && decryptedBuffer[3] == 'K'.toByte()) {
|
||||||
|
aapsLogger.debug(LTag.PUMPBTCOMM, "<<<<< " + "ENCRYPTION__PUMP_CHECK (OK)" + " " + DanaRS_Packet.toHexString(decryptedBuffer))
|
||||||
|
// Grab pairing key from preferences if exists
|
||||||
|
val pairingKey = sp.getString(resourceHelper.gs(R.string.key_danars_pairingkey) + DanaRSPlugin.mDeviceName, "")
|
||||||
|
aapsLogger.debug(LTag.PUMPBTCOMM, "Using stored pairing key: $pairingKey")
|
||||||
|
if (pairingKey.isNotEmpty()) {
|
||||||
|
val encodedPairingKey = DanaRS_Packet.hexToBytes(pairingKey)
|
||||||
|
val bytes = bleEncryption.getEncryptedPacket(BleEncryption.DANAR_PACKET__OPCODE_ENCRYPTION__CHECK_PASSKEY, encodedPairingKey, null)
|
||||||
|
aapsLogger.debug(LTag.PUMPBTCOMM, ">>>>> " + "ENCRYPTION__CHECK_PASSKEY" + " " + DanaRS_Packet.toHexString(bytes))
|
||||||
|
writeCharacteristicNoResponse(uartWriteBTGattChar, bytes)
|
||||||
|
} else {
|
||||||
|
// Stored pairing key does not exists, request pairing
|
||||||
|
sendPairingRequest()
|
||||||
|
}
|
||||||
|
} else if (decryptedBuffer.size == 6 && decryptedBuffer[2] == 'P'.toByte() && decryptedBuffer[3] == 'U'.toByte() && decryptedBuffer[4] == 'M'.toByte() && decryptedBuffer[5] == 'P'.toByte()) {
|
||||||
|
aapsLogger.debug(LTag.PUMPBTCOMM, "<<<<< " + "ENCRYPTION__PUMP_CHECK (PUMP)" + " " + DanaRS_Packet.toHexString(decryptedBuffer))
|
||||||
|
mSendQueue.clear()
|
||||||
|
rxBus.send(EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTED, resourceHelper.gs(R.string.pumperror)))
|
||||||
|
NSUpload.uploadError(resourceHelper.gs(R.string.pumperror))
|
||||||
|
val n = Notification(Notification.PUMPERROR, resourceHelper.gs(R.string.pumperror), Notification.URGENT)
|
||||||
|
rxBus.send(EventNewNotification(n))
|
||||||
|
} else if (decryptedBuffer.size == 6 && decryptedBuffer[2] == 'B'.toByte() && decryptedBuffer[3] == 'U'.toByte() && decryptedBuffer[4] == 'S'.toByte() && decryptedBuffer[5] == 'Y'.toByte()) {
|
||||||
|
aapsLogger.debug(LTag.PUMPBTCOMM, "<<<<< " + "ENCRYPTION__PUMP_CHECK (BUSY)" + " " + DanaRS_Packet.toHexString(decryptedBuffer))
|
||||||
|
mSendQueue.clear()
|
||||||
|
rxBus.send(EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTED, resourceHelper.gs(R.string.pumpbusy)))
|
||||||
|
} else {
|
||||||
|
// ERROR in response, wrong serial number
|
||||||
|
aapsLogger.debug(LTag.PUMPBTCOMM, "<<<<< " + "ENCRYPTION__PUMP_CHECK (ERROR)" + " " + DanaRS_Packet.toHexString(decryptedBuffer))
|
||||||
|
mSendQueue.clear()
|
||||||
|
rxBus.send(EventPumpStatusChanged(EventPumpStatusChanged.Status.DISCONNECTED, resourceHelper.gs(R.string.connectionerror)))
|
||||||
|
sp.remove(resourceHelper.gs(R.string.key_danars_pairingkey) + DanaRSPlugin.mDeviceName)
|
||||||
|
val n = Notification(Notification.WRONGSERIALNUMBER, resourceHelper.gs(R.string.wrongpassword), Notification.URGENT)
|
||||||
|
rxBus.send(EventNewNotification(n))
|
||||||
|
}
|
||||||
|
|
||||||
|
BleEncryption.DANAR_PACKET__OPCODE_ENCRYPTION__CHECK_PASSKEY.toByte() -> {
|
||||||
|
aapsLogger.debug(LTag.PUMPBTCOMM, "<<<<< " + "ENCRYPTION__CHECK_PASSKEY" + " " + DanaRS_Packet.toHexString(decryptedBuffer))
|
||||||
|
if (decryptedBuffer[2] == 0x00.toByte()) {
|
||||||
|
// Paring is not requested, sending time info
|
||||||
|
sendTimeInfo()
|
||||||
|
} else {
|
||||||
|
// Pairing on pump is requested
|
||||||
|
sendPairingRequest()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
BleEncryption.DANAR_PACKET__OPCODE_ENCRYPTION__PASSKEY_REQUEST.toByte() -> {
|
||||||
|
aapsLogger.debug(LTag.PUMPBTCOMM, "<<<<< " + "ENCRYPTION__PASSKEY_REQUEST " + DanaRS_Packet.toHexString(decryptedBuffer))
|
||||||
|
if (decryptedBuffer[2] != 0x00.toByte()) {
|
||||||
|
disconnect("passkey request failed")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
BleEncryption.DANAR_PACKET__OPCODE_ENCRYPTION__PASSKEY_RETURN.toByte() -> {
|
||||||
|
aapsLogger.debug(LTag.PUMPBTCOMM, "<<<<< " + "ENCRYPTION__PASSKEY_RETURN " + DanaRS_Packet.toHexString(decryptedBuffer))
|
||||||
|
// Paring is successful, sending time info
|
||||||
|
rxBus.send(EventDanaRSPairingSuccess())
|
||||||
|
sendTimeInfo()
|
||||||
|
val pairingKey = byteArrayOf(decryptedBuffer[2], decryptedBuffer[3])
|
||||||
|
// store pairing key to preferences
|
||||||
|
sp.putString(resourceHelper.gs(R.string.key_danars_pairingkey) + DanaRSPlugin.mDeviceName, DanaRS_Packet.bytesToHex(pairingKey))
|
||||||
|
aapsLogger.debug(LTag.PUMPBTCOMM, "Got pairing key: " + DanaRS_Packet.bytesToHex(pairingKey))
|
||||||
|
}
|
||||||
|
|
||||||
|
BleEncryption.DANAR_PACKET__OPCODE_ENCRYPTION__TIME_INFORMATION.toByte() -> {
|
||||||
|
aapsLogger.debug(LTag.PUMPBTCOMM, "<<<<< " + "ENCRYPTION__TIME_INFORMATION " + /*message.getMessageName() + " " + */DanaRS_Packet.toHexString(decryptedBuffer))
|
||||||
|
val size = decryptedBuffer.size
|
||||||
|
var pass: Int = (decryptedBuffer[size - 1].toInt() and 0x000000FF shl 8) + (decryptedBuffer[size - 2].toInt() and 0x000000FF)
|
||||||
|
pass = pass xor 3463
|
||||||
|
danaRPump.rsPassword = Integer.toHexString(pass)
|
||||||
|
aapsLogger.debug(LTag.PUMPBTCOMM, "Pump user password: " + Integer.toHexString(pass))
|
||||||
|
rxBus.send(EventPumpStatusChanged(EventPumpStatusChanged.Status.CONNECTED))
|
||||||
|
isConnected = true
|
||||||
|
isConnecting = false
|
||||||
|
aapsLogger.debug(LTag.PUMPBTCOMM, "RS connected and status read")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
else -> {
|
||||||
|
// Retrieve message code from received buffer and last message sent
|
||||||
|
val originalCommand = processedMessage?.command ?: 0xFFFF
|
||||||
|
val receivedCommand = DanaRS_Packet.getCommand(decryptedBuffer)
|
||||||
|
val message: DanaRS_Packet? = if (originalCommand == receivedCommand) {
|
||||||
|
// it's response to last message
|
||||||
|
processedMessage
|
||||||
|
} else {
|
||||||
|
// it's not response to last message, create new instance
|
||||||
|
danaRSMessageHashTable.findMessage(receivedCommand)
|
||||||
|
}
|
||||||
|
if (message != null) {
|
||||||
|
aapsLogger.debug(LTag.PUMPBTCOMM, "<<<<< " + message.friendlyName + " " + DanaRS_Packet.toHexString(decryptedBuffer))
|
||||||
|
// process received data
|
||||||
|
message.handleMessage(decryptedBuffer)
|
||||||
|
message.setReceived()
|
||||||
|
synchronized(message) {
|
||||||
|
// notify to sendMessage
|
||||||
|
message.notify()
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
aapsLogger.error("Unknown message received " + DanaRS_Packet.toHexString(decryptedBuffer))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} ?: throw IllegalStateException("Null decryptedInputBuffer")
|
||||||
|
} catch (e: Exception) {
|
||||||
|
aapsLogger.error("Unhandled exception", e)
|
||||||
|
}
|
||||||
|
startSignatureFound = false
|
||||||
|
packetIsValid = false
|
||||||
|
if (bufferLength < 6) {
|
||||||
|
// stop the loop
|
||||||
|
isProcessing = false
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// stop the loop
|
||||||
|
isProcessing = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun sendMessage(message: DanaRS_Packet?) {
|
||||||
|
processedMessage = message
|
||||||
|
if (message == null) return
|
||||||
|
val command = byteArrayOf(message.type.toByte(), message.opCode.toByte())
|
||||||
|
val params = message.requestParams
|
||||||
|
aapsLogger.debug(LTag.PUMPBTCOMM, ">>>>> " + message.friendlyName + " " + DanaRS_Packet.toHexString(command) + " " + DanaRS_Packet.toHexString(params))
|
||||||
|
var bytes = bleEncryption.getEncryptedPacket(message.opCode, params, null)
|
||||||
|
// If there is another message not completely sent, add to queue only
|
||||||
|
if (mSendQueue.size > 0) {
|
||||||
|
// Split to parts per 20 bytes max
|
||||||
|
while (true) {
|
||||||
|
if (bytes.size > 20) {
|
||||||
|
val addBytes = ByteArray(20)
|
||||||
|
System.arraycopy(bytes, 0, addBytes, 0, addBytes.size)
|
||||||
|
val reBytes = ByteArray(bytes.size - addBytes.size)
|
||||||
|
System.arraycopy(bytes, addBytes.size, reBytes, 0, reBytes.size)
|
||||||
|
bytes = reBytes
|
||||||
|
synchronized(mSendQueue) { mSendQueue.add(addBytes) }
|
||||||
|
} else {
|
||||||
|
synchronized(mSendQueue) { mSendQueue.add(bytes) }
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (bytes.size > 20) {
|
||||||
|
// Cut first 20 bytes
|
||||||
|
val sendBytes = ByteArray(20)
|
||||||
|
System.arraycopy(bytes, 0, sendBytes, 0, sendBytes.size)
|
||||||
|
var reBytes = ByteArray(bytes.size - sendBytes.size)
|
||||||
|
System.arraycopy(bytes, sendBytes.size, reBytes, 0, reBytes.size)
|
||||||
|
bytes = reBytes
|
||||||
|
// and send
|
||||||
|
writeCharacteristicNoResponse(uartWriteBTGattChar, sendBytes)
|
||||||
|
// The rest split to parts per 20 bytes max
|
||||||
|
while (true) {
|
||||||
|
if (bytes.size > 20) {
|
||||||
|
val addBytes = ByteArray(20)
|
||||||
|
System.arraycopy(bytes, 0, addBytes, 0, addBytes.size)
|
||||||
|
reBytes = ByteArray(bytes.size - addBytes.size)
|
||||||
|
System.arraycopy(bytes, addBytes.size, reBytes, 0, reBytes.size)
|
||||||
|
bytes = reBytes
|
||||||
|
synchronized(mSendQueue) { mSendQueue.add(addBytes) }
|
||||||
|
} else {
|
||||||
|
synchronized(mSendQueue) { mSendQueue.add(bytes) }
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
writeCharacteristicNoResponse(uartWriteBTGattChar, bytes)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// The rest from queue is send from onCharacteristicWrite (after sending 1st part)
|
||||||
|
synchronized(message) {
|
||||||
|
try {
|
||||||
|
message.waitMillis(5000)
|
||||||
|
} catch (e: InterruptedException) {
|
||||||
|
aapsLogger.error("sendMessage InterruptedException", e)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//SystemClock.sleep(200);
|
||||||
|
if (!message.isReceived) {
|
||||||
|
aapsLogger.warn(LTag.PUMPBTCOMM, "Reply not received " + message.friendlyName)
|
||||||
|
message.handleMessageNotReceived()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun sendPairingRequest() {
|
||||||
|
// Start activity which is waiting 20sec
|
||||||
|
// On pump pairing request is displayed and is waiting for conformation
|
||||||
|
val i = Intent()
|
||||||
|
i.setClass(context, PairingHelperActivity::class.java)
|
||||||
|
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||||
|
context.startActivity(i)
|
||||||
|
val bytes = bleEncryption.getEncryptedPacket(BleEncryption.DANAR_PACKET__OPCODE_ENCRYPTION__PASSKEY_REQUEST, null, null)
|
||||||
|
aapsLogger.debug(LTag.PUMPBTCOMM, ">>>>> " + "ENCRYPTION__PASSKEY_REQUEST" + " " + DanaRS_Packet.toHexString(bytes))
|
||||||
|
writeCharacteristicNoResponse(uartWriteBTGattChar, bytes)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun sendPumpCheck() {
|
||||||
|
// 1st message sent to pump after connect
|
||||||
|
val deviceName = connectDeviceName
|
||||||
|
if (deviceName == null || deviceName == "") {
|
||||||
|
val n = Notification(Notification.DEVICENOTPAIRED, resourceHelper.gs(R.string.pairfirst), Notification.URGENT)
|
||||||
|
rxBus.send(EventNewNotification(n))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
val bytes = bleEncryption.getEncryptedPacket(BleEncryption.DANAR_PACKET__OPCODE_ENCRYPTION__PUMP_CHECK, null, deviceName)
|
||||||
|
aapsLogger.debug(LTag.PUMPBTCOMM, ">>>>> " + "ENCRYPTION__PUMP_CHECK (0x00)" + " " + DanaRS_Packet.toHexString(bytes))
|
||||||
|
writeCharacteristicNoResponse(uartWriteBTGattChar, bytes)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun sendTimeInfo() {
|
||||||
|
val bytes = bleEncryption.getEncryptedPacket(BleEncryption.DANAR_PACKET__OPCODE_ENCRYPTION__TIME_INFORMATION, null, null)
|
||||||
|
aapsLogger.debug(LTag.PUMPBTCOMM, ">>>>> " + "ENCRYPTION__TIME_INFORMATION" + " " + DanaRS_Packet.toHexString(bytes))
|
||||||
|
writeCharacteristicNoResponse(uartWriteBTGattChar, bytes)
|
||||||
|
}
|
||||||
|
}
|
|
@ -101,10 +101,11 @@ public class DanaRSService extends DaggerService {
|
||||||
@Inject ActivePluginProvider activePlugin;
|
@Inject ActivePluginProvider activePlugin;
|
||||||
@Inject ConstraintChecker constraintChecker;
|
@Inject ConstraintChecker constraintChecker;
|
||||||
@Inject DetailedBolusInfoStorage detailedBolusInfoStorage;
|
@Inject DetailedBolusInfoStorage detailedBolusInfoStorage;
|
||||||
|
@Inject BLEComm bleComm;
|
||||||
|
@Inject FabricPrivacy fabricPrivacy;
|
||||||
|
|
||||||
private CompositeDisposable disposable = new CompositeDisposable();
|
private CompositeDisposable disposable = new CompositeDisposable();
|
||||||
|
|
||||||
private BLEComm bleComm;
|
|
||||||
|
|
||||||
private IBinder mBinder = new LocalBinder();
|
private IBinder mBinder = new LocalBinder();
|
||||||
|
|
||||||
|
@ -116,14 +117,13 @@ public class DanaRSService extends DaggerService {
|
||||||
@Override
|
@Override
|
||||||
public void onCreate() {
|
public void onCreate() {
|
||||||
super.onCreate();
|
super.onCreate();
|
||||||
bleComm = new BLEComm(this, danaRSMessageHashTable, danaRPump);
|
|
||||||
disposable.add(rxBus
|
disposable.add(rxBus
|
||||||
.toObservable(EventAppExit.class)
|
.toObservable(EventAppExit.class)
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(Schedulers.io())
|
||||||
.subscribe(event -> {
|
.subscribe(event -> {
|
||||||
aapsLogger.debug(LTag.PUMPCOMM, "EventAppExit received");
|
aapsLogger.debug(LTag.PUMPCOMM, "EventAppExit received");
|
||||||
stopSelf();
|
stopSelf();
|
||||||
}, exception -> FabricPrivacy.getInstance().logException(exception))
|
}, fabricPrivacy::logException)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -134,15 +134,15 @@ public class DanaRSService extends DaggerService {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isConnected() {
|
public boolean isConnected() {
|
||||||
return bleComm.isConnected;
|
return bleComm.isConnected();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isConnecting() {
|
public boolean isConnecting() {
|
||||||
return bleComm.isConnecting;
|
return bleComm.isConnecting();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean connect(String from, String address, Object confirmConnect) {
|
public boolean connect(String from, String address) {
|
||||||
return bleComm.connect(from, address, confirmConnect);
|
return bleComm.connect(from, address);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void stopConnecting() {
|
public void stopConnecting() {
|
||||||
|
|
BIN
app/src/main/jniLibs/arm64-v8a/libBleEncryption.so
Normal file
BIN
app/src/main/jniLibs/arm64-v8a/libBleEncryption.so
Normal file
Binary file not shown.
BIN
app/src/main/jniLibs/armeabi-v7a/libBleEncryption.so
Normal file
BIN
app/src/main/jniLibs/armeabi-v7a/libBleEncryption.so
Normal file
Binary file not shown.
BIN
app/src/main/jniLibs/x86/libBleEncryption.so
Normal file
BIN
app/src/main/jniLibs/x86/libBleEncryption.so
Normal file
Binary file not shown.
BIN
app/src/main/jniLibs/x86_64/libBleEncryption.so
Normal file
BIN
app/src/main/jniLibs/x86_64/libBleEncryption.so
Normal file
Binary file not shown.
|
@ -1,6 +1,6 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
package info.nightscout.androidaps.plugins.pump.danaRS.comm
|
||||||
|
|
||||||
import com.cozmo.danar.util.BleCommandUtil
|
import info.nightscout.androidaps.plugins.pump.danaRS.encryption.BleEncryption
|
||||||
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
import info.nightscout.androidaps.interfaces.ActivePluginProvider
|
||||||
import info.nightscout.androidaps.interfaces.Constraint
|
import info.nightscout.androidaps.interfaces.Constraint
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker
|
import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker
|
||||||
|
@ -31,6 +31,6 @@ class DanaRSMessageHashTableTest : DanaRSTestBase() {
|
||||||
val danaRSMessageHashTable = DanaRSMessageHashTable(aapsLogger, rxBus, resourceHelper, danaRPump, danaRSPlugin, activePlugin, constraintChecker, detailedBolusInfoStorage)
|
val danaRSMessageHashTable = DanaRSMessageHashTable(aapsLogger, rxBus, resourceHelper, danaRPump, danaRSPlugin, activePlugin, constraintChecker, detailedBolusInfoStorage)
|
||||||
val forTesting: DanaRS_Packet = DanaRS_Packet_APS_Set_Event_History(aapsLogger, DanaRPump.CARBS, 0, 0, 0)
|
val forTesting: DanaRS_Packet = DanaRS_Packet_APS_Set_Event_History(aapsLogger, DanaRPump.CARBS, 0, 0, 0)
|
||||||
val testPacket: DanaRS_Packet = danaRSMessageHashTable.findMessage(forTesting.command)
|
val testPacket: DanaRS_Packet = danaRSMessageHashTable.findMessage(forTesting.command)
|
||||||
Assert.assertEquals(BleCommandUtil.DANAR_PACKET__OPCODE__APS_SET_EVENT_HISTORY.toLong(), testPacket.getOpCode().toLong())
|
Assert.assertEquals(BleEncryption.DANAR_PACKET__OPCODE__APS_SET_EVENT_HISTORY.toLong(), testPacket.getOpCode().toLong())
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue