Now AAPS recognizes firmwares different than 2.0 and 2.2

Also, the exact version string is shown in the RL Status window
This commit is contained in:
Artiom Kenibasov 2020-12-17 20:46:36 +01:00
parent ae175f3b99
commit 6e30088d1a
6 changed files with 41 additions and 31 deletions

View file

@ -99,6 +99,8 @@ public class RFSpy {
public void initializeRileyLink() {
bleVersion = getVersion();
rileyLinkServiceData.firmwareVersion = getFirmwareVersion();
rileyLinkServiceData.versionCC110 = getCC1110Version();
}
@ -129,9 +131,7 @@ public class RFSpy {
return (firmwareVersion != RileyLinkFirmwareVersion.UnknownVersion);
}
private RileyLinkFirmwareVersion getFirmwareVersion() {
private String getCC1110Version() {
aapsLogger.debug(LTag.PUMPBTCOMM, "Firmware Version. Get Version - Start");
for (int i = 0; i < 5; i++) {
@ -146,19 +146,30 @@ public class RFSpy {
if (response != null) { // && response[0] == (byte) 0xDD) {
String versionString = StringUtil.fromBytes(response);
RileyLinkFirmwareVersion version = RileyLinkFirmwareVersion.getByVersionString(StringUtil
.fromBytes(response));
aapsLogger.debug(LTag.PUMPBTCOMM, "Firmware Version string: {}, resolved to {}.", versionString, version);
if (version != RileyLinkFirmwareVersion.UnknownVersion)
return version;
if (versionString.length() > 3) {
if (versionString.indexOf('s') >= 0) {
versionString = versionString.substring(versionString.indexOf('s'));
}
return versionString;
}
SystemClock.sleep(1000);
}
}
return null;
}
private RileyLinkFirmwareVersion getFirmwareVersion() {
String versionString = getCC1110Version();
if (versionString != null) {
RileyLinkFirmwareVersion version = RileyLinkFirmwareVersion.getByVersionString(versionString);
aapsLogger.debug(LTag.PUMPBTCOMM, "Firmware Version string: {}, resolved to {}.", versionString, version);
if (version != RileyLinkFirmwareVersion.UnknownVersion) {
return version;
}
}
aapsLogger.error(LTag.PUMPBTCOMM, "Firmware Version can't be determined. Checking with BLE Version [{}].", bleVersion);
if (bleVersion.contains(" 2.")) {
@ -168,7 +179,6 @@ public class RFSpy {
return RileyLinkFirmwareVersion.UnknownVersion;
}
private byte[] writeToDataRaw(byte[] bytes, int responseTimeout_ms) {
SystemClock.sleep(100);
// FIXME drain read queue?

View file

@ -74,7 +74,7 @@ public class RadioResponse {
}
byte[] encodedPayload;
if (RileyLinkFirmwareVersion.isSameVersion(rileyLinkServiceData.versionCC110,
if (RileyLinkFirmwareVersion.isSameVersion(rileyLinkServiceData.firmwareVersion,
RileyLinkFirmwareVersion.Version2AndHigher)) {
encodedPayload = ByteUtil.substring(rxData, 3, rxData.length - 3);
rssi = rxData[1];

View file

@ -12,12 +12,13 @@ public enum RileyLinkFirmwareVersion {
Version_1_0(1, 0, "1.0"), //
Version_2_0(2, 0, "2.0"), //
Version_2_2(2, 2, "2.2"), //
Version_3_x(3, 0, "3.x"), //
Version_4_x(4, 0, "4.x"), //
UnknownVersion(0, 0, "???"), //
Version_2_x(2, null, "2.x"), //
Version_3_x(3, null, "3.x"), //
Version_4_x(4, null, "4.x"), //
UnknownVersion(null, null, "???"), //
Version1(Version_0_0, Version_0_9, Version_1_0), //
Version2(Version_2_0, Version_2_2), //
Version2AndHigher(Version_2_0, Version_2_2, Version_3_x, Version_4_x), //
Version2(Version_2_0, Version_2_2, Version_2_x), //
Version2AndHigher(Version2, Version_3_x, Version_4_x), //
;
private static final String FIRMWARE_IDENTIFICATION_PREFIX = "subg_rfspy ";
@ -35,12 +36,12 @@ public enum RileyLinkFirmwareVersion {
}
protected RileyLinkFirmwareVersion[] familyMembers;
private int major;
private int minor;
private Integer major;
private Integer minor;
private String versionKey = "";
RileyLinkFirmwareVersion(int major, int minor, String versionKey) {
RileyLinkFirmwareVersion(Integer major, Integer minor, String versionKey) {
this.major = major;
this.minor = minor;
this.versionKey = versionKey;
@ -86,8 +87,8 @@ public enum RileyLinkFirmwareVersion {
private static RileyLinkFirmwareVersion defaultToLowestMajorVersion(int major) {
if (mapByVersion.containsKey(major + ".0")) {
return mapByVersion.get(major + ".0");
if (mapByVersion.containsKey(major + ".x")) {
return mapByVersion.get(major + ".x");
}
return UnknownVersion;
}

View file

@ -108,13 +108,11 @@ public class RileyLinkStatusGeneralFragment extends DaggerFragment implements Re
"-"
: resourceHelper.gs(rileyLinkServiceData.rileyLinkError.getResourceId(targetDevice)));
RileyLinkFirmwareVersion firmwareVersion = rileyLinkServiceData.versionCC110;
if (firmwareVersion == null) {
this.firmwareVersion.setText("BLE113: -\nCC110: -");
} else {
this.firmwareVersion.setText("BLE113: " + rileyLinkServiceData.versionBLE113 + //
"\nCC110: " + firmwareVersion.toString());
this.firmwareVersion.setText("BLE113: " + rileyLinkServiceData.versionBLE113 +
"\nCC110: " + rileyLinkServiceData.versionCC110);
}
}

View file

@ -159,7 +159,7 @@ public class RileyLinkBroadcastReceiver extends DaggerBroadcastReceiver {
// if (isLoggingEnabled())
aapsLogger.debug(LTag.PUMPBTCOMM, "RfSpy Radio version (CC110): " + rlVersion.name());
this.rileyLinkServiceData.versionCC110 = rlVersion;
this.rileyLinkServiceData.firmwareVersion = rlVersion;
ServiceTask task = new InitializePumpManagerTask(injector, context);
serviceTaskExecutor.startTask(task);

View file

@ -32,7 +32,7 @@ public class RileyLinkServiceData {
public RileyLinkError rileyLinkError;
public RileyLinkServiceState rileyLinkServiceState = RileyLinkServiceState.NotStarted;
private long lastServiceStateChange = 0L;
public RileyLinkFirmwareVersion firmwareVersion;
public RileyLinkFirmwareVersion firmwareVersion; // here we have "compatibility level" version
public RileyLinkTargetFrequency rileyLinkTargetFrequency;
public String rileylinkAddress;
long lastTuneUpTime = 0L;
@ -41,7 +41,8 @@ public class RileyLinkServiceData {
// bt version
public String versionBLE113;
// radio version
public RileyLinkFirmwareVersion versionCC110;
public String versionCC110;
public RileyLinkTargetDevice targetDevice;