diff --git a/common/data/src/main/java/org/thingsboard/server/common/data/device/data/lwm2m/OtherConfiguration.java b/common/data/src/main/java/org/thingsboard/server/common/data/device/data/lwm2m/OtherConfiguration.java
index f935f53ee3..c7681cfad8 100644
--- a/common/data/src/main/java/org/thingsboard/server/common/data/device/data/lwm2m/OtherConfiguration.java
+++ b/common/data/src/main/java/org/thingsboard/server/common/data/device/data/lwm2m/OtherConfiguration.java
@@ -27,7 +27,7 @@ public class OtherConfiguration {
private Integer swUpdateStrategy;
private Integer clientOnlyObserveAfterConnect;
private PowerMode powerMode;
- private Long eDRXCycle;
+ private Long edrxCycle;
private String fwUpdateResource;
private String swUpdateResource;
private boolean compositeOperationsSupport;
diff --git a/common/transport/lwm2m/src/main/java/org/thingsboard/server/transport/lwm2m/server/client/LwM2mClientContextImpl.java b/common/transport/lwm2m/src/main/java/org/thingsboard/server/transport/lwm2m/server/client/LwM2mClientContextImpl.java
index 51a23ce8d0..ebf673be84 100644
--- a/common/transport/lwm2m/src/main/java/org/thingsboard/server/transport/lwm2m/server/client/LwM2mClientContextImpl.java
+++ b/common/transport/lwm2m/src/main/java/org/thingsboard/server/transport/lwm2m/server/client/LwM2mClientContextImpl.java
@@ -353,7 +353,7 @@ public class LwM2mClientContextImpl implements LwM2mClientContext {
OtherConfiguration clientLwM2mSettings = clientProfile.getClientLwM2mSettings();
Long timeout = null;
if (PowerMode.E_DRX.equals(clientLwM2mSettings.getPowerMode())) {
- timeout = clientLwM2mSettings.getEDRXCycle();
+ timeout = clientLwM2mSettings.getEdrxCycle();
}
if (timeout == null || timeout == 0L) {
timeout = this.config.getTimeout();
diff --git a/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-device-profile-transport-configuration.component.html b/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-device-profile-transport-configuration.component.html
index 571820acb2..6e4f4f3929 100644
--- a/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-device-profile-transport-configuration.component.html
+++ b/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-device-profile-transport-configuration.component.html
@@ -167,6 +167,17 @@
+
+ {{ 'device-profile.edrx-cycle' | translate }}
+
+
+ {{ 'device-profile.edrx-cycle-required' | translate }}
+
+
+ {{ 'device-profile.edrx-cycle-pattern' | translate }}
+
+
{{ 'device-profile.lwm2m.composite-operations-support' | translate }}
diff --git a/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-device-profile-transport-configuration.component.ts b/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-device-profile-transport-configuration.component.ts
index bb9c3c87f6..1fd6835cb7 100644
--- a/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-device-profile-transport-configuration.component.ts
+++ b/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-device-profile-transport-configuration.component.ts
@@ -116,6 +116,7 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro
fwUpdateResource: [{value: '', disabled: true}, []],
swUpdateResource: [{value: '', disabled: true}, []],
powerMode: [PowerMode.DRX, Validators.required],
+ edrxCycle: [0],
compositeOperationsSupport: [false]
})
});
@@ -150,6 +151,20 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro
}
this.otaUpdateSwStrategyValidate(true);
});
+ this.lwm2mDeviceProfileFormGroup.get('clientLwM2mSettings.powerMode').valueChanges.pipe(
+ takeUntil(this.destroy$)
+ ).subscribe((powerMode: PowerMode) => {
+ if (powerMode === PowerMode.E_DRX) {
+ this.lwm2mDeviceProfileFormGroup.get('clientLwM2mSettings.edrxCycle').enable({emitEvent: false});
+ this.lwm2mDeviceProfileFormGroup.get('clientLwM2mSettings.edrxCycle').patchValue(0, {emitEvent: false});
+ this.lwm2mDeviceProfileFormGroup.get('clientLwM2mSettings.edrxCycle')
+ .setValidators([Validators.required, Validators.min(0), Validators.pattern('[0-9]*')]);
+ } else {
+ this.lwm2mDeviceProfileFormGroup.get('clientLwM2mSettings.edrxCycle').disable({emitEvent: false});
+ this.lwm2mDeviceProfileFormGroup.get('clientLwM2mSettings.edrxCycle').clearValidators();
+ }
+ this.lwm2mDeviceProfileFormGroup.get('clientLwM2mSettings.edrxCycle').updateValueAndValidity({emitEvent: false});
+ });
this.lwm2mDeviceProfileFormGroup.valueChanges.pipe(
takeUntil(this.destroy$)
).subscribe((value) => {
@@ -256,10 +271,13 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro
fwUpdateResource: fwResource,
swUpdateResource: swResource,
powerMode: this.configurationValue.clientLwM2mSettings.powerMode || PowerMode.DRX,
+ edrxCycle: this.configurationValue.clientLwM2mSettings.edrxCycle || 0,
compositeOperationsSupport: this.configurationValue.clientLwM2mSettings.compositeOperationsSupport || false
}
},
{emitEvent: false});
+ this.lwm2mDeviceProfileFormGroup.get('clientLwM2mSettings.powerMode')
+ .patchValue(this.configurationValue.clientLwM2mSettings.powerMode || PowerMode.DRX, {emitEvent: false, onlySelf: true});
this.configurationValue.clientLwM2mSettings.fwUpdateResource = fwResource;
this.configurationValue.clientLwM2mSettings.swUpdateResource = swResource;
this.isFwUpdateStrategy = this.configurationValue.clientLwM2mSettings.fwUpdateStrategy === 2;
diff --git a/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-profile-config.models.ts b/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-profile-config.models.ts
index d9c2eb87ca..1a14cb354d 100644
--- a/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-profile-config.models.ts
+++ b/ui-ngx/src/app/modules/home/components/profile/device/lwm2m/lwm2m-profile-config.models.ts
@@ -169,6 +169,7 @@ export interface ClientLwM2mSettings {
fwUpdateResource: string;
swUpdateResource: string;
powerMode: PowerMode;
+ edrxCycle?: number;
compositeOperationsSupport: boolean;
}
diff --git a/ui-ngx/src/app/modules/home/pages/device/data/lwm2m-device-transport-configuration.component.html b/ui-ngx/src/app/modules/home/pages/device/data/lwm2m-device-transport-configuration.component.html
index 2bd7190831..5a59caf862 100644
--- a/ui-ngx/src/app/modules/home/pages/device/data/lwm2m-device-transport-configuration.component.html
+++ b/ui-ngx/src/app/modules/home/pages/device/data/lwm2m-device-transport-configuration.component.html
@@ -25,4 +25,15 @@
+
+ {{ 'device-profile.edrx-cycle' | translate }}
+
+
+ {{ 'device-profile.edrx-cycle-required' | translate }}
+
+
+ {{ 'device-profile.edrx-cycle-pattern' | translate }}
+
+
diff --git a/ui-ngx/src/app/modules/home/pages/device/data/lwm2m-device-transport-configuration.component.ts b/ui-ngx/src/app/modules/home/pages/device/data/lwm2m-device-transport-configuration.component.ts
index f74029c2ff..1d98f5580b 100644
--- a/ui-ngx/src/app/modules/home/pages/device/data/lwm2m-device-transport-configuration.component.ts
+++ b/ui-ngx/src/app/modules/home/pages/device/data/lwm2m-device-transport-configuration.component.ts
@@ -14,16 +14,16 @@
/// limitations under the License.
///
-import { Component, forwardRef, Input, OnInit } from '@angular/core';
+import { Component, forwardRef, Input, OnDestroy, OnInit } from '@angular/core';
import { ControlValueAccessor, FormBuilder, FormGroup, NG_VALUE_ACCESSOR, Validators } from '@angular/forms';
import { Store } from '@ngrx/store';
import { AppState } from '@app/core/core.state';
import { coerceBooleanProperty } from '@angular/cdk/coercion';
-import {
- DeviceTransportConfiguration,
- DeviceTransportType, Lwm2mDeviceTransportConfiguration
-} from '@shared/models/device.models';
-import {PowerMode, PowerModeTranslationMap} from "@home/components/profile/device/lwm2m/lwm2m-profile-config.models";
+import { DeviceTransportConfiguration, Lwm2mDeviceTransportConfiguration } from '@shared/models/device.models';
+import { PowerMode, PowerModeTranslationMap } from '@home/components/profile/device/lwm2m/lwm2m-profile-config.models';
+import { takeUntil } from 'rxjs/operators';
+import { Subject } from 'rxjs';
+import { isDefinedAndNotNull } from '@core/utils';
@Component({
selector: 'tb-lwm2m-device-transport-configuration',
@@ -35,7 +35,7 @@ import {PowerMode, PowerModeTranslationMap} from "@home/components/profile/devic
multi: true
}]
})
-export class Lwm2mDeviceTransportConfigurationComponent implements ControlValueAccessor, OnInit {
+export class Lwm2mDeviceTransportConfigurationComponent implements ControlValueAccessor, OnInit, OnDestroy {
lwm2mDeviceTransportConfigurationFormGroup: FormGroup;
powerMods = Object.values(PowerMode);
@@ -53,6 +53,7 @@ export class Lwm2mDeviceTransportConfigurationComponent implements ControlValueA
@Input()
disabled: boolean;
+ private destroy$ = new Subject();
private propagateChange = (v: any) => { };
constructor(private store: Store,
@@ -68,13 +69,35 @@ export class Lwm2mDeviceTransportConfigurationComponent implements ControlValueA
ngOnInit() {
this.lwm2mDeviceTransportConfigurationFormGroup = this.fb.group({
- powerMode: [null]
+ powerMode: [null],
+ edrxCycle: [0]
});
- this.lwm2mDeviceTransportConfigurationFormGroup.valueChanges.subscribe(() => {
+ this.lwm2mDeviceTransportConfigurationFormGroup.get('powerMode').valueChanges.pipe(
+ takeUntil(this.destroy$)
+ ).subscribe((powerMode: PowerMode) => {
+ if (powerMode === PowerMode.E_DRX) {
+ this.lwm2mDeviceTransportConfigurationFormGroup.get('edrxCycle').enable({emitEvent: false});
+ this.lwm2mDeviceTransportConfigurationFormGroup.get('edrxCycle').patchValue(0, {emitEvent: false});
+ this.lwm2mDeviceTransportConfigurationFormGroup.get('edrxCycle')
+ .setValidators([Validators.required, Validators.min(0), Validators.pattern('[0-9]*')]);
+ } else {
+ this.lwm2mDeviceTransportConfigurationFormGroup.get('edrxCycle').disable({emitEvent: false});
+ this.lwm2mDeviceTransportConfigurationFormGroup.get('edrxCycle').clearValidators();
+ }
+ this.lwm2mDeviceTransportConfigurationFormGroup.get('edrxCycle').updateValueAndValidity({emitEvent: false});
+ });
+ this.lwm2mDeviceTransportConfigurationFormGroup.valueChanges.pipe(
+ takeUntil(this.destroy$)
+ ).subscribe(() => {
this.updateModel();
});
}
+ ngOnDestroy() {
+ this.destroy$.next();
+ this.destroy$.complete();
+ }
+
setDisabledState(isDisabled: boolean): void {
this.disabled = isDisabled;
if (this.disabled) {
@@ -85,13 +108,18 @@ export class Lwm2mDeviceTransportConfigurationComponent implements ControlValueA
}
writeValue(value: Lwm2mDeviceTransportConfiguration | null): void {
- this.lwm2mDeviceTransportConfigurationFormGroup.patchValue(value, {emitEvent: false});
+ if (isDefinedAndNotNull(value)) {
+ this.lwm2mDeviceTransportConfigurationFormGroup.get('powerMode').patchValue(value.powerMode, {emitEvent: false, onlySelf: true});
+ this.lwm2mDeviceTransportConfigurationFormGroup.get('edrxCycle').patchValue(value.edrxCycle || 0, {emitEvent: false});
+ } else {
+ this.lwm2mDeviceTransportConfigurationFormGroup.patchValue({powerMode: null, edrxCycle: 0}, {emitEvent: false});
+ }
}
private updateModel() {
let configuration: DeviceTransportConfiguration = null;
if (this.lwm2mDeviceTransportConfigurationFormGroup.valid) {
- configuration = this.lwm2mDeviceTransportConfigurationFormGroup.getRawValue();
+ configuration = this.lwm2mDeviceTransportConfigurationFormGroup.value;
// configuration.type = DeviceTransportType.LWM2M;
}
this.propagateChange(configuration);
diff --git a/ui-ngx/src/app/shared/models/device.models.ts b/ui-ngx/src/app/shared/models/device.models.ts
index 3feb8c28d6..25bfd369a4 100644
--- a/ui-ngx/src/app/shared/models/device.models.ts
+++ b/ui-ngx/src/app/shared/models/device.models.ts
@@ -30,6 +30,7 @@ import { AbstractControl, ValidationErrors } from '@angular/forms';
import { OtaPackageId } from '@shared/models/id/ota-package-id';
import { DashboardId } from '@shared/models/id/dashboard-id';
import { DataType } from '@shared/models/constants';
+import { PowerMode } from '@home/components/profile/device/lwm2m/lwm2m-profile-config.models';
export enum DeviceProfileType {
DEFAULT = 'DEFAULT',
@@ -573,6 +574,8 @@ export interface CoapDeviceTransportConfiguration {
}
export interface Lwm2mDeviceTransportConfiguration {
+ powerMode?: PowerMode | null;
+ edrxCycle?: number;
[key: string]: any;
}
diff --git a/ui-ngx/src/assets/locale/locale.constant-en_US.json b/ui-ngx/src/assets/locale/locale.constant-en_US.json
index 69c35412a0..e2d4fb719e 100644
--- a/ui-ngx/src/assets/locale/locale.constant-en_US.json
+++ b/ui-ngx/src/assets/locale/locale.constant-en_US.json
@@ -1222,6 +1222,9 @@
"drx": "Discontinuous Reception (DRX)",
"edrx": "Extended Discontinuous Reception (eDRX)"
},
+ "edrx-cycle": "eDRX cycle",
+ "edrx-cycle-required": "eDRX cycle is required.",
+ "edrx-cycle-pattern": "eDRX cycle must be a positive integer.",
"lwm2m": {
"object-list": "Object list",
"object-list-empty": "No objects selected.",