use of org.thingsboard.server.common.data.device.data.DeviceData in project thingsboard by thingsboard.
the class ProtoTransportEntityService method getDeviceById.
public Device getDeviceById(DeviceId id) {
TransportProtos.GetDeviceResponseMsg deviceProto = transportService.getDevice(TransportProtos.GetDeviceRequestMsg.newBuilder().setDeviceIdMSB(id.getId().getMostSignificantBits()).setDeviceIdLSB(id.getId().getLeastSignificantBits()).build());
if (deviceProto == null) {
return null;
}
DeviceProfileId deviceProfileId = new DeviceProfileId(new UUID(deviceProto.getDeviceProfileIdMSB(), deviceProto.getDeviceProfileIdLSB()));
Device device = new Device();
device.setId(id);
device.setDeviceProfileId(deviceProfileId);
DeviceTransportConfiguration deviceTransportConfiguration = (DeviceTransportConfiguration) dataDecodingEncodingService.decode(deviceProto.getDeviceTransportConfiguration().toByteArray()).orElseThrow(() -> new IllegalStateException("Can't find device transport configuration"));
DeviceData deviceData = new DeviceData();
deviceData.setTransportConfiguration(deviceTransportConfiguration);
device.setDeviceData(deviceData);
return device;
}
use of org.thingsboard.server.common.data.device.data.DeviceData in project thingsboard by thingsboard.
the class AbstractDeviceEntity method toDevice.
protected Device toDevice() {
Device device = new Device(new DeviceId(getUuid()));
device.setCreatedTime(createdTime);
if (tenantId != null) {
device.setTenantId(TenantId.fromUUID(tenantId));
}
if (customerId != null) {
device.setCustomerId(new CustomerId(customerId));
}
if (deviceProfileId != null) {
device.setDeviceProfileId(new DeviceProfileId(deviceProfileId));
}
if (firmwareId != null) {
device.setFirmwareId(new OtaPackageId(firmwareId));
}
if (softwareId != null) {
device.setSoftwareId(new OtaPackageId(softwareId));
}
device.setDeviceData(JacksonUtil.convertValue(deviceData, DeviceData.class));
device.setName(name);
device.setType(type);
device.setLabel(label);
device.setAdditionalInfo(additionalInfo);
return device;
}
Aggregations