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() { public void initializeRileyLink() {
bleVersion = getVersion(); bleVersion = getVersion();
rileyLinkServiceData.firmwareVersion = getFirmwareVersion(); rileyLinkServiceData.firmwareVersion = getFirmwareVersion();
rileyLinkServiceData.versionCC110 = getCC1110Version();
} }
@ -129,9 +131,7 @@ public class RFSpy {
return (firmwareVersion != RileyLinkFirmwareVersion.UnknownVersion); return (firmwareVersion != RileyLinkFirmwareVersion.UnknownVersion);
} }
private String getCC1110Version() {
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,16 +146,27 @@ 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) {
if (versionString.indexOf('s') >= 0) {
versionString = versionString.substring(versionString.indexOf('s'));
}
return versionString;
}
SystemClock.sleep(1000);
}
}
RileyLinkFirmwareVersion version = RileyLinkFirmwareVersion.getByVersionString(StringUtil return null;
.fromBytes(response)); }
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); aapsLogger.debug(LTag.PUMPBTCOMM, "Firmware Version string: {}, resolved to {}.", versionString, version);
if (version != RileyLinkFirmwareVersion.UnknownVersion) if (version != RileyLinkFirmwareVersion.UnknownVersion) {
return version; return version;
SystemClock.sleep(1000);
} }
} }
@ -168,7 +179,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?

View file

@ -74,7 +74,7 @@ public class RadioResponse {
} }
byte[] encodedPayload; byte[] encodedPayload;
if (RileyLinkFirmwareVersion.isSameVersion(rileyLinkServiceData.versionCC110, if (RileyLinkFirmwareVersion.isSameVersion(rileyLinkServiceData.firmwareVersion,
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];

View file

@ -12,12 +12,13 @@ public enum RileyLinkFirmwareVersion {
Version_1_0(1, 0, "1.0"), // Version_1_0(1, 0, "1.0"), //
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"), //
UnknownVersion(null, null, "???"), //
Version1(Version_0_0, Version_0_9, Version_1_0), // Version1(Version_0_0, Version_0_9, Version_1_0), //
Version2(Version_2_0, Version_2_2), // Version2(Version_2_0, Version_2_2, Version_2_x), //
Version2AndHigher(Version_2_0, Version_2_2, Version_3_x, Version_4_x), // Version2AndHigher(Version2, Version_3_x, Version_4_x), //
; ;
private static final String FIRMWARE_IDENTIFICATION_PREFIX = "subg_rfspy "; private static final String FIRMWARE_IDENTIFICATION_PREFIX = "subg_rfspy ";
@ -35,12 +36,12 @@ public enum RileyLinkFirmwareVersion {
} }
protected RileyLinkFirmwareVersion[] familyMembers; protected RileyLinkFirmwareVersion[] familyMembers;
private int major; private Integer major;
private int minor; private Integer minor;
private String versionKey = ""; private String versionKey = "";
RileyLinkFirmwareVersion(int major, int minor, String versionKey) { RileyLinkFirmwareVersion(Integer major, Integer minor, String versionKey) {
this.major = major; this.major = major;
this.minor = minor; this.minor = minor;
this.versionKey = versionKey; this.versionKey = versionKey;
@ -86,8 +87,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;
} }

View file

@ -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);
} }
} }

View file

@ -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);

View file

@ -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;