Browse Source

added PowerMode for LwM2M

pull/4746/head
YevhenBondarenko 5 years ago
parent
commit
b1204ebe5c
  1. 20
      common/data/src/main/java/org/thingsboard/server/common/data/device/data/PowerMode.java
  2. 4
      common/data/src/main/java/org/thingsboard/server/common/data/device/data/lwm2m/OtherConfiguration.java
  3. 4
      common/transport/lwm2m/src/main/java/org/thingsboard/server/transport/lwm2m/server/DefaultLwM2mTransportService.java
  4. 8
      common/transport/lwm2m/src/main/java/org/thingsboard/server/transport/lwm2m/server/LwM2mTransportCoapResource.java
  5. 4
      common/transport/lwm2m/src/main/java/org/thingsboard/server/transport/lwm2m/server/LwM2mTransportUtil.java
  6. 4
      common/transport/lwm2m/src/main/java/org/thingsboard/server/transport/lwm2m/server/client/LwM2mFwSwUpdate.java
  7. 32
      ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-device-profile-transport-configuration.component.html
  8. 62
      ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-device-profile-transport-configuration.component.ts
  9. 28
      ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-profile-config.models.ts
  10. 11
      ui-ngx/src/assets/locale/locale.constant-en_US.json

20
common/data/src/main/java/org/thingsboard/server/common/data/device/data/PowerMode.java

@ -0,0 +1,20 @@
/**
* Copyright © 2016-2021 The Thingsboard Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.thingsboard.server.common.data.device.data;
public enum PowerMode {
PSM, DRX, E_DRX
}

4
common/data/src/main/java/org/thingsboard/server/common/data/device/data/lwm2m/OtherConfiguration.java

@ -16,12 +16,16 @@
package org.thingsboard.server.common.data.device.data.lwm2m; package org.thingsboard.server.common.data.device.data.lwm2m;
import lombok.Data; import lombok.Data;
import org.thingsboard.server.common.data.device.data.PowerMode;
@Data @Data
public class OtherConfiguration { public class OtherConfiguration {
private Integer fwUpdateStrategy; private Integer fwUpdateStrategy;
private String fwUpdateResource;
private Integer swUpdateStrategy; private Integer swUpdateStrategy;
private String swUpdateResource;
private Integer clientOnlyObserveAfterConnect; private Integer clientOnlyObserveAfterConnect;
private PowerMode powerMode;
} }

4
common/transport/lwm2m/src/main/java/org/thingsboard/server/transport/lwm2m/server/DefaultLwM2mTransportService.java

@ -64,7 +64,7 @@ import static org.eclipse.californium.scandium.dtls.cipher.CipherSuite.TLS_ECDHE
import static org.eclipse.californium.scandium.dtls.cipher.CipherSuite.TLS_PSK_WITH_AES_128_CBC_SHA256; import static org.eclipse.californium.scandium.dtls.cipher.CipherSuite.TLS_PSK_WITH_AES_128_CBC_SHA256;
import static org.eclipse.californium.scandium.dtls.cipher.CipherSuite.TLS_PSK_WITH_AES_128_CCM_8; import static org.eclipse.californium.scandium.dtls.cipher.CipherSuite.TLS_PSK_WITH_AES_128_CCM_8;
import static org.thingsboard.server.transport.lwm2m.server.LwM2mNetworkConfig.getCoapConfig; import static org.thingsboard.server.transport.lwm2m.server.LwM2mNetworkConfig.getCoapConfig;
import static org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil.FIRMWARE_UPDATE_COAP_RECOURSE; import static org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil.FIRMWARE_UPDATE_COAP_RESOURCE;
@Slf4j @Slf4j
@Component @Component
@ -104,7 +104,7 @@ public class DefaultLwM2mTransportService implements LwM2MTransportService {
*/ */
LwM2mTransportCoapResource otaCoapResource = new LwM2mTransportCoapResource(handler, FIRMWARE_UPDATE_COAP_RECOURSE); LwM2mTransportCoapResource otaCoapResource = new LwM2mTransportCoapResource(handler, FIRMWARE_UPDATE_COAP_RESOURCE);
this.server.coap().getServer().add(otaCoapResource); this.server.coap().getServer().add(otaCoapResource);
this.startLhServer(); this.startLhServer();
this.context.setServer(server); this.context.setServer(server);

8
common/transport/lwm2m/src/main/java/org/thingsboard/server/transport/lwm2m/server/LwM2mTransportCoapResource.java

@ -32,8 +32,8 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap; import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import static org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil.FIRMWARE_UPDATE_COAP_RECOURSE; import static org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil.FIRMWARE_UPDATE_COAP_RESOURCE;
import static org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil.SOFTWARE_UPDATE_COAP_RECOURSE; import static org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil.SOFTWARE_UPDATE_COAP_RESOURCE;
@Slf4j @Slf4j
public class LwM2mTransportCoapResource extends AbstractLwM2mTransportResource { public class LwM2mTransportCoapResource extends AbstractLwM2mTransportResource {
@ -72,8 +72,8 @@ public class LwM2mTransportCoapResource extends AbstractLwM2mTransportResource {
protected void processHandleGet(CoapExchange exchange) { protected void processHandleGet(CoapExchange exchange) {
log.warn("90) processHandleGet [{}]", exchange); log.warn("90) processHandleGet [{}]", exchange);
if (exchange.getRequestOptions().getUriPath().size() >= 2 && if (exchange.getRequestOptions().getUriPath().size() >= 2 &&
(FIRMWARE_UPDATE_COAP_RECOURSE.equals(exchange.getRequestOptions().getUriPath().get(exchange.getRequestOptions().getUriPath().size()-2)) || (FIRMWARE_UPDATE_COAP_RESOURCE.equals(exchange.getRequestOptions().getUriPath().get(exchange.getRequestOptions().getUriPath().size()-2)) ||
SOFTWARE_UPDATE_COAP_RECOURSE.equals(exchange.getRequestOptions().getUriPath().get(exchange.getRequestOptions().getUriPath().size()-2)))) { SOFTWARE_UPDATE_COAP_RESOURCE.equals(exchange.getRequestOptions().getUriPath().get(exchange.getRequestOptions().getUriPath().size()-2)))) {
this.sendOtaData(exchange); this.sendOtaData(exchange);
} }
} }

4
common/transport/lwm2m/src/main/java/org/thingsboard/server/transport/lwm2m/server/LwM2mTransportUtil.java

@ -137,7 +137,7 @@ public class LwM2mTransportUtil {
// Firmware // Firmware
public static final String FIRMWARE_UPDATE_COAP_RECOURSE = "firmwareUpdateCoapRecourse"; public static final String FIRMWARE_UPDATE_COAP_RESOURCE = "firmwareUpdateCoapResource";
public static final String FW_UPDATE = "Firmware update"; public static final String FW_UPDATE = "Firmware update";
public static final Integer FW_5_ID = 5; public static final Integer FW_5_ID = 5;
public static final Integer FW_19_ID = 19; public static final Integer FW_19_ID = 19;
@ -169,7 +169,7 @@ public class LwM2mTransportUtil {
public static final String FW_UPDATE_ID = "/5/0/2"; public static final String FW_UPDATE_ID = "/5/0/2";
// Software // Software
public static final String SOFTWARE_UPDATE_COAP_RECOURSE = "softwareUpdateCoapRecourse"; public static final String SOFTWARE_UPDATE_COAP_RESOURCE = "softwareUpdateCoapResource";
public static final String SW_UPDATE = "Software update"; public static final String SW_UPDATE = "Software update";
public static final Integer SW_ID = 9; public static final Integer SW_ID = 9;
// Package W // Package W

4
common/transport/lwm2m/src/main/java/org/thingsboard/server/transport/lwm2m/server/client/LwM2mFwSwUpdate.java

@ -49,7 +49,7 @@ import static org.thingsboard.server.common.data.ota.OtaPackageUpdateStatus.INIT
import static org.thingsboard.server.common.data.ota.OtaPackageUpdateStatus.UPDATED; import static org.thingsboard.server.common.data.ota.OtaPackageUpdateStatus.UPDATED;
import static org.thingsboard.server.common.data.ota.OtaPackageUpdateStatus.UPDATING; import static org.thingsboard.server.common.data.ota.OtaPackageUpdateStatus.UPDATING;
import static org.thingsboard.server.common.data.ota.OtaPackageUtil.getAttributeKey; import static org.thingsboard.server.common.data.ota.OtaPackageUtil.getAttributeKey;
import static org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil.FIRMWARE_UPDATE_COAP_RECOURSE; import static org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil.FIRMWARE_UPDATE_COAP_RESOURCE;
import static org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil.FW_3_VER_ID; import static org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil.FW_3_VER_ID;
import static org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil.FW_5_VER_ID; import static org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil.FW_5_VER_ID;
import static org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil.FW_NAME_ID; import static org.thingsboard.server.transport.lwm2m.server.LwM2mTransportUtil.FW_NAME_ID;
@ -199,7 +199,7 @@ public class LwM2mFwSwUpdate {
request.sendWriteReplaceRequest(lwM2MClient, downlink, new TbLwM2MWriteResponseCallback(handler, lwM2MClient, targetIdVer)); request.sendWriteReplaceRequest(lwM2MClient, downlink, new TbLwM2MWriteResponseCallback(handler, lwM2MClient, targetIdVer));
} else if (LwM2mTransportUtil.LwM2MFirmwareUpdateStrategy.OBJ_5_TEMP_URL.code == this.updateStrategy) { } else if (LwM2mTransportUtil.LwM2MFirmwareUpdateStrategy.OBJ_5_TEMP_URL.code == this.updateStrategy) {
String apiFont = "coap://176.36.143.9:5685"; String apiFont = "coap://176.36.143.9:5685";
String uri = apiFont + "/" + FIRMWARE_UPDATE_COAP_RECOURSE + "/" + this.currentId.toString(); String uri = apiFont + "/" + FIRMWARE_UPDATE_COAP_RESOURCE + "/" + this.currentId.toString();
log.warn("89) coapUri: [{}]", uri); log.warn("89) coapUri: [{}]", uri);
//TODO: user this.rpcRequest??? //TODO: user this.rpcRequest???
TbLwM2MWriteReplaceRequest downlink = TbLwM2MWriteReplaceRequest.builder().versionedId(targetIdVer).value(uri).timeout(handler.config.getTimeout()).build(); TbLwM2MWriteReplaceRequest downlink = TbLwM2MWriteReplaceRequest.builder().versionedId(targetIdVer).value(uri).timeout(handler.config.getTimeout()).build();

32
ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-device-profile-transport-configuration.component.html

@ -126,10 +126,10 @@
</mat-select> </mat-select>
</mat-form-field> </mat-form-field>
<mat-form-field class="mat-block" fxFlex *ngIf="isFwUpdateStrategy"> <mat-form-field class="mat-block" fxFlex *ngIf="isFwUpdateStrategy">
<mat-label>{{ 'device-profile.lwm2m.fw-update-recourse' | translate }}</mat-label> <mat-label>{{ 'device-profile.lwm2m.fw-update-resource' | translate }}</mat-label>
<input matInput formControlName="fwUpdateRecourse" required> <input matInput formControlName="fwUpdateResource" required>
<mat-error *ngIf="lwm2mDeviceProfileFormGroup.get('fwUpdateRecourse').hasError('required')"> <mat-error *ngIf="lwm2mDeviceProfileFormGroup.get('fwUpdateResource').hasError('required')">
{{ 'device-profile.lwm2m.fw-update-recourse-required' | translate }} {{ 'device-profile.lwm2m.fw-update-resource-required' | translate }}
</mat-error> </mat-error>
</mat-form-field> </mat-form-field>
</fieldset> </fieldset>
@ -143,13 +143,25 @@
</mat-select> </mat-select>
</mat-form-field> </mat-form-field>
<mat-form-field class="mat-block" fxFlex *ngIf="isSwUpdateStrategy"> <mat-form-field class="mat-block" fxFlex *ngIf="isSwUpdateStrategy">
<mat-label>{{ 'device-profile.lwm2m.sw-update-recourse' | translate }}</mat-label> <mat-label>{{ 'device-profile.lwm2m.sw-update-resource' | translate }}</mat-label>
<input matInput formControlName="swUpdateRecourse" required> <input matInput formControlName="swUpdateResource" required>
<mat-error *ngIf="lwm2mDeviceProfileFormGroup.get('swUpdateRecourse').hasError('required')"> <mat-error *ngIf="lwm2mDeviceProfileFormGroup.get('swUpdateResource').hasError('required')">
{{ 'device-profile.lwm2m.sw-update-recourse-required' | translate }} {{ 'device-profile.lwm2m.sw-update-resource-required' | translate }}
</mat-error> </mat-error>
</mat-form-field> </mat-form-field>
</fieldset> </fieldset>
<fieldset class="fields-group">
<legend class="group-title" translate>device-profile.lwm2m.power-mode</legend>
<mat-form-field class="mat-block" fxFlex>
<mat-label> </mat-label>
<mat-select formControlName="powerMode">
<mat-option *ngFor="let powerMode of powerModeLwM2MTypes"
[value]="powerMode">
{{ powerModeLwM2MNamesMap.get(powerModeLwM2MType[powerMode]) }}
</mat-option>
</mat-select>
</mat-form-field>
</fieldset>
<!-- <mat-accordion multi="true">--> <!-- <mat-accordion multi="true">-->
<!-- <div *ngIf="false">--> <!-- <div *ngIf="false">-->
<!-- <mat-expansion-panel>--> <!-- <mat-expansion-panel>-->
@ -160,9 +172,9 @@
<!-- <div fxLayout="column">--> <!-- <div fxLayout="column">-->
<!-- <mat-form-field class="mat-block">--> <!-- <mat-form-field class="mat-block">-->
<!-- <mat-label>{{ 'device-profile.lwm2m.client-strategy-label' | translate }}</mat-label>--> <!-- <mat-label>{{ 'device-profile.lwm2m.client-strategy-label' | translate }}</mat-label>-->
<!-- <mat-select formControlName="clientStrategy"--> <!-- <mat-select formControlName="clientOnlyObserveAfterConnect"-->
<!-- matTooltip="{{ 'device-profile.lwm2m.client-strategy-tip' | translate:--> <!-- matTooltip="{{ 'device-profile.lwm2m.client-strategy-tip' | translate:-->
<!-- { count: +lwm2mDeviceProfileFormGroup.get('clientStrategy').value } }}"--> <!-- { count: +lwm2mDeviceProfileFormGroup.get('clientOnlyObserveAfterConnect').value } }}"-->
<!-- matTooltipPosition="above">--> <!-- matTooltipPosition="above">-->
<!-- <mat-option value=1>{{ 'device-profile.lwm2m.client-strategy-connect' | translate:--> <!-- <mat-option value=1>{{ 'device-profile.lwm2m.client-strategy-connect' | translate:-->
<!-- {count: 1} }}</mat-option>--> <!-- {count: 1} }}</mat-option>-->

62
ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-device-profile-transport-configuration.component.ts

@ -32,7 +32,7 @@ import {
ModelValue, ModelValue,
ObjectLwM2M, ObjectLwM2M,
OBSERVE, OBSERVE,
OBSERVE_ATTR_TELEMETRY, OBSERVE_ATTR_TELEMETRY, powerMode, powerModeNames,
RESOURCES, RESOURCES,
TELEMETRY TELEMETRY
} from './lwm2m-profile-config.models'; } from './lwm2m-profile-config.models';
@ -72,6 +72,9 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro
sortFunction: (key: string, value: object) => object; sortFunction: (key: string, value: object) => object;
isFwUpdateStrategy: boolean; isFwUpdateStrategy: boolean;
isSwUpdateStrategy: boolean; isSwUpdateStrategy: boolean;
powerModeLwM2MType = powerMode;
powerModeLwM2MTypes = Object.keys(powerMode);
powerModeLwM2MNamesMap = powerModeNames;
get required(): boolean { get required(): boolean {
return this.requiredValue; return this.requiredValue;
@ -97,11 +100,12 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro
binding: [], binding: [],
bootstrapServer: [null, Validators.required], bootstrapServer: [null, Validators.required],
lwm2mServer: [null, Validators.required], lwm2mServer: [null, Validators.required],
clientStrategy: [1, []], clientOnlyObserveAfterConnect: [1, []],
fwUpdateStrategy: [1, []], fwUpdateStrategy: [1, []],
swUpdateStrategy: [1, []], swUpdateStrategy: [1, []],
fwUpdateRecourse: [{value: '', disabled: true}, []], fwUpdateResource: [{value: '', disabled: true}, []],
swUpdateRecourse: [{value: '', disabled: true}, []] swUpdateResource: [{value: '', disabled: true}, []],
powerMode: [null, Validators.required]
}); });
this.lwm2mDeviceConfigFormGroup = this.fb.group({ this.lwm2mDeviceConfigFormGroup = this.fb.group({
configurationJson: [null, Validators.required] configurationJson: [null, Validators.required]
@ -110,11 +114,11 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro
takeUntil(this.destroy$) takeUntil(this.destroy$)
).subscribe((fwStrategy) => { ).subscribe((fwStrategy) => {
if (fwStrategy === 2) { if (fwStrategy === 2) {
this.lwm2mDeviceProfileFormGroup.get('fwUpdateRecourse').enable({emitEvent: false}); this.lwm2mDeviceProfileFormGroup.get('fwUpdateResource').enable({emitEvent: false});
this.lwm2mDeviceProfileFormGroup.get('fwUpdateRecourse').patchValue(DEFAULT_FW_UPDATE_RESOURCE, {emitEvent: false}); this.lwm2mDeviceProfileFormGroup.get('fwUpdateResource').patchValue(DEFAULT_FW_UPDATE_RESOURCE, {emitEvent: false});
this.isFwUpdateStrategy = true; this.isFwUpdateStrategy = true;
} else { } else {
this.lwm2mDeviceProfileFormGroup.get('fwUpdateRecourse').disable({emitEvent: false}); this.lwm2mDeviceProfileFormGroup.get('fwUpdateResource').disable({emitEvent: false});
this.isFwUpdateStrategy = false; this.isFwUpdateStrategy = false;
} }
this.otaUpdateFwStrategyValidate(true); this.otaUpdateFwStrategyValidate(true);
@ -123,12 +127,12 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro
takeUntil(this.destroy$) takeUntil(this.destroy$)
).subscribe((swStrategy) => { ).subscribe((swStrategy) => {
if (swStrategy === 2) { if (swStrategy === 2) {
this.lwm2mDeviceProfileFormGroup.get('swUpdateRecourse').enable({emitEvent: false}); this.lwm2mDeviceProfileFormGroup.get('swUpdateResource').enable({emitEvent: false});
this.lwm2mDeviceProfileFormGroup.get('swUpdateRecourse').patchValue(DEFAULT_SW_UPDATE_RESOURCE, {emitEvent: false}); this.lwm2mDeviceProfileFormGroup.get('swUpdateResource').patchValue(DEFAULT_SW_UPDATE_RESOURCE, {emitEvent: false});
this.isSwUpdateStrategy = true; this.isSwUpdateStrategy = true;
} else { } else {
this.isSwUpdateStrategy = false; this.isSwUpdateStrategy = false;
this.lwm2mDeviceProfileFormGroup.get('swUpdateRecourse').disable({emitEvent: false}); this.lwm2mDeviceProfileFormGroup.get('swUpdateResource').disable({emitEvent: false});
} }
this.otaUpdateSwStrategyValidate(true); this.otaUpdateSwStrategyValidate(true);
}); });
@ -202,10 +206,10 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro
} }
private updateWriteValue = (value: ModelValue): void => { private updateWriteValue = (value: ModelValue): void => {
const fwResource = isDefinedAndNotNull(this.configurationValue.clientLwM2mSettings.fwUpdateRecourse) ? const fwResource = isDefinedAndNotNull(this.configurationValue.clientLwM2mSettings.fwUpdateResource) ?
this.configurationValue.clientLwM2mSettings.fwUpdateRecourse : ''; this.configurationValue.clientLwM2mSettings.fwUpdateResource : '';
const swResource = isDefinedAndNotNull(this.configurationValue.clientLwM2mSettings.fwUpdateRecourse) ? const swResource = isDefinedAndNotNull(this.configurationValue.clientLwM2mSettings.fwUpdateResource) ?
this.configurationValue.clientLwM2mSettings.swUpdateRecourse : ''; this.configurationValue.clientLwM2mSettings.swUpdateResource : '';
this.lwm2mDeviceProfileFormGroup.patchValue({ this.lwm2mDeviceProfileFormGroup.patchValue({
objectIds: value, objectIds: value,
observeAttrTelemetry: this.getObserveAttrTelemetryObjects(value.objectsList), observeAttrTelemetry: this.getObserveAttrTelemetryObjects(value.objectsList),
@ -216,15 +220,16 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro
binding: this.configurationValue.bootstrap.servers.binding, binding: this.configurationValue.bootstrap.servers.binding,
bootstrapServer: this.configurationValue.bootstrap.bootstrapServer, bootstrapServer: this.configurationValue.bootstrap.bootstrapServer,
lwm2mServer: this.configurationValue.bootstrap.lwm2mServer, lwm2mServer: this.configurationValue.bootstrap.lwm2mServer,
clientStrategy: this.configurationValue.clientLwM2mSettings.clientStrategy, clientOnlyObserveAfterConnect: this.configurationValue.clientLwM2mSettings.clientOnlyObserveAfterConnect,
fwUpdateStrategy: this.configurationValue.clientLwM2mSettings.fwUpdateStrategy || 1, fwUpdateStrategy: this.configurationValue.clientLwM2mSettings.fwUpdateStrategy || 1,
swUpdateStrategy: this.configurationValue.clientLwM2mSettings.swUpdateStrategy || 1, swUpdateStrategy: this.configurationValue.clientLwM2mSettings.swUpdateStrategy || 1,
fwUpdateRecourse: fwResource, fwUpdateResource: fwResource,
swUpdateRecourse: swResource swUpdateResource: swResource,
powerMode: this.configurationValue.clientLwM2mSettings.powerMode
}, },
{emitEvent: false}); {emitEvent: false});
this.configurationValue.clientLwM2mSettings.fwUpdateRecourse = fwResource; this.configurationValue.clientLwM2mSettings.fwUpdateResource = fwResource;
this.configurationValue.clientLwM2mSettings.swUpdateRecourse = swResource; this.configurationValue.clientLwM2mSettings.swUpdateResource = swResource;
this.isFwUpdateStrategy = this.configurationValue.clientLwM2mSettings.fwUpdateStrategy === 2; this.isFwUpdateStrategy = this.configurationValue.clientLwM2mSettings.fwUpdateStrategy === 2;
this.isSwUpdateStrategy = this.configurationValue.clientLwM2mSettings.swUpdateStrategy === 2; this.isSwUpdateStrategy = this.configurationValue.clientLwM2mSettings.swUpdateStrategy === 2;
this.otaUpdateSwStrategyValidate(); this.otaUpdateSwStrategyValidate();
@ -257,11 +262,12 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro
bootstrapServers.defaultMinPeriod = config.defaultMinPeriod; bootstrapServers.defaultMinPeriod = config.defaultMinPeriod;
bootstrapServers.notifIfDisabled = config.notifIfDisabled; bootstrapServers.notifIfDisabled = config.notifIfDisabled;
bootstrapServers.binding = config.binding; bootstrapServers.binding = config.binding;
this.configurationValue.clientLwM2mSettings.clientStrategy = config.clientStrategy; this.configurationValue.clientLwM2mSettings.clientOnlyObserveAfterConnect = config.clientOnlyObserveAfterConnect;
this.configurationValue.clientLwM2mSettings.fwUpdateStrategy = config.fwUpdateStrategy; this.configurationValue.clientLwM2mSettings.fwUpdateStrategy = config.fwUpdateStrategy;
this.configurationValue.clientLwM2mSettings.swUpdateStrategy = config.swUpdateStrategy; this.configurationValue.clientLwM2mSettings.swUpdateStrategy = config.swUpdateStrategy;
this.configurationValue.clientLwM2mSettings.fwUpdateRecourse = config.fwUpdateRecourse; this.configurationValue.clientLwM2mSettings.fwUpdateResource = config.fwUpdateResource;
this.configurationValue.clientLwM2mSettings.swUpdateRecourse = config.swUpdateRecourse; this.configurationValue.clientLwM2mSettings.swUpdateResource = config.swUpdateResource;
this.configurationValue.clientLwM2mSettings.powerMode = config.powerMode;
this.upDateJsonAllConfig(); this.upDateJsonAllConfig();
} }
this.updateModel(); this.updateModel();
@ -539,20 +545,20 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro
private otaUpdateFwStrategyValidate(updated = false): void { private otaUpdateFwStrategyValidate(updated = false): void {
if (this.isFwUpdateStrategy) { if (this.isFwUpdateStrategy) {
this.lwm2mDeviceProfileFormGroup.get('fwUpdateRecourse').setValidators([Validators.required]); this.lwm2mDeviceProfileFormGroup.get('fwUpdateResource').setValidators([Validators.required]);
} else { } else {
this.lwm2mDeviceProfileFormGroup.get('fwUpdateRecourse').clearValidators(); this.lwm2mDeviceProfileFormGroup.get('fwUpdateResource').clearValidators();
} }
this.lwm2mDeviceProfileFormGroup.get('fwUpdateRecourse').updateValueAndValidity({emitEvent: updated}); this.lwm2mDeviceProfileFormGroup.get('fwUpdateResource').updateValueAndValidity({emitEvent: updated});
} }
private otaUpdateSwStrategyValidate(updated = false): void { private otaUpdateSwStrategyValidate(updated = false): void {
if (this.isSwUpdateStrategy) { if (this.isSwUpdateStrategy) {
this.lwm2mDeviceProfileFormGroup.get('swUpdateRecourse').setValidators([Validators.required]); this.lwm2mDeviceProfileFormGroup.get('swUpdateResource').setValidators([Validators.required]);
} else { } else {
this.lwm2mDeviceProfileFormGroup.get('swUpdateRecourse').clearValidators(); this.lwm2mDeviceProfileFormGroup.get('swUpdateResource').clearValidators();
} }
this.lwm2mDeviceProfileFormGroup.get('swUpdateRecourse').updateValueAndValidity({emitEvent: updated}); this.lwm2mDeviceProfileFormGroup.get('swUpdateResource').updateValueAndValidity({emitEvent: updated});
} }
} }

28
ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-profile-config.models.ts

@ -128,6 +128,20 @@ export const securityConfigModeNames = new Map<securityConfigMode, string>(
] ]
); );
export enum powerMode {
PSM = 'PSM',
DRX = 'DRX',
E_DRX = 'E_DRX'
}
export const powerModeNames = new Map<powerMode, string>(
[
[powerMode.PSM, 'Power Saving Mode (PSM)'],
[powerMode.DRX, 'Discontinuous Reception (DRX)'],
[powerMode.E_DRX, 'Extended Discontinuous Reception (eDRX)']
]
);
export interface ModelValue { export interface ModelValue {
objectIds: string[]; objectIds: string[];
objectsList: ObjectLwM2M[]; objectsList: ObjectLwM2M[];
@ -168,11 +182,12 @@ export interface Lwm2mProfileConfigModels {
} }
export interface ClientLwM2mSettings { export interface ClientLwM2mSettings {
clientStrategy: string; clientOnlyObserveAfterConnect: string;
fwUpdateStrategy: number; fwUpdateStrategy: number;
swUpdateStrategy: number; swUpdateStrategy: number;
fwUpdateRecourse: string; fwUpdateResource: string;
swUpdateRecourse: string; swUpdateResource: string;
powerMode: powerMode;
} }
export interface ObservableAttributes { export interface ObservableAttributes {
@ -240,11 +255,12 @@ export function getDefaultProfileConfig(hostname?: any): Lwm2mProfileConfigModel
function getDefaultProfileClientLwM2mSettingsConfig(): ClientLwM2mSettings { function getDefaultProfileClientLwM2mSettingsConfig(): ClientLwM2mSettings {
return { return {
clientStrategy: '1', clientOnlyObserveAfterConnect: '1',
fwUpdateStrategy: 1, fwUpdateStrategy: 1,
swUpdateStrategy: 1, swUpdateStrategy: 1,
fwUpdateRecourse: DEFAULT_FW_UPDATE_RESOURCE, fwUpdateResource: DEFAULT_FW_UPDATE_RESOURCE,
swUpdateRecourse: DEFAULT_SW_UPDATE_RESOURCE swUpdateResource: DEFAULT_SW_UPDATE_RESOURCE,
powerMode: powerMode.DRX
}; };
} }

11
ui-ngx/src/assets/locale/locale.constant-en_US.json

@ -1288,11 +1288,12 @@
"sw-update-strategy": "Software update strategy", "sw-update-strategy": "Software update strategy",
"sw-update-strategy-package": "Push binary file using Object 9 and Resource 2 (Package)", "sw-update-strategy-package": "Push binary file using Object 9 and Resource 2 (Package)",
"sw-update-strategy-package-uri": "Auto-generate unique CoAP URL to download the package and push software update using Object 9 and Resource 3 (Package URI)", "sw-update-strategy-package-uri": "Auto-generate unique CoAP URL to download the package and push software update using Object 9 and Resource 3 (Package URI)",
"fw-update-recourse": "Firmware update CoAP recourse", "fw-update-resource": "Firmware update CoAP resource",
"fw-update-recourse-required": "Firmware update CoAP recourse is required.", "fw-update-resource-required": "Firmware update CoAP resource is required.",
"sw-update-recourse": "Software update CoAP recourse", "sw-update-resource": "Software update CoAP resource",
"sw-update-recourse-required": "Software update CoAP recourse is required.", "sw-update-resource-required": "Software update CoAP resource is required.",
"config-json-tab": "Json Config Profile Device" "config-json-tab": "Json Config Profile Device",
"power-mode": "Power Mode"
} }
}, },
"dialog": { "dialog": {

Loading…
Cancel
Save