use of org.thingsboard.server.common.data.device.data.Lwm2mDeviceTransportConfiguration in project thingsboard by thingsboard.
the class DefaultTransportApiService method getDeviceInfoProto.
private DeviceInfoProto getDeviceInfoProto(Device device) throws JsonProcessingException {
DeviceInfoProto.Builder builder = DeviceInfoProto.newBuilder().setTenantIdMSB(device.getTenantId().getId().getMostSignificantBits()).setTenantIdLSB(device.getTenantId().getId().getLeastSignificantBits()).setCustomerIdMSB(Optional.ofNullable(device.getCustomerId()).map(customerId -> customerId.getId().getMostSignificantBits()).orElse(0L)).setCustomerIdLSB(Optional.ofNullable(device.getCustomerId()).map(customerId -> customerId.getId().getLeastSignificantBits()).orElse(0L)).setDeviceIdMSB(device.getId().getId().getMostSignificantBits()).setDeviceIdLSB(device.getId().getId().getLeastSignificantBits()).setDeviceName(device.getName()).setDeviceType(device.getType()).setDeviceProfileIdMSB(device.getDeviceProfileId().getId().getMostSignificantBits()).setDeviceProfileIdLSB(device.getDeviceProfileId().getId().getLeastSignificantBits()).setAdditionalInfo(mapper.writeValueAsString(device.getAdditionalInfo()));
PowerSavingConfiguration psmConfiguration = null;
switch(device.getDeviceData().getTransportConfiguration().getType()) {
case LWM2M:
psmConfiguration = (Lwm2mDeviceTransportConfiguration) device.getDeviceData().getTransportConfiguration();
break;
case COAP:
psmConfiguration = (CoapDeviceTransportConfiguration) device.getDeviceData().getTransportConfiguration();
break;
}
if (psmConfiguration != null) {
PowerMode powerMode = psmConfiguration.getPowerMode();
if (powerMode != null) {
builder.setPowerMode(powerMode.name());
if (powerMode.equals(PowerMode.PSM)) {
builder.setPsmActivityTimer(checkLong(psmConfiguration.getPsmActivityTimer()));
} else if (powerMode.equals(PowerMode.E_DRX)) {
builder.setEdrxCycle(checkLong(psmConfiguration.getEdrxCycle()));
builder.setPagingTransmissionWindow(checkLong(psmConfiguration.getPagingTransmissionWindow()));
}
}
}
return builder.build();
}
use of org.thingsboard.server.common.data.device.data.Lwm2mDeviceTransportConfiguration in project thingsboard by thingsboard.
the class LwM2mClient method onDeviceUpdate.
public void onDeviceUpdate(Device device, Optional<DeviceProfile> deviceProfileOpt) {
SessionInfoProto.Builder builder = SessionInfoProto.newBuilder().mergeFrom(session);
this.deviceId = device.getUuidId();
builder.setDeviceIdMSB(deviceId.getMostSignificantBits());
builder.setDeviceIdLSB(deviceId.getLeastSignificantBits());
builder.setDeviceName(device.getName());
deviceProfileOpt.ifPresent(deviceProfile -> updateSession(deviceProfile, builder));
this.session = builder.build();
Lwm2mDeviceTransportConfiguration transportConfiguration = (Lwm2mDeviceTransportConfiguration) device.getDeviceData().getTransportConfiguration();
this.powerMode = transportConfiguration.getPowerMode();
this.edrxCycle = transportConfiguration.getEdrxCycle();
this.psmActivityTimer = transportConfiguration.getPsmActivityTimer();
this.pagingTransmissionWindow = transportConfiguration.getPagingTransmissionWindow();
}
Aggregations