use of sugar.free.sightparser.applayer.messages.status.ReadDateTimeMessage in project SightRemote by TebbeUbben.
the class HistorySyncService method onResult.
@Override
public void onResult(Object result) {
if (result instanceof ReadStatusParamBlockMessage) {
pumpSerialNumber = ((SystemIdentificationBlock) ((ReadStatusParamBlockMessage) result).getStatusBlock()).getSerialNumber();
new SingleMessageTaskRunner(connector, new ReadDateTimeMessage()).fetch(this);
} else if (result instanceof ReadHistoryTaskRunner.HistoryResult) {
ReadHistoryTaskRunner.HistoryResult historyResult = (ReadHistoryTaskRunner.HistoryResult) result;
List<HistoryFrame> historyFrames = historyResult.getHistoryFrames();
if (historyResult.getLatestEventNumber() > 0)
Offset.setOffset(getDatabaseHelper(), pumpSerialNumber, HistoryType.ALL, historyResult.getLatestEventNumber());
connector.disconnect();
connector.disconnectFromService();
processHistoryFrames(historyFrames);
syncing = false;
sendBroadcast(new Intent(HistoryBroadcast.ACTION_SYNC_FINISHED));
if (wakeLock.isHeld())
wakeLock.release();
} else if (result instanceof ReadDateTimeMessage) {
ReadDateTimeMessage dateTimeMessage = (ReadDateTimeMessage) result;
Date pumpDate = parseDateTime(dateTimeMessage.getYear(), dateTimeMessage.getMonth(), dateTimeMessage.getDay(), dateTimeMessage.getHour(), dateTimeMessage.getMinute(), dateTimeMessage.getSecond());
dateTimeOffset = new Date().getTime() - pumpDate.getTime();
new ReadHistoryTaskRunner(connector, createOpenMessage(HistoryType.ALL), Offset.getOffset(getDatabaseHelper(), pumpSerialNumber, HistoryType.ALL) == -1 ? 20 : Integer.MAX_VALUE).fetch(this);
}
}
use of sugar.free.sightparser.applayer.messages.status.ReadDateTimeMessage in project SightRemote by TebbeUbben.
the class TimeSynchronizationService method onStatusChange.
@Override
public void onStatusChange(Status status) {
if (status == Status.CONNECTED) {
serviceConnector.connect();
new SingleMessageTaskRunner(serviceConnector, new ReadDateTimeMessage()).fetch(this);
} else
serviceConnector.disconnect();
}
Aggregations