RS: handle not received time

This commit is contained in:
Milos Kozak 2019-09-08 10:39:32 +02:00
parent 8b502c93c9
commit 118b4bc0d1
4 changed files with 17 additions and 0 deletions

View file

@ -58,6 +58,9 @@ public class DanaRS_Packet {
public void handleMessage(byte[] data) {
}
public void handleMessageNotReceived() {
}
public String getFriendlyName() {
return "UNKNOWN_PACKET";
}

View file

@ -58,6 +58,11 @@ public class DanaRS_Packet_Option_Get_Pump_Time extends DanaRS_Packet {
}
}
@Override
public void handleMessageNotReceived() {
DanaRPump.getInstance().pumpTime = 0;
}
@Override
public String getFriendlyName() {
return "OPTION__GET_PUMP_TIME";

View file

@ -643,6 +643,7 @@ public class BLEComm {
//SystemClock.sleep(200);
if (!message.isReceived()) {
log.warn("Reply not received " + message.getFriendlyName());
message.handleMessageNotReceived();
}
}

View file

@ -158,6 +158,14 @@ public class DanaRSService extends Service {
bleComm.sendMessage(new DanaRS_Packet_Option_Get_Pump_Time());
long timeDiff = (danaRPump.pumpTime - System.currentTimeMillis()) / 1000L;
if (danaRPump.pumpTime == 0) {
// initial handshake was not successfull
// deinitialize pump
danaRPump.lastConnection = 0;
RxBus.INSTANCE.send(new EventDanaRNewStatus());
MainApp.bus().post(new EventInitializationChanged());
return;
}
if (L.isEnabled(L.PUMPCOMM))
log.debug("Pump time difference: " + timeDiff + " seconds");
if (Math.abs(timeDiff) > 3) {