Moved code to existing processing
This commit is contained in:
parent
c24db73a37
commit
2d1f9b6158
@ -647,37 +647,7 @@ public class DefaultTransportService implements TransportService {
|
|||||||
}
|
}
|
||||||
} else if (EntityType.DEVICE.equals(entityType)) {
|
} else if (EntityType.DEVICE.equals(entityType)) {
|
||||||
Optional<Device> deviceOpt = dataDecodingEncodingService.decode(msg.getData().toByteArray());
|
Optional<Device> deviceOpt = dataDecodingEncodingService.decode(msg.getData().toByteArray());
|
||||||
if (deviceOpt.isPresent()) {
|
deviceOpt.ifPresent(this::onDeviceUpdate);
|
||||||
Device device = deviceOpt.get();
|
|
||||||
if (device.getAdditionalInfo().has("gateway") && device.getAdditionalInfo().get("gateway").asBoolean()) {
|
|
||||||
sessions.forEach((uuid, currentMD) -> {
|
|
||||||
if (device.getId().equals(new DeviceId(new UUID(currentMD.getSessionInfo().getDeviceIdMSB(), currentMD.getSessionInfo().getDeviceIdLSB())))) {
|
|
||||||
boolean newActivityTimeFromGatewayDevice = device.getAdditionalInfo().get("activityTimeFromGatewayDevice").asBoolean();
|
|
||||||
if (currentMD.getSessionInfo().getActivityTimeFromGatewayDevice() != newActivityTimeFromGatewayDevice) {
|
|
||||||
SessionInfoProto currentSessionInfo = currentMD.getSessionInfo();
|
|
||||||
SessionInfoProto newSessionInfo = SessionInfoProto.newBuilder()
|
|
||||||
.setNodeId(currentSessionInfo.getNodeId())
|
|
||||||
.setSessionIdMSB(currentSessionInfo.getSessionIdMSB())
|
|
||||||
.setSessionIdLSB(currentSessionInfo.getSessionIdLSB())
|
|
||||||
.setDeviceIdMSB(currentSessionInfo.getDeviceIdMSB())
|
|
||||||
.setDeviceIdLSB(currentSessionInfo.getDeviceIdLSB())
|
|
||||||
.setTenantIdMSB(currentSessionInfo.getTenantIdMSB())
|
|
||||||
.setTenantIdLSB(currentSessionInfo.getTenantIdLSB())
|
|
||||||
.setDeviceName(currentSessionInfo.getDeviceName())
|
|
||||||
.setDeviceType(currentSessionInfo.getDeviceType())
|
|
||||||
.setGwSessionIdMSB(currentSessionInfo.getGwSessionIdMSB())
|
|
||||||
.setGwSessionIdLSB(currentSessionInfo.getGwSessionIdLSB())
|
|
||||||
.setDeviceProfileIdMSB(currentSessionInfo.getDeviceProfileIdMSB())
|
|
||||||
.setDeviceProfileIdLSB(currentSessionInfo.getDeviceProfileIdLSB())
|
|
||||||
.setActivityTimeFromGatewayDevice(newActivityTimeFromGatewayDevice)
|
|
||||||
.build();
|
|
||||||
currentMD.setSessionInfo(newSessionInfo);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
onDeviceUpdate(device);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else if (toSessionMsg.hasEntityDeleteMsg()) {
|
} else if (toSessionMsg.hasEntityDeleteMsg()) {
|
||||||
TransportProtos.EntityDeleteMsg msg = toSessionMsg.getEntityDeleteMsg();
|
TransportProtos.EntityDeleteMsg msg = toSessionMsg.getEntityDeleteMsg();
|
||||||
@ -733,13 +703,21 @@ public class DefaultTransportService implements TransportService {
|
|||||||
} else {
|
} else {
|
||||||
newDeviceProfile = null;
|
newDeviceProfile = null;
|
||||||
}
|
}
|
||||||
TransportProtos.SessionInfoProto newSessionInfo = TransportProtos.SessionInfoProto.newBuilder()
|
TransportProtos.SessionInfoProto.Builder newSessionInfoBuilder = TransportProtos.SessionInfoProto.newBuilder()
|
||||||
.mergeFrom(md.getSessionInfo())
|
.mergeFrom(md.getSessionInfo())
|
||||||
.setDeviceProfileIdMSB(deviceProfileIdMSB)
|
.setDeviceProfileIdMSB(deviceProfileIdMSB)
|
||||||
.setDeviceProfileIdLSB(deviceProfileIdLSB)
|
.setDeviceProfileIdLSB(deviceProfileIdLSB)
|
||||||
.setDeviceName(device.getName())
|
.setDeviceName(device.getName())
|
||||||
.setDeviceType(device.getType())
|
.setDeviceType(device.getType());
|
||||||
.build();
|
if (device.getAdditionalInfo().has("gateway")
|
||||||
|
&& device.getAdditionalInfo().get("gateway").asBoolean()
|
||||||
|
&& device.getAdditionalInfo().has("activityTimeFromGatewayDevice")) {
|
||||||
|
boolean activityTimeFromGatewayDevice = device.getAdditionalInfo().get("activityTimeFromGatewayDevice").asBoolean();
|
||||||
|
if (md.getSessionInfo().getActivityTimeFromGatewayDevice() != activityTimeFromGatewayDevice) {
|
||||||
|
newSessionInfoBuilder.setActivityTimeFromGatewayDevice(activityTimeFromGatewayDevice);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
TransportProtos.SessionInfoProto newSessionInfo = newSessionInfoBuilder.build();
|
||||||
md.setSessionInfo(newSessionInfo);
|
md.setSessionInfo(newSessionInfo);
|
||||||
transportCallbackExecutor.submit(() -> md.getListener().onDeviceUpdate(newSessionInfo, device, Optional.ofNullable(newDeviceProfile)));
|
transportCallbackExecutor.submit(() -> md.getListener().onDeviceUpdate(newSessionInfo, device, Optional.ofNullable(newDeviceProfile)));
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user