|
|
|
@ -43,7 +43,9 @@ import { |
|
|
|
RESOURCES, |
|
|
|
ServerSecurityConfig, |
|
|
|
TELEMETRY, |
|
|
|
ObjectIDVerTranslationMap |
|
|
|
ObjectIDVerTranslationMap, |
|
|
|
ObserveStrategy, |
|
|
|
ObserveStrategyMap |
|
|
|
} from './lwm2m-profile-config.models'; |
|
|
|
import { DeviceProfileService } from '@core/http/device-profile.service'; |
|
|
|
import { deepClone, isDefinedAndNotNull, isEmpty } from '@core/utils'; |
|
|
|
@ -84,6 +86,9 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro |
|
|
|
objectIDVers = Object.values(ObjectIDVer) as ObjectIDVer[]; |
|
|
|
objectIDVerTranslationMap = ObjectIDVerTranslationMap; |
|
|
|
|
|
|
|
observeStrategyList = Object.values(ObserveStrategy) as ObserveStrategy[]; |
|
|
|
observeStrategyMap = ObserveStrategyMap; |
|
|
|
|
|
|
|
sortFunction: (key: string, value: object) => object; |
|
|
|
|
|
|
|
@Input() |
|
|
|
@ -102,6 +107,7 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro |
|
|
|
observeAttrTelemetry: [null], |
|
|
|
bootstrapServerUpdateEnable: [false], |
|
|
|
bootstrap: [[]], |
|
|
|
observeStrategy: [null, []], |
|
|
|
clientLwM2mSettings: this.fb.group({ |
|
|
|
clientOnlyObserveAfterConnect: [1, []], |
|
|
|
useObject19ForOtaInfo: [false], |
|
|
|
@ -173,6 +179,10 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
this.lwm2mDeviceProfileFormGroup.get('objectIds').valueChanges.pipe( |
|
|
|
takeUntil(this.destroy$) |
|
|
|
).subscribe(value => this.updateObserveStrategy(value)); |
|
|
|
|
|
|
|
this.lwm2mDeviceProfileFormGroup.valueChanges.pipe( |
|
|
|
takeUntil(this.destroy$) |
|
|
|
).subscribe((value) => { |
|
|
|
@ -261,6 +271,7 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro |
|
|
|
observeAttrTelemetry: this.getObserveAttrTelemetryObjects(value), |
|
|
|
bootstrap: this.configurationValue.bootstrap, |
|
|
|
bootstrapServerUpdateEnable: this.configurationValue.bootstrapServerUpdateEnable || false, |
|
|
|
observeStrategy: this.configurationValue.observeAttr.observeStrategy || ObserveStrategy.SINGLE, |
|
|
|
clientLwM2mSettings: { |
|
|
|
clientOnlyObserveAfterConnect: this.configurationValue.clientLwM2mSettings.clientOnlyObserveAfterConnect, |
|
|
|
useObject19ForOtaInfo: this.configurationValue.clientLwM2mSettings.useObject19ForOtaInfo ?? false, |
|
|
|
@ -283,6 +294,7 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro |
|
|
|
this.lwm2mDeviceProfileFormGroup.get('clientLwM2mSettings.fwUpdateStrategy').updateValueAndValidity({onlySelf: true}); |
|
|
|
this.lwm2mDeviceProfileFormGroup.get('clientLwM2mSettings.swUpdateStrategy').updateValueAndValidity({onlySelf: true}); |
|
|
|
} |
|
|
|
this.updateObserveStrategy(value); |
|
|
|
this.cd.markForCheck(); |
|
|
|
} |
|
|
|
|
|
|
|
@ -427,6 +439,7 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro |
|
|
|
const telemetryArray: Array<string> = []; |
|
|
|
const attributes: any = {}; |
|
|
|
const keyNameNew = {}; |
|
|
|
const observeStrategyValue = this.lwm2mDeviceProfileFormGroup.get('observeStrategy').value; |
|
|
|
const observeJson: ObjectLwM2M[] = JSON.parse(JSON.stringify(val)); |
|
|
|
observeJson.forEach(obj => { |
|
|
|
if (isDefinedAndNotNull(obj.attributes) && !isEmpty(obj.attributes)) { |
|
|
|
@ -467,7 +480,8 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro |
|
|
|
attribute: attributeArray, |
|
|
|
telemetry: telemetryArray, |
|
|
|
keyName: this.sortObjectKeyPathJson(KEY_NAME, keyNameNew), |
|
|
|
attributeLwm2m: attributes |
|
|
|
attributeLwm2m: attributes, |
|
|
|
observeStrategy: observeStrategyValue |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
@ -568,4 +582,12 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro |
|
|
|
return this.lwm2mDeviceProfileFormGroup.get('clientLwM2mSettings') as UntypedFormGroup; |
|
|
|
} |
|
|
|
|
|
|
|
private updateObserveStrategy(value: ObjectLwM2M[]) { |
|
|
|
if (value.length && !this.disabled) { |
|
|
|
this.lwm2mDeviceProfileFormGroup.get('observeStrategy').enable({onlySelf: true}); |
|
|
|
} else { |
|
|
|
this.lwm2mDeviceProfileFormGroup.get('observeStrategy').disable({onlySelf: true}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|