Add support lwm2m edrxCycle settings
This commit is contained in:
parent
8ce022b03c
commit
3d04d5b11c
@ -27,7 +27,7 @@ public class OtherConfiguration {
|
|||||||
private Integer swUpdateStrategy;
|
private Integer swUpdateStrategy;
|
||||||
private Integer clientOnlyObserveAfterConnect;
|
private Integer clientOnlyObserveAfterConnect;
|
||||||
private PowerMode powerMode;
|
private PowerMode powerMode;
|
||||||
private Long eDRXCycle;
|
private Long edrxCycle;
|
||||||
private String fwUpdateResource;
|
private String fwUpdateResource;
|
||||||
private String swUpdateResource;
|
private String swUpdateResource;
|
||||||
private boolean compositeOperationsSupport;
|
private boolean compositeOperationsSupport;
|
||||||
|
|||||||
@ -353,7 +353,7 @@ public class LwM2mClientContextImpl implements LwM2mClientContext {
|
|||||||
OtherConfiguration clientLwM2mSettings = clientProfile.getClientLwM2mSettings();
|
OtherConfiguration clientLwM2mSettings = clientProfile.getClientLwM2mSettings();
|
||||||
Long timeout = null;
|
Long timeout = null;
|
||||||
if (PowerMode.E_DRX.equals(clientLwM2mSettings.getPowerMode())) {
|
if (PowerMode.E_DRX.equals(clientLwM2mSettings.getPowerMode())) {
|
||||||
timeout = clientLwM2mSettings.getEDRXCycle();
|
timeout = clientLwM2mSettings.getEdrxCycle();
|
||||||
}
|
}
|
||||||
if (timeout == null || timeout == 0L) {
|
if (timeout == null || timeout == 0L) {
|
||||||
timeout = this.config.getTimeout();
|
timeout = this.config.getTimeout();
|
||||||
|
|||||||
@ -167,6 +167,17 @@
|
|||||||
</mat-option>
|
</mat-option>
|
||||||
</mat-select>
|
</mat-select>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
|
<mat-form-field class="mat-block" fxFlex *ngIf="lwm2mDeviceProfileFormGroup.get('clientLwM2mSettings.powerMode').value === 'E_DRX'">
|
||||||
|
<mat-label>{{ 'device-profile.edrx-cycle' | translate }}</mat-label>
|
||||||
|
<input matInput type="number" min="0" formControlName="edrxCycle" required>
|
||||||
|
<mat-error *ngIf="lwm2mDeviceProfileFormGroup.get('clientLwM2mSettings.edrxCycle').hasError('required')">
|
||||||
|
{{ 'device-profile.edrx-cycle-required' | translate }}
|
||||||
|
</mat-error>
|
||||||
|
<mat-error *ngIf="lwm2mDeviceProfileFormGroup.get('clientLwM2mSettings.edrxCycle').hasError('pattern') ||
|
||||||
|
lwm2mDeviceProfileFormGroup.get('clientLwM2mSettings.edrxCycle').hasError('min')">
|
||||||
|
{{ 'device-profile.edrx-cycle-pattern' | translate }}
|
||||||
|
</mat-error>
|
||||||
|
</mat-form-field>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
<mat-slide-toggle class="mat-slider"
|
<mat-slide-toggle class="mat-slider"
|
||||||
formControlName="compositeOperationsSupport">{{ 'device-profile.lwm2m.composite-operations-support' | translate }}</mat-slide-toggle>
|
formControlName="compositeOperationsSupport">{{ 'device-profile.lwm2m.composite-operations-support' | translate }}</mat-slide-toggle>
|
||||||
|
|||||||
@ -116,6 +116,7 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro
|
|||||||
fwUpdateResource: [{value: '', disabled: true}, []],
|
fwUpdateResource: [{value: '', disabled: true}, []],
|
||||||
swUpdateResource: [{value: '', disabled: true}, []],
|
swUpdateResource: [{value: '', disabled: true}, []],
|
||||||
powerMode: [PowerMode.DRX, Validators.required],
|
powerMode: [PowerMode.DRX, Validators.required],
|
||||||
|
edrxCycle: [0],
|
||||||
compositeOperationsSupport: [false]
|
compositeOperationsSupport: [false]
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
@ -150,6 +151,20 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro
|
|||||||
}
|
}
|
||||||
this.otaUpdateSwStrategyValidate(true);
|
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(
|
this.lwm2mDeviceProfileFormGroup.valueChanges.pipe(
|
||||||
takeUntil(this.destroy$)
|
takeUntil(this.destroy$)
|
||||||
).subscribe((value) => {
|
).subscribe((value) => {
|
||||||
@ -256,10 +271,13 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro
|
|||||||
fwUpdateResource: fwResource,
|
fwUpdateResource: fwResource,
|
||||||
swUpdateResource: swResource,
|
swUpdateResource: swResource,
|
||||||
powerMode: this.configurationValue.clientLwM2mSettings.powerMode || PowerMode.DRX,
|
powerMode: this.configurationValue.clientLwM2mSettings.powerMode || PowerMode.DRX,
|
||||||
|
edrxCycle: this.configurationValue.clientLwM2mSettings.edrxCycle || 0,
|
||||||
compositeOperationsSupport: this.configurationValue.clientLwM2mSettings.compositeOperationsSupport || false
|
compositeOperationsSupport: this.configurationValue.clientLwM2mSettings.compositeOperationsSupport || false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{emitEvent: 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.fwUpdateResource = fwResource;
|
||||||
this.configurationValue.clientLwM2mSettings.swUpdateResource = swResource;
|
this.configurationValue.clientLwM2mSettings.swUpdateResource = swResource;
|
||||||
this.isFwUpdateStrategy = this.configurationValue.clientLwM2mSettings.fwUpdateStrategy === 2;
|
this.isFwUpdateStrategy = this.configurationValue.clientLwM2mSettings.fwUpdateStrategy === 2;
|
||||||
|
|||||||
@ -169,6 +169,7 @@ export interface ClientLwM2mSettings {
|
|||||||
fwUpdateResource: string;
|
fwUpdateResource: string;
|
||||||
swUpdateResource: string;
|
swUpdateResource: string;
|
||||||
powerMode: PowerMode;
|
powerMode: PowerMode;
|
||||||
|
edrxCycle?: number;
|
||||||
compositeOperationsSupport: boolean;
|
compositeOperationsSupport: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -25,4 +25,15 @@
|
|||||||
</mat-option>
|
</mat-option>
|
||||||
</mat-select>
|
</mat-select>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
|
<mat-form-field class="mat-block" fxFlex *ngIf="lwm2mDeviceTransportConfigurationFormGroup.get('powerMode').value === 'E_DRX'">
|
||||||
|
<mat-label>{{ 'device-profile.edrx-cycle' | translate }}</mat-label>
|
||||||
|
<input matInput type="number" min="0" formControlName="edrxCycle" required>
|
||||||
|
<mat-error *ngIf="lwm2mDeviceTransportConfigurationFormGroup.get('edrxCycle').hasError('required')">
|
||||||
|
{{ 'device-profile.edrx-cycle-required' | translate }}
|
||||||
|
</mat-error>
|
||||||
|
<mat-error *ngIf="lwm2mDeviceTransportConfigurationFormGroup.get('edrxCycle').hasError('pattern') ||
|
||||||
|
lwm2mDeviceTransportConfigurationFormGroup.get('edrxCycle').hasError('min')">
|
||||||
|
{{ 'device-profile.edrx-cycle-pattern' | translate }}
|
||||||
|
</mat-error>
|
||||||
|
</mat-form-field>
|
||||||
</form>
|
</form>
|
||||||
|
|||||||
@ -14,16 +14,16 @@
|
|||||||
/// limitations under the License.
|
/// 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 { ControlValueAccessor, FormBuilder, FormGroup, NG_VALUE_ACCESSOR, Validators } from '@angular/forms';
|
||||||
import { Store } from '@ngrx/store';
|
import { Store } from '@ngrx/store';
|
||||||
import { AppState } from '@app/core/core.state';
|
import { AppState } from '@app/core/core.state';
|
||||||
import { coerceBooleanProperty } from '@angular/cdk/coercion';
|
import { coerceBooleanProperty } from '@angular/cdk/coercion';
|
||||||
import {
|
import { DeviceTransportConfiguration, Lwm2mDeviceTransportConfiguration } from '@shared/models/device.models';
|
||||||
DeviceTransportConfiguration,
|
import { PowerMode, PowerModeTranslationMap } from '@home/components/profile/device/lwm2m/lwm2m-profile-config.models';
|
||||||
DeviceTransportType, Lwm2mDeviceTransportConfiguration
|
import { takeUntil } from 'rxjs/operators';
|
||||||
} from '@shared/models/device.models';
|
import { Subject } from 'rxjs';
|
||||||
import {PowerMode, PowerModeTranslationMap} from "@home/components/profile/device/lwm2m/lwm2m-profile-config.models";
|
import { isDefinedAndNotNull } from '@core/utils';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'tb-lwm2m-device-transport-configuration',
|
selector: 'tb-lwm2m-device-transport-configuration',
|
||||||
@ -35,7 +35,7 @@ import {PowerMode, PowerModeTranslationMap} from "@home/components/profile/devic
|
|||||||
multi: true
|
multi: true
|
||||||
}]
|
}]
|
||||||
})
|
})
|
||||||
export class Lwm2mDeviceTransportConfigurationComponent implements ControlValueAccessor, OnInit {
|
export class Lwm2mDeviceTransportConfigurationComponent implements ControlValueAccessor, OnInit, OnDestroy {
|
||||||
|
|
||||||
lwm2mDeviceTransportConfigurationFormGroup: FormGroup;
|
lwm2mDeviceTransportConfigurationFormGroup: FormGroup;
|
||||||
powerMods = Object.values(PowerMode);
|
powerMods = Object.values(PowerMode);
|
||||||
@ -53,6 +53,7 @@ export class Lwm2mDeviceTransportConfigurationComponent implements ControlValueA
|
|||||||
@Input()
|
@Input()
|
||||||
disabled: boolean;
|
disabled: boolean;
|
||||||
|
|
||||||
|
private destroy$ = new Subject();
|
||||||
private propagateChange = (v: any) => { };
|
private propagateChange = (v: any) => { };
|
||||||
|
|
||||||
constructor(private store: Store<AppState>,
|
constructor(private store: Store<AppState>,
|
||||||
@ -68,13 +69,35 @@ export class Lwm2mDeviceTransportConfigurationComponent implements ControlValueA
|
|||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.lwm2mDeviceTransportConfigurationFormGroup = this.fb.group({
|
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();
|
this.updateModel();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ngOnDestroy() {
|
||||||
|
this.destroy$.next();
|
||||||
|
this.destroy$.complete();
|
||||||
|
}
|
||||||
|
|
||||||
setDisabledState(isDisabled: boolean): void {
|
setDisabledState(isDisabled: boolean): void {
|
||||||
this.disabled = isDisabled;
|
this.disabled = isDisabled;
|
||||||
if (this.disabled) {
|
if (this.disabled) {
|
||||||
@ -85,13 +108,18 @@ export class Lwm2mDeviceTransportConfigurationComponent implements ControlValueA
|
|||||||
}
|
}
|
||||||
|
|
||||||
writeValue(value: Lwm2mDeviceTransportConfiguration | null): void {
|
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() {
|
private updateModel() {
|
||||||
let configuration: DeviceTransportConfiguration = null;
|
let configuration: DeviceTransportConfiguration = null;
|
||||||
if (this.lwm2mDeviceTransportConfigurationFormGroup.valid) {
|
if (this.lwm2mDeviceTransportConfigurationFormGroup.valid) {
|
||||||
configuration = this.lwm2mDeviceTransportConfigurationFormGroup.getRawValue();
|
configuration = this.lwm2mDeviceTransportConfigurationFormGroup.value;
|
||||||
// configuration.type = DeviceTransportType.LWM2M;
|
// configuration.type = DeviceTransportType.LWM2M;
|
||||||
}
|
}
|
||||||
this.propagateChange(configuration);
|
this.propagateChange(configuration);
|
||||||
|
|||||||
@ -30,6 +30,7 @@ import { AbstractControl, ValidationErrors } from '@angular/forms';
|
|||||||
import { OtaPackageId } from '@shared/models/id/ota-package-id';
|
import { OtaPackageId } from '@shared/models/id/ota-package-id';
|
||||||
import { DashboardId } from '@shared/models/id/dashboard-id';
|
import { DashboardId } from '@shared/models/id/dashboard-id';
|
||||||
import { DataType } from '@shared/models/constants';
|
import { DataType } from '@shared/models/constants';
|
||||||
|
import { PowerMode } from '@home/components/profile/device/lwm2m/lwm2m-profile-config.models';
|
||||||
|
|
||||||
export enum DeviceProfileType {
|
export enum DeviceProfileType {
|
||||||
DEFAULT = 'DEFAULT',
|
DEFAULT = 'DEFAULT',
|
||||||
@ -573,6 +574,8 @@ export interface CoapDeviceTransportConfiguration {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface Lwm2mDeviceTransportConfiguration {
|
export interface Lwm2mDeviceTransportConfiguration {
|
||||||
|
powerMode?: PowerMode | null;
|
||||||
|
edrxCycle?: number;
|
||||||
[key: string]: any;
|
[key: string]: any;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1222,6 +1222,9 @@
|
|||||||
"drx": "Discontinuous Reception (DRX)",
|
"drx": "Discontinuous Reception (DRX)",
|
||||||
"edrx": "Extended Discontinuous Reception (eDRX)"
|
"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": {
|
"lwm2m": {
|
||||||
"object-list": "Object list",
|
"object-list": "Object list",
|
||||||
"object-list-empty": "No objects selected.",
|
"object-list-empty": "No objects selected.",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user