RS: handle not received time
This commit is contained in:
parent
8b502c93c9
commit
118b4bc0d1
|
@ -58,6 +58,9 @@ public class DanaRS_Packet {
|
|||
public void handleMessage(byte[] data) {
|
||||
}
|
||||
|
||||
public void handleMessageNotReceived() {
|
||||
}
|
||||
|
||||
public String getFriendlyName() {
|
||||
return "UNKNOWN_PACKET";
|
||||
}
|
||||
|
|
|
@ -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";
|
||||
|
|
|
@ -643,6 +643,7 @@ public class BLEComm {
|
|||
//SystemClock.sleep(200);
|
||||
if (!message.isReceived()) {
|
||||
log.warn("Reply not received " + message.getFriendlyName());
|
||||
message.handleMessageNotReceived();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue