Merge pull request #125 from AAPS-Omnipod/omnipod_eros_dev_upstream_merge
Improve RileyLink version detection
This commit is contained in:
commit
54a81458c7
13 changed files with 194 additions and 60 deletions
|
@ -246,7 +246,7 @@ dependencies {
|
||||||
|
|
||||||
testImplementation "junit:junit:$junit_version"
|
testImplementation "junit:junit:$junit_version"
|
||||||
testImplementation 'org.json:json:20200518'
|
testImplementation 'org.json:json:20200518'
|
||||||
testImplementation "org.mockito:mockito-core:2.8.47"
|
testImplementation "org.mockito:mockito-core:${mockitoVersion}"
|
||||||
testImplementation "org.powermock:powermock-api-mockito2:${powermockVersion}"
|
testImplementation "org.powermock:powermock-api-mockito2:${powermockVersion}"
|
||||||
testImplementation "org.powermock:powermock-module-junit4-rule-agent:${powermockVersion}"
|
testImplementation "org.powermock:powermock-module-junit4-rule-agent:${powermockVersion}"
|
||||||
testImplementation "org.powermock:powermock-module-junit4-rule:${powermockVersion}"
|
testImplementation "org.powermock:powermock-module-junit4-rule:${powermockVersion}"
|
||||||
|
|
|
@ -23,6 +23,7 @@ buildscript {
|
||||||
work_version = '2.4.0'
|
work_version = '2.4.0'
|
||||||
|
|
||||||
junit_version = '4.13.1'
|
junit_version = '4.13.1'
|
||||||
|
mockitoVersion = '2.8.47'
|
||||||
powermockVersion = "1.7.3"
|
powermockVersion = "1.7.3"
|
||||||
dexmakerVersion = "1.2"
|
dexmakerVersion = "1.2"
|
||||||
retrofit2Version = '2.9.0'
|
retrofit2Version = '2.9.0'
|
||||||
|
|
|
@ -59,7 +59,7 @@ dependencies {
|
||||||
kapt "com.google.dagger:dagger-compiler:$dagger_version"
|
kapt "com.google.dagger:dagger-compiler:$dagger_version"
|
||||||
|
|
||||||
testImplementation "junit:junit:$junit_version"
|
testImplementation "junit:junit:$junit_version"
|
||||||
testImplementation "org.mockito:mockito-core:2.8.47"
|
testImplementation "org.mockito:mockito-core:${mockitoVersion}"
|
||||||
testImplementation "org.powermock:powermock-api-mockito2:$powermockVersion"
|
testImplementation "org.powermock:powermock-api-mockito2:$powermockVersion"
|
||||||
testImplementation "org.powermock:powermock-module-junit4:${powermockVersion}"
|
testImplementation "org.powermock:powermock-module-junit4:${powermockVersion}"
|
||||||
testImplementation 'joda-time:joda-time:2.10.6'
|
testImplementation 'joda-time:joda-time:2.10.6'
|
||||||
|
|
|
@ -50,6 +50,9 @@ dependencies {
|
||||||
kapt "com.google.dagger:dagger-compiler:$dagger_version"
|
kapt "com.google.dagger:dagger-compiler:$dagger_version"
|
||||||
|
|
||||||
testImplementation "junit:junit:$junit_version"
|
testImplementation "junit:junit:$junit_version"
|
||||||
|
testImplementation "org.mockito:mockito-core:${mockitoVersion}"
|
||||||
|
testImplementation "org.powermock:powermock-api-mockito2:${powermockVersion}"
|
||||||
|
testImplementation "org.powermock:powermock-module-junit4:${powermockVersion}"
|
||||||
androidTestImplementation "androidx.test.ext:junit:$androidx_junit"
|
androidTestImplementation "androidx.test.ext:junit:$androidx_junit"
|
||||||
androidTestImplementation "androidx.test:rules:$androidx_rules"
|
androidTestImplementation "androidx.test:rules:$androidx_rules"
|
||||||
}
|
}
|
||||||
|
|
|
@ -98,7 +98,9 @@ public class RFSpy {
|
||||||
// firmware version
|
// firmware version
|
||||||
public void initializeRileyLink() {
|
public void initializeRileyLink() {
|
||||||
bleVersion = getVersion();
|
bleVersion = getVersion();
|
||||||
rileyLinkServiceData.firmwareVersion = getFirmwareVersion();
|
String cc1110Version = getCC1110Version();
|
||||||
|
rileyLinkServiceData.versionCC110 = cc1110Version;
|
||||||
|
rileyLinkServiceData.firmwareVersion = getFirmwareVersion(aapsLogger, bleVersion, cc1110Version);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -123,15 +125,7 @@ public class RFSpy {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isRileyLinkStillAvailable() {
|
private String getCC1110Version() {
|
||||||
RileyLinkFirmwareVersion firmwareVersion = getFirmwareVersion();
|
|
||||||
|
|
||||||
return (firmwareVersion != RileyLinkFirmwareVersion.UnknownVersion);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private RileyLinkFirmwareVersion getFirmwareVersion() {
|
|
||||||
|
|
||||||
aapsLogger.debug(LTag.PUMPBTCOMM, "Firmware Version. Get Version - Start");
|
aapsLogger.debug(LTag.PUMPBTCOMM, "Firmware Version. Get Version - Start");
|
||||||
|
|
||||||
for (int i = 0; i < 5; i++) {
|
for (int i = 0; i < 5; i++) {
|
||||||
|
@ -146,19 +140,29 @@ public class RFSpy {
|
||||||
if (response != null) { // && response[0] == (byte) 0xDD) {
|
if (response != null) { // && response[0] == (byte) 0xDD) {
|
||||||
|
|
||||||
String versionString = StringUtil.fromBytes(response);
|
String versionString = StringUtil.fromBytes(response);
|
||||||
|
if (versionString.length() > 3) {
|
||||||
RileyLinkFirmwareVersion version = RileyLinkFirmwareVersion.getByVersionString(StringUtil
|
if (versionString.indexOf('s') >= 0) {
|
||||||
.fromBytes(response));
|
versionString = versionString.substring(versionString.indexOf('s'));
|
||||||
|
}
|
||||||
aapsLogger.debug(LTag.PUMPBTCOMM, "Firmware Version string: {}, resolved to {}.", versionString, version);
|
return versionString;
|
||||||
|
}
|
||||||
if (version != RileyLinkFirmwareVersion.UnknownVersion)
|
|
||||||
return version;
|
|
||||||
|
|
||||||
SystemClock.sleep(1000);
|
SystemClock.sleep(1000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
static RileyLinkFirmwareVersion getFirmwareVersion(AAPSLogger aapsLogger, String bleVersion, String cc1110Version) {
|
||||||
|
if (cc1110Version != null) {
|
||||||
|
RileyLinkFirmwareVersion version = RileyLinkFirmwareVersion.getByVersionString(cc1110Version);
|
||||||
|
aapsLogger.debug(LTag.PUMPBTCOMM, "Firmware Version string: {}, resolved to {}.", cc1110Version, version);
|
||||||
|
|
||||||
|
if (version != RileyLinkFirmwareVersion.UnknownVersion) {
|
||||||
|
return version;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
aapsLogger.error(LTag.PUMPBTCOMM, "Firmware Version can't be determined. Checking with BLE Version [{}].", bleVersion);
|
aapsLogger.error(LTag.PUMPBTCOMM, "Firmware Version can't be determined. Checking with BLE Version [{}].", bleVersion);
|
||||||
|
|
||||||
if (bleVersion.contains(" 2.")) {
|
if (bleVersion.contains(" 2.")) {
|
||||||
|
@ -168,7 +172,6 @@ public class RFSpy {
|
||||||
return RileyLinkFirmwareVersion.UnknownVersion;
|
return RileyLinkFirmwareVersion.UnknownVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private byte[] writeToDataRaw(byte[] bytes, int responseTimeout_ms) {
|
private byte[] writeToDataRaw(byte[] bytes, int responseTimeout_ms) {
|
||||||
SystemClock.sleep(100);
|
SystemClock.sleep(100);
|
||||||
// FIXME drain read queue?
|
// FIXME drain read queue?
|
||||||
|
@ -373,7 +376,7 @@ public class RFSpy {
|
||||||
private void setMedtronicEncoding() {
|
private void setMedtronicEncoding() {
|
||||||
RileyLinkEncodingType encoding = RileyLinkEncodingType.FourByteSixByteLocal;
|
RileyLinkEncodingType encoding = RileyLinkEncodingType.FourByteSixByteLocal;
|
||||||
|
|
||||||
if (RileyLinkFirmwareVersion.isSameVersion(rileyLinkServiceData.firmwareVersion, RileyLinkFirmwareVersion.Version2AndHigher)) {
|
if (rileyLinkServiceData.firmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version2AndHigher)) {
|
||||||
if (sp.getString(RileyLinkConst.Prefs.Encoding, "None")
|
if (sp.getString(RileyLinkConst.Prefs.Encoding, "None")
|
||||||
.equals(resourceHelper.gs(R.string.key_medtronic_pump_encoding_4b6b_rileylink))) {
|
.equals(resourceHelper.gs(R.string.key_medtronic_pump_encoding_4b6b_rileylink))) {
|
||||||
encoding = RileyLinkEncodingType.FourByteSixByteRileyLink;
|
encoding = RileyLinkEncodingType.FourByteSixByteRileyLink;
|
||||||
|
|
|
@ -74,8 +74,7 @@ public class RadioResponse {
|
||||||
}
|
}
|
||||||
byte[] encodedPayload;
|
byte[] encodedPayload;
|
||||||
|
|
||||||
if (RileyLinkFirmwareVersion.isSameVersion(rileyLinkServiceData.versionCC110,
|
if (rileyLinkServiceData.firmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version2AndHigher)) {
|
||||||
RileyLinkFirmwareVersion.Version2AndHigher)) {
|
|
||||||
encodedPayload = ByteUtil.substring(rxData, 3, rxData.length - 3);
|
encodedPayload = ByteUtil.substring(rxData, 3, rxData.length - 3);
|
||||||
rssi = rxData[1];
|
rssi = rxData[1];
|
||||||
responseNumber = rxData[2];
|
responseNumber = rxData[2];
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
package info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.defs;
|
package info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.defs;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
@ -10,19 +13,22 @@ public enum RileyLinkFirmwareVersion {
|
||||||
Version_0_0(0, 0, "0.0"), // just for defaulting
|
Version_0_0(0, 0, "0.0"), // just for defaulting
|
||||||
Version_0_9(0, 9, "0.9"), //
|
Version_0_9(0, 9, "0.9"), //
|
||||||
Version_1_0(1, 0, "1.0"), //
|
Version_1_0(1, 0, "1.0"), //
|
||||||
|
Version_1_x(1, null, "1.x"), //
|
||||||
Version_2_0(2, 0, "2.0"), //
|
Version_2_0(2, 0, "2.0"), //
|
||||||
Version_2_2(2, 2, "2.2"), //
|
Version_2_2(2, 2, "2.2"), //
|
||||||
Version_3_x(3, 0, "3.x"), //
|
Version_2_x(2, null, "2.x"), //
|
||||||
Version_4_x(4, 0, "4.x"), //
|
Version_3_x(3, null, "3.x"), //
|
||||||
UnknownVersion(0, 0, "???"), //
|
Version_4_x(4, null, "4.x"), //
|
||||||
Version1(Version_0_0, Version_0_9, Version_1_0), //
|
UnknownVersion(null, null, "???"), //
|
||||||
Version2(Version_2_0, Version_2_2), //
|
Version1(Version_0_0, Version_0_9, Version_1_0, Version_1_x), //
|
||||||
Version2AndHigher(Version_2_0, Version_2_2, Version_3_x, Version_4_x), //
|
Version2(Version_2_0, Version_2_2, Version_2_x), //
|
||||||
;
|
Version3(Version_3_x), //
|
||||||
|
Version4(Version_4_x), //
|
||||||
|
Version2AndHigher(Version2, Version3, Version4);
|
||||||
|
|
||||||
private static final String FIRMWARE_IDENTIFICATION_PREFIX = "subg_rfspy ";
|
private static final String FIRMWARE_IDENTIFICATION_PREFIX = "subg_rfspy ";
|
||||||
private static final Pattern _version_pattern = Pattern.compile(FIRMWARE_IDENTIFICATION_PREFIX
|
private static final Pattern _version_pattern = Pattern.compile(FIRMWARE_IDENTIFICATION_PREFIX
|
||||||
+ "([0-9]+)\\.([0-9]+)");
|
+ "([0-9]+)\\.([0-9]+)");
|
||||||
static Map<String, RileyLinkFirmwareVersion> mapByVersion;
|
static Map<String, RileyLinkFirmwareVersion> mapByVersion;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
@ -34,13 +40,12 @@ public enum RileyLinkFirmwareVersion {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected RileyLinkFirmwareVersion[] familyMembers;
|
private List<RileyLinkFirmwareVersion> familyMembers;
|
||||||
private int major;
|
private Integer major;
|
||||||
private int minor;
|
private Integer minor;
|
||||||
private String versionKey = "";
|
private String versionKey = "";
|
||||||
|
|
||||||
|
RileyLinkFirmwareVersion(Integer major, Integer minor, String versionKey) {
|
||||||
RileyLinkFirmwareVersion(int major, int minor, String versionKey) {
|
|
||||||
this.major = major;
|
this.major = major;
|
||||||
this.minor = minor;
|
this.minor = minor;
|
||||||
this.versionKey = versionKey;
|
this.versionKey = versionKey;
|
||||||
|
@ -48,23 +53,39 @@ public enum RileyLinkFirmwareVersion {
|
||||||
|
|
||||||
|
|
||||||
RileyLinkFirmwareVersion(RileyLinkFirmwareVersion... familyMembers) {
|
RileyLinkFirmwareVersion(RileyLinkFirmwareVersion... familyMembers) {
|
||||||
this.familyMembers = familyMembers;
|
this.familyMembers = Arrays.asList(familyMembers);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean hasFamilyMembers() {
|
||||||
|
return familyMembers != null;
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean isSameVersion(RileyLinkFirmwareVersion versionWeCheck, RileyLinkFirmwareVersion versionSources) {
|
private List<RileyLinkFirmwareVersion> getFamilyMembersRecursive() {
|
||||||
if (versionSources.familyMembers != null) {
|
List<RileyLinkFirmwareVersion> members = new ArrayList<>();
|
||||||
for (RileyLinkFirmwareVersion vrs : versionSources.familyMembers) {
|
if (hasFamilyMembers()) {
|
||||||
if (vrs == versionWeCheck)
|
for (RileyLinkFirmwareVersion version : familyMembers) {
|
||||||
return true;
|
members.add(version);
|
||||||
|
if (version.hasFamilyMembers()) {
|
||||||
|
members.addAll(version.getFamilyMembersRecursive());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
return (versionWeCheck == versionSources);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return members;
|
||||||
|
}
|
||||||
|
|
||||||
|
static boolean isSameVersion(RileyLinkFirmwareVersion versionWeCheck, RileyLinkFirmwareVersion versionSources) {
|
||||||
|
if (versionWeCheck == versionSources) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (versionSources.familyMembers != null) {
|
||||||
|
return versionSources.getFamilyMembersRecursive().contains(versionWeCheck);
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static RileyLinkFirmwareVersion getByVersionString(String versionString) {
|
public static RileyLinkFirmwareVersion getByVersionString(String versionString) {
|
||||||
if (versionString != null) {
|
if (versionString != null) {
|
||||||
Matcher m = _version_pattern.matcher(versionString);
|
Matcher m = _version_pattern.matcher(versionString);
|
||||||
|
@ -76,7 +97,7 @@ public enum RileyLinkFirmwareVersion {
|
||||||
return mapByVersion.get(versionKey);
|
return mapByVersion.get(versionKey);
|
||||||
} else {
|
} else {
|
||||||
return defaultToLowestMajorVersion(major); // just in case there is new release that we don't cover
|
return defaultToLowestMajorVersion(major); // just in case there is new release that we don't cover
|
||||||
// example: 2.3 etc
|
// example: 2.3 etc
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -86,8 +107,8 @@ public enum RileyLinkFirmwareVersion {
|
||||||
|
|
||||||
|
|
||||||
private static RileyLinkFirmwareVersion defaultToLowestMajorVersion(int major) {
|
private static RileyLinkFirmwareVersion defaultToLowestMajorVersion(int major) {
|
||||||
if (mapByVersion.containsKey(major + ".0")) {
|
if (mapByVersion.containsKey(major + ".x")) {
|
||||||
return mapByVersion.get(major + ".0");
|
return mapByVersion.get(major + ".x");
|
||||||
}
|
}
|
||||||
return UnknownVersion;
|
return UnknownVersion;
|
||||||
}
|
}
|
||||||
|
@ -100,6 +121,9 @@ public enum RileyLinkFirmwareVersion {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
|
if (hasFamilyMembers()) {
|
||||||
|
return FIRMWARE_IDENTIFICATION_PREFIX + name();
|
||||||
|
}
|
||||||
return FIRMWARE_IDENTIFICATION_PREFIX + versionKey;
|
return FIRMWARE_IDENTIFICATION_PREFIX + versionKey;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -108,13 +108,11 @@ public class RileyLinkStatusGeneralFragment extends DaggerFragment implements Re
|
||||||
"-"
|
"-"
|
||||||
: resourceHelper.gs(rileyLinkServiceData.rileyLinkError.getResourceId(targetDevice)));
|
: resourceHelper.gs(rileyLinkServiceData.rileyLinkError.getResourceId(targetDevice)));
|
||||||
|
|
||||||
RileyLinkFirmwareVersion firmwareVersion = rileyLinkServiceData.versionCC110;
|
|
||||||
|
|
||||||
if (firmwareVersion == null) {
|
if (firmwareVersion == null) {
|
||||||
this.firmwareVersion.setText("BLE113: -\nCC110: -");
|
this.firmwareVersion.setText("BLE113: -\nCC110: -");
|
||||||
} else {
|
} else {
|
||||||
this.firmwareVersion.setText("BLE113: " + rileyLinkServiceData.versionBLE113 + //
|
this.firmwareVersion.setText("BLE113: " + rileyLinkServiceData.versionBLE113 +
|
||||||
"\nCC110: " + firmwareVersion.toString());
|
"\nCC110: " + rileyLinkServiceData.versionCC110);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -159,7 +159,7 @@ public class RileyLinkBroadcastReceiver extends DaggerBroadcastReceiver {
|
||||||
|
|
||||||
// if (isLoggingEnabled())
|
// if (isLoggingEnabled())
|
||||||
aapsLogger.debug(LTag.PUMPBTCOMM, "RfSpy Radio version (CC110): " + rlVersion.name());
|
aapsLogger.debug(LTag.PUMPBTCOMM, "RfSpy Radio version (CC110): " + rlVersion.name());
|
||||||
this.rileyLinkServiceData.versionCC110 = rlVersion;
|
this.rileyLinkServiceData.firmwareVersion = rlVersion;
|
||||||
|
|
||||||
ServiceTask task = new InitializePumpManagerTask(injector, context);
|
ServiceTask task = new InitializePumpManagerTask(injector, context);
|
||||||
serviceTaskExecutor.startTask(task);
|
serviceTaskExecutor.startTask(task);
|
||||||
|
|
|
@ -32,7 +32,7 @@ public class RileyLinkServiceData {
|
||||||
public RileyLinkError rileyLinkError;
|
public RileyLinkError rileyLinkError;
|
||||||
public RileyLinkServiceState rileyLinkServiceState = RileyLinkServiceState.NotStarted;
|
public RileyLinkServiceState rileyLinkServiceState = RileyLinkServiceState.NotStarted;
|
||||||
private long lastServiceStateChange = 0L;
|
private long lastServiceStateChange = 0L;
|
||||||
public RileyLinkFirmwareVersion firmwareVersion;
|
public RileyLinkFirmwareVersion firmwareVersion; // here we have "compatibility level" version
|
||||||
public RileyLinkTargetFrequency rileyLinkTargetFrequency;
|
public RileyLinkTargetFrequency rileyLinkTargetFrequency;
|
||||||
public String rileylinkAddress;
|
public String rileylinkAddress;
|
||||||
long lastTuneUpTime = 0L;
|
long lastTuneUpTime = 0L;
|
||||||
|
@ -41,7 +41,8 @@ public class RileyLinkServiceData {
|
||||||
// bt version
|
// bt version
|
||||||
public String versionBLE113;
|
public String versionBLE113;
|
||||||
// radio version
|
// radio version
|
||||||
public RileyLinkFirmwareVersion versionCC110;
|
public String versionCC110;
|
||||||
|
|
||||||
|
|
||||||
public RileyLinkTargetDevice targetDevice;
|
public RileyLinkTargetDevice targetDevice;
|
||||||
|
|
||||||
|
@ -77,7 +78,6 @@ public class RileyLinkServiceData {
|
||||||
private synchronized RileyLinkServiceState workWithServiceState(RileyLinkServiceState newState, RileyLinkError errorCode, boolean set) {
|
private synchronized RileyLinkServiceState workWithServiceState(RileyLinkServiceState newState, RileyLinkError errorCode, boolean set) {
|
||||||
|
|
||||||
if (set) {
|
if (set) {
|
||||||
|
|
||||||
rileyLinkServiceState = newState;
|
rileyLinkServiceState = newState;
|
||||||
lastServiceStateChange = System.currentTimeMillis();
|
lastServiceStateChange = System.currentTimeMillis();
|
||||||
this.rileyLinkError = errorCode;
|
this.rileyLinkError = errorCode;
|
||||||
|
@ -87,7 +87,6 @@ public class RileyLinkServiceData {
|
||||||
rileyLinkUtil.getRileyLinkHistory().add(new RLHistoryItem(rileyLinkServiceState, errorCode, targetDevice));
|
rileyLinkUtil.getRileyLinkHistory().add(new RLHistoryItem(rileyLinkServiceState, errorCode, targetDevice));
|
||||||
rxBus.send(new EventRileyLinkDeviceStatusChange(targetDevice, newState, errorCode));
|
rxBus.send(new EventRileyLinkDeviceStatusChange(targetDevice, newState, errorCode));
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
return rileyLinkServiceState;
|
return rileyLinkServiceState;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,47 @@
|
||||||
|
package info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.mockito.Mock;
|
||||||
|
import org.powermock.modules.junit4.PowerMockRunner;
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.logging.AAPSLogger;
|
||||||
|
import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.defs.RileyLinkFirmwareVersion;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
|
@RunWith(PowerMockRunner.class)
|
||||||
|
public class RFSpyTest {
|
||||||
|
@Mock
|
||||||
|
private AAPSLogger aapsLogger;
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testGetFirmwareVersion() {
|
||||||
|
assertEquals(RileyLinkFirmwareVersion.Version_1_0, RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 1.0"));
|
||||||
|
assertEquals(RileyLinkFirmwareVersion.Version_1_x, RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 1.1"));
|
||||||
|
assertEquals(RileyLinkFirmwareVersion.Version_1_x, RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 1.1.13"));
|
||||||
|
|
||||||
|
assertEquals(RileyLinkFirmwareVersion.Version_2_0, RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 2.0"));
|
||||||
|
assertEquals(RileyLinkFirmwareVersion.Version_2_0, RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 2.0.1"));
|
||||||
|
assertEquals(RileyLinkFirmwareVersion.Version_2_2, RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 2.2"));
|
||||||
|
assertEquals(RileyLinkFirmwareVersion.Version_2_2, RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 2.2.16"));
|
||||||
|
assertEquals(RileyLinkFirmwareVersion.Version_2_2, RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 2.2.17"));
|
||||||
|
assertEquals(RileyLinkFirmwareVersion.Version_2_x, RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 2.3"));
|
||||||
|
assertEquals(RileyLinkFirmwareVersion.Version_2_x, RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 2.3.0"));
|
||||||
|
assertEquals(RileyLinkFirmwareVersion.Version_2_x, RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 2.3.17"));
|
||||||
|
|
||||||
|
assertEquals(RileyLinkFirmwareVersion.Version_3_x, RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 3.0"));
|
||||||
|
assertEquals(RileyLinkFirmwareVersion.Version_3_x, RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 3.0.1"));
|
||||||
|
assertEquals(RileyLinkFirmwareVersion.Version_3_x, RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 3.1"));
|
||||||
|
assertEquals(RileyLinkFirmwareVersion.Version_3_x, RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 3.1.13"));
|
||||||
|
|
||||||
|
assertEquals(RileyLinkFirmwareVersion.Version_4_x, RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 4.0"));
|
||||||
|
assertEquals(RileyLinkFirmwareVersion.Version_4_x, RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 4.0.4"));
|
||||||
|
assertEquals(RileyLinkFirmwareVersion.Version_4_x, RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 4.3"));
|
||||||
|
assertEquals(RileyLinkFirmwareVersion.Version_4_x, RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 4.5.7"));
|
||||||
|
|
||||||
|
assertEquals(RileyLinkFirmwareVersion.UnknownVersion, RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 5.0"));
|
||||||
|
assertEquals(RileyLinkFirmwareVersion.UnknownVersion, RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 5.0.0"));
|
||||||
|
assertEquals(RileyLinkFirmwareVersion.UnknownVersion, RFSpy.getFirmwareVersion(aapsLogger, "", "subg_rfspy 5.5.5"));
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,60 @@
|
||||||
|
package info.nightscout.androidaps.plugins.pump.common.hw.rileylink.ble.defs;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertFalse;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
|
public class RileyLinkFirmwareVersionTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testIsSameVersion() {
|
||||||
|
assertTrue(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version1, RileyLinkFirmwareVersion.Version1));
|
||||||
|
assertTrue(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version_1_0, RileyLinkFirmwareVersion.Version1));
|
||||||
|
assertTrue(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version_0_0, RileyLinkFirmwareVersion.Version1));
|
||||||
|
assertTrue(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version_0_9, RileyLinkFirmwareVersion.Version1));
|
||||||
|
assertTrue(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version_1_x, RileyLinkFirmwareVersion.Version1));
|
||||||
|
assertFalse(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version1, RileyLinkFirmwareVersion.Version_1_0));
|
||||||
|
assertFalse(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version_0_0, RileyLinkFirmwareVersion.Version2AndHigher));
|
||||||
|
assertFalse(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version_1_0, RileyLinkFirmwareVersion.Version2AndHigher));
|
||||||
|
assertFalse(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version_0_9, RileyLinkFirmwareVersion.Version2AndHigher));
|
||||||
|
assertFalse(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version_1_x, RileyLinkFirmwareVersion.Version2AndHigher));
|
||||||
|
assertFalse(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version1, RileyLinkFirmwareVersion.Version2AndHigher));
|
||||||
|
assertFalse(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version2, RileyLinkFirmwareVersion.Version1));
|
||||||
|
assertFalse(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version2AndHigher, RileyLinkFirmwareVersion.Version1));
|
||||||
|
assertFalse(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version3, RileyLinkFirmwareVersion.Version1));
|
||||||
|
assertFalse(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version4, RileyLinkFirmwareVersion.Version1));
|
||||||
|
assertFalse(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version_2_0, RileyLinkFirmwareVersion.Version1));
|
||||||
|
assertFalse(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version_2_2, RileyLinkFirmwareVersion.Version1));
|
||||||
|
assertFalse(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version_2_x, RileyLinkFirmwareVersion.Version1));
|
||||||
|
assertFalse(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version_3_x, RileyLinkFirmwareVersion.Version1));
|
||||||
|
assertFalse(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version_4_x, RileyLinkFirmwareVersion.Version1));
|
||||||
|
|
||||||
|
assertTrue(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version2, RileyLinkFirmwareVersion.Version2));
|
||||||
|
assertTrue(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version2, RileyLinkFirmwareVersion.Version2AndHigher));
|
||||||
|
assertTrue(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version_2_0, RileyLinkFirmwareVersion.Version2));
|
||||||
|
assertTrue(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version_2_0, RileyLinkFirmwareVersion.Version2AndHigher));
|
||||||
|
assertTrue(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version_2_2, RileyLinkFirmwareVersion.Version2));
|
||||||
|
assertTrue(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version_2_2, RileyLinkFirmwareVersion.Version2AndHigher));
|
||||||
|
assertTrue(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version_2_x, RileyLinkFirmwareVersion.Version2));
|
||||||
|
assertTrue(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version_2_x, RileyLinkFirmwareVersion.Version2AndHigher));
|
||||||
|
assertFalse(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version2, RileyLinkFirmwareVersion.Version_2_x));
|
||||||
|
assertFalse(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version3, RileyLinkFirmwareVersion.Version2));
|
||||||
|
assertFalse(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version4, RileyLinkFirmwareVersion.Version2));
|
||||||
|
assertFalse(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version_3_x, RileyLinkFirmwareVersion.Version2));
|
||||||
|
assertFalse(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version_4_x, RileyLinkFirmwareVersion.Version2));
|
||||||
|
|
||||||
|
assertTrue(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version3, RileyLinkFirmwareVersion.Version3));
|
||||||
|
assertTrue(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version3, RileyLinkFirmwareVersion.Version2AndHigher));
|
||||||
|
assertTrue(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version_3_x, RileyLinkFirmwareVersion.Version3));
|
||||||
|
assertTrue(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version_3_x, RileyLinkFirmwareVersion.Version2AndHigher));
|
||||||
|
assertFalse(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version3, RileyLinkFirmwareVersion.Version_3_x));
|
||||||
|
assertFalse(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version4, RileyLinkFirmwareVersion.Version3));
|
||||||
|
|
||||||
|
assertTrue(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version4, RileyLinkFirmwareVersion.Version4));
|
||||||
|
assertTrue(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version4, RileyLinkFirmwareVersion.Version2AndHigher));
|
||||||
|
assertTrue(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version_4_x, RileyLinkFirmwareVersion.Version4));
|
||||||
|
assertTrue(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version_4_x, RileyLinkFirmwareVersion.Version2AndHigher));
|
||||||
|
assertFalse(RileyLinkFirmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version4, RileyLinkFirmwareVersion.Version_4_x));
|
||||||
|
}
|
||||||
|
}
|
|
@ -127,7 +127,7 @@ dependencies {
|
||||||
|
|
||||||
testImplementation "junit:junit:$junit_version"
|
testImplementation "junit:junit:$junit_version"
|
||||||
testImplementation 'org.json:json:20200518'
|
testImplementation 'org.json:json:20200518'
|
||||||
testImplementation("org.mockito:mockito-core:2.8.47") {
|
testImplementation("org.mockito:mockito-core:${mockitoVersion}") {
|
||||||
exclude group: 'net.bytebuddy', module: 'byte-buddy'
|
exclude group: 'net.bytebuddy', module: 'byte-buddy'
|
||||||
exclude group: 'net.bytebuddy', module: 'byte-buddy-android'
|
exclude group: 'net.bytebuddy', module: 'byte-buddy-android'
|
||||||
exclude group: 'net.bytebuddy', module: 'byte-buddy-agent'
|
exclude group: 'net.bytebuddy', module: 'byte-buddy-agent'
|
||||||
|
|
Loading…
Reference in a new issue