From c9a039a8a690629babf5a43e2bbf07b1dd04936f Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Fri, 1 Jul 2022 00:51:05 +0200 Subject: [PATCH] RL: enum -> kt --- .../service/RileyLinkMedtronicService.kt | 2 +- .../pump/common/hw/rileylink/ble/RFSpy.java | 6 ++--- .../hw/rileylink/ble/defs/RLMessageType.java | 10 -------- .../hw/rileylink/ble/defs/RLMessageType.kt | 10 ++++++++ .../hw/rileylink/ble/defs/RXFilterMode.java | 19 -------------- .../hw/rileylink/ble/defs/RXFilterMode.kt | 10 ++++++++ .../ble/defs/RileyLinkTargetFrequency.java | 25 ------------------- .../ble/defs/RileyLinkTargetFrequency.kt | 11 ++++++++ 8 files changed, 35 insertions(+), 58 deletions(-) delete mode 100644 rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/defs/RLMessageType.java create mode 100644 rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/defs/RLMessageType.kt delete mode 100644 rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/defs/RXFilterMode.java create mode 100644 rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/defs/RXFilterMode.kt delete mode 100644 rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/defs/RileyLinkTargetFrequency.java create mode 100644 rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/defs/RileyLinkTargetFrequency.kt diff --git a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/service/RileyLinkMedtronicService.kt b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/service/RileyLinkMedtronicService.kt index e5157aadec..4154965d3b 100644 --- a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/service/RileyLinkMedtronicService.kt +++ b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/service/RileyLinkMedtronicService.kt @@ -177,7 +177,7 @@ class RileyLinkMedtronicService : RileyLinkService() { medtronicPumpStatus.pumpFrequency = pumpFrequency val isFrequencyUS = pumpFrequency == frequencies[0] val newTargetFrequency = if (isFrequencyUS) // - RileyLinkTargetFrequency.Medtronic_US else RileyLinkTargetFrequency.Medtronic_WorldWide + RileyLinkTargetFrequency.MedtronicUS else RileyLinkTargetFrequency.MedtronicWorldWide if (rileyLinkServiceData.rileyLinkTargetFrequency != newTargetFrequency) { rileyLinkServiceData.rileyLinkTargetFrequency = newTargetFrequency } diff --git a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/RFSpy.java b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/RFSpy.java index abd0bd5d83..356628cce8 100644 --- a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/RFSpy.java +++ b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/RFSpy.java @@ -309,7 +309,7 @@ public class RFSpy { aapsLogger.error(LTag.PUMPBTCOMM, "RileyLinkTargetFrequency: " + frequency); switch (frequency) { - case Medtronic_WorldWide: + case MedtronicWorldWide: setRXFilterMode(RXFilterMode.Wide); updateRegister(CC111XRegister.mdmcfg1, 0x62); updateRegister(CC111XRegister.mdmcfg0, 0x1A); @@ -317,7 +317,7 @@ public class RFSpy { setMedtronicEncoding(); break; - case Medtronic_US: + case MedtronicUS: setRXFilterMode(RXFilterMode.Narrow); updateRegister(CC111XRegister.mdmcfg1, 0x61); updateRegister(CC111XRegister.mdmcfg0, 0x7E); @@ -400,7 +400,7 @@ public class RFSpy { private void setRXFilterMode(RXFilterMode mode) { byte drate_e = (byte) 0x9; // exponent of symbol rate (16kbps) - byte chanbw = mode.value; + byte chanbw = mode.getValue(); updateRegister(CC111XRegister.mdmcfg4, (byte) (chanbw | drate_e)); } diff --git a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/defs/RLMessageType.java b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/defs/RLMessageType.java deleted file mode 100644 index 7cc11da498..0000000000 --- a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/defs/RLMessageType.java +++ /dev/null @@ -1,10 +0,0 @@ -package info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.defs; - -/** - * Created by andy on 5/6/18. - */ - -public enum RLMessageType { - PowerOn, // for powering on the pump (wakeup) - ReadSimpleData, // for checking if pump is readable (for Medtronic we can use GetModel) -} diff --git a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/defs/RLMessageType.kt b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/defs/RLMessageType.kt new file mode 100644 index 0000000000..f64cd6666f --- /dev/null +++ b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/defs/RLMessageType.kt @@ -0,0 +1,10 @@ +package info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.defs + +/** + * Created by andy on 5/6/18. + */ +enum class RLMessageType { + + PowerOn, // for powering on the pump (wakeup) + ReadSimpleData // for checking if pump is readable (for Medtronic we can use GetModel) +} \ No newline at end of file diff --git a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/defs/RXFilterMode.java b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/defs/RXFilterMode.java deleted file mode 100644 index e50929ebfe..0000000000 --- a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/defs/RXFilterMode.java +++ /dev/null @@ -1,19 +0,0 @@ -package info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.defs; - -/** - * Created by andy on 21/05/2018. - */ - -public enum RXFilterMode { - - Wide(0x50), // - Narrow(0x90) // - ; - - public byte value; - - - RXFilterMode(int value) { - this.value = (byte)value; - } -} diff --git a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/defs/RXFilterMode.kt b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/defs/RXFilterMode.kt new file mode 100644 index 0000000000..9150be1789 --- /dev/null +++ b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/defs/RXFilterMode.kt @@ -0,0 +1,10 @@ +package info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.defs + +/** + * Created by andy on 21/05/2018. + */ +enum class RXFilterMode(val value: Byte) { + + Wide(0x50), + Narrow(0x90.toByte()); +} \ No newline at end of file diff --git a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/defs/RileyLinkTargetFrequency.java b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/defs/RileyLinkTargetFrequency.java deleted file mode 100644 index 0d7f341584..0000000000 --- a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/defs/RileyLinkTargetFrequency.java +++ /dev/null @@ -1,25 +0,0 @@ -package info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.defs; - -/** - * Created by andy on 6/7/18. - */ - -public enum RileyLinkTargetFrequency { - - Medtronic_WorldWide(868.25, 868.3, 868.35, 868.4, 868.45, 868.5, 868.55, 868.6, 868.65), // - Medtronic_US(916.45, 916.5, 916.55, 916.6, 916.65, 916.7, 916.75, 916.8), // - Omnipod(433.91), // - ; - - double[] frequencies; - - - RileyLinkTargetFrequency(double... frequencies) { - this.frequencies = frequencies; - } - - - public double[] getScanFrequencies() { - return frequencies; - } -} diff --git a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/defs/RileyLinkTargetFrequency.kt b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/defs/RileyLinkTargetFrequency.kt new file mode 100644 index 0000000000..8a50374cde --- /dev/null +++ b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/ble/defs/RileyLinkTargetFrequency.kt @@ -0,0 +1,11 @@ +package info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.defs + +/** + * Created by andy on 6/7/18. + */ +enum class RileyLinkTargetFrequency(vararg var scanFrequencies: Double) { + + MedtronicWorldWide(868.25, 868.3, 868.35, 868.4, 868.45, 868.5, 868.55, 868.6, 868.65), + MedtronicUS(916.45, 916.5, 916.55, 916.6, 916.65, 916.7, 916.75, 916.8), + Omnipod(433.91); +} \ No newline at end of file