Inject RileyLinkServiceData in SetPreamble command and remove some unused code

This commit is contained in:
Bart Sopers 2020-08-09 19:11:00 +02:00
parent 1787afda98
commit e74e80a4ce
5 changed files with 4 additions and 12 deletions

View file

@ -38,9 +38,6 @@ public class RileyLinkUtil {
private RileyLinkEncodingType encoding;
private Encoding4b6b encoding4b6b;
// TODO maybe not needed
private RileyLinkTargetFrequency rileyLinkTargetFrequency;
@Inject
public RileyLinkUtil() {
}
@ -158,8 +155,4 @@ public class RileyLinkUtil {
public Encoding4b6b getEncoding4b6b() {
return encoding4b6b;
}
public void setRileyLinkTargetFrequency(RileyLinkTargetFrequency rileyLinkTargetFrequency_) {
this.rileyLinkTargetFrequency = rileyLinkTargetFrequency_;
}
}

View file

@ -387,7 +387,7 @@ public class RFSpy {
try {
resp = writeToData(new SetPreamble(injector, preamble), EXPECTED_MAX_BLUETOOTH_LATENCY_MS);
} catch (Exception e) {
e.toString();
aapsLogger.error("Failed to set preamble", e);
}
return resp;
}

View file

@ -18,10 +18,11 @@ public class SetPreamble extends RileyLinkCommand {
private int preamble;
public SetPreamble(HasAndroidInjector injector, int preamble) throws Exception {
super();
injector.androidInjector().inject(this);
// this command was not supported before 2.0
if (!rileyLinkServiceData.firmwareVersion.isSameVersion(RileyLinkFirmwareVersion.Version2AndHigher)) {
throw new NotImplementedException("Old firmware does not support SetPreamble command");

View file

@ -150,7 +150,7 @@ public class RileyLinkBroadcastReceiver extends DaggerBroadcastReceiver {
return true;
} else if (action.equals(RileyLinkConst.Intents.RileyLinkReady)) {
aapsLogger.warn(LTag.PUMPCOMM, "MedtronicConst.Intents.RileyLinkReady");
aapsLogger.warn(LTag.PUMPCOMM, "RileyLinkConst.Intents.RileyLinkReady");
// sendIPCNotification(RT2Const.IPC.MSG_note_WakingPump);
rileyLinkService.rileyLinkBLE.enableNotifications();

View file

@ -67,12 +67,10 @@ public class RileyLinkServiceData {
return workWithServiceState(null, null, false);
}
public void setServiceState(RileyLinkServiceState newState, RileyLinkError errorCode) {
workWithServiceState(newState, errorCode, true);
}
private synchronized RileyLinkServiceState workWithServiceState(RileyLinkServiceState newState, RileyLinkError errorCode, boolean set) {
if (set) {