@ -30,7 +30,8 @@ import {
DEFAULT_NOTIF_IF_DESIBLED ,
DEFAULT_SW_UPDATE_RESOURCE ,
getDefaultBootstrapServerSecurityConfig ,
getDefaultBootstrapServersSecurityConfig , getDefaultLwM2MServerSecurityConfig ,
getDefaultBootstrapServersSecurityConfig ,
getDefaultLwM2MServerSecurityConfig ,
getDefaultProfileClientLwM2mSettingsConfig ,
getDefaultProfileObserveAttrConfig ,
Instance ,
@ -41,7 +42,10 @@ import {
ObjectLwM2M ,
OBSERVE ,
OBSERVE_ATTR_TELEMETRY ,
RESOURCES , ServerSecurityConfig ,
PowerMode ,
PowerModeTranslationMap ,
RESOURCES ,
ServerSecurityConfig ,
TELEMETRY
} from './lwm2m-profile-config.models' ;
import { DeviceProfileService } from '@core/http/device-profile.service' ;
@ -76,6 +80,8 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro
sortFunction : ( key : string , value : object ) = > object ;
isFwUpdateStrategy : boolean ;
isSwUpdateStrategy : boolean ;
powerMods = Object . values ( PowerMode ) ;
powerModeTranslationMap = PowerModeTranslationMap ;
get required ( ) : boolean {
return this . requiredValue ;
@ -109,8 +115,9 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro
clientOnlyObserveAfterConnect : [ 1 , [ ] ] ,
fwUpdateStrategy : [ 1 , [ ] ] ,
swUpdateStrategy : [ 1 , [ ] ] ,
fwUpdateRecourse : [ { value : '' , disabled : true } , [ ] ] ,
swUpdateRecourse : [ { value : '' , disabled : true } , [ ] ]
fwUpdateResource : [ { value : '' , disabled : true } , [ ] ] ,
swUpdateResource : [ { value : '' , disabled : true } , [ ] ] ,
powerMode : [ null , Validators . required ]
} )
} ) ;
this . lwm2mDeviceConfigFormGroup = this . fb . group ( {
@ -120,12 +127,12 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro
takeUntil ( this . destroy $ )
) . subscribe ( ( fwStrategy ) = > {
if ( fwStrategy === 2 ) {
this . lwm2mDeviceProfileFormGroup . get ( 'clientLwM2mSettings.fwUpdateRecours e' ) . enable ( { emitEvent : false } ) ;
this . lwm2mDeviceProfileFormGroup . get ( 'clientLwM2mSettings.fwUpdateRecours e' )
this . lwm2mDeviceProfileFormGroup . get ( 'clientLwM2mSettings.fwUpdateResourc e' ) . enable ( { emitEvent : false } ) ;
this . lwm2mDeviceProfileFormGroup . get ( 'clientLwM2mSettings.fwUpdateResourc e' )
. patchValue ( DEFAULT_FW_UPDATE_RESOURCE , { emitEvent : false } ) ;
this . isFwUpdateStrategy = true ;
} else {
this . lwm2mDeviceProfileFormGroup . get ( 'clientLwM2mSettings.fwUpdateRecours e' ) . disable ( { emitEvent : false } ) ;
this . lwm2mDeviceProfileFormGroup . get ( 'clientLwM2mSettings.fwUpdateResourc e' ) . disable ( { emitEvent : false } ) ;
this . isFwUpdateStrategy = false ;
}
this . otaUpdateFwStrategyValidate ( true ) ;
@ -134,13 +141,13 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro
takeUntil ( this . destroy $ )
) . subscribe ( ( swStrategy ) = > {
if ( swStrategy === 2 ) {
this . lwm2mDeviceProfileFormGroup . get ( 'clientLwM2mSettings.swUpdateRecours e' ) . enable ( { emitEvent : false } ) ;
this . lwm2mDeviceProfileFormGroup . get ( 'clientLwM2mSettings.swUpdateRecours e' )
this . lwm2mDeviceProfileFormGroup . get ( 'clientLwM2mSettings.swUpdateResourc e' ) . enable ( { emitEvent : false } ) ;
this . lwm2mDeviceProfileFormGroup . get ( 'clientLwM2mSettings.swUpdateResourc e' )
. patchValue ( DEFAULT_SW_UPDATE_RESOURCE , { emitEvent : false } ) ;
this . isSwUpdateStrategy = true ;
} else {
this . isSwUpdateStrategy = false ;
this . lwm2mDeviceProfileFormGroup . get ( 'clientLwM2mSettings.swUpdateRecours e' ) . disable ( { emitEvent : false } ) ;
this . lwm2mDeviceProfileFormGroup . get ( 'clientLwM2mSettings.swUpdateResourc e' ) . disable ( { emitEvent : false } ) ;
}
this . otaUpdateSwStrategyValidate ( true ) ;
} ) ;
@ -237,10 +244,10 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro
}
private updateWriteValue = ( value : ModelValue ) : void = > {
const fwResource = isDefinedAndNotNull ( this . configurationValue . clientLwM2mSettings . fwUpdateRecours e ) ?
this . configurationValue . clientLwM2mSettings . fwUpdateRecours e : '' ;
const swResource = isDefinedAndNotNull ( this . configurationValue . clientLwM2mSettings . fwUpdateRecours e) ?
this . configurationValue . clientLwM2mSettings . swUpdateRecours e : '' ;
const fwResource = isDefinedAndNotNull ( this . configurationValue . clientLwM2mSettings . fwUpdateResourc e ) ?
this . configurationValue . clientLwM2mSettings . fwUpdateResourc e : '' ;
const swResource = isDefinedAndNotNull ( this . configurationValue . clientLwM2mSettings . swUpdateResourc e) ?
this . configurationValue . clientLwM2mSettings . swUpdateResourc e : '' ;
this . lwm2mDeviceProfileFormGroup . patchValue ( {
objectIds : value ,
observeAttrTelemetry : this.getObserveAttrTelemetryObjects ( value . objectsList ) ,
@ -249,13 +256,14 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro
clientOnlyObserveAfterConnect : this.configurationValue.clientLwM2mSettings.clientOnlyObserveAfterConnect ,
fwUpdateStrategy : this.configurationValue.clientLwM2mSettings.fwUpdateStrategy || 1 ,
swUpdateStrategy : this.configurationValue.clientLwM2mSettings.swUpdateStrategy || 1 ,
fwUpdateRecourse : fwResource ,
swUpdateRecourse : swResource
fwUpdateResource : fwResource ,
swUpdateResource : swResource ,
powerMode : this.configurationValue.clientLwM2mSettings.powerMode
}
} ,
{ emitEvent : false } ) ;
this . configurationValue . clientLwM2mSettings . fwUpdateRecours e = fwResource ;
this . configurationValue . clientLwM2mSettings . swUpdateRecours e = swResource ;
this . configurationValue . clientLwM2mSettings . fwUpdateResourc e = fwResource ;
this . configurationValue . clientLwM2mSettings . swUpdateResourc e = swResource ;
this . isFwUpdateStrategy = this . configurationValue . clientLwM2mSettings . fwUpdateStrategy === 2 ;
this . isSwUpdateStrategy = this . configurationValue . clientLwM2mSettings . swUpdateStrategy === 2 ;
this . otaUpdateSwStrategyValidate ( ) ;
@ -561,20 +569,20 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro
private otaUpdateFwStrategyValidate ( updated = false ) : void {
if ( this . isFwUpdateStrategy ) {
this . lwm2mDeviceProfileFormGroup . get ( 'clientLwM2mSettings.fwUpdateRecours e' ) . setValidators ( [ Validators . required ] ) ;
this . lwm2mDeviceProfileFormGroup . get ( 'clientLwM2mSettings.fwUpdateResourc e' ) . setValidators ( [ Validators . required ] ) ;
} else {
this . lwm2mDeviceProfileFormGroup . get ( 'clientLwM2mSettings.fwUpdateRecours e' ) . clearValidators ( ) ;
this . lwm2mDeviceProfileFormGroup . get ( 'clientLwM2mSettings.fwUpdateResourc e' ) . clearValidators ( ) ;
}
this . lwm2mDeviceProfileFormGroup . get ( 'clientLwM2mSettings.fwUpdateRecours e' ) . updateValueAndValidity ( { emitEvent : updated } ) ;
this . lwm2mDeviceProfileFormGroup . get ( 'clientLwM2mSettings.fwUpdateResourc e' ) . updateValueAndValidity ( { emitEvent : updated } ) ;
}
private otaUpdateSwStrategyValidate ( updated = false ) : void {
if ( this . isSwUpdateStrategy ) {
this . lwm2mDeviceProfileFormGroup . get ( 'clientLwM2mSettings.swUpdateRecours e' ) . setValidators ( [ Validators . required ] ) ;
this . lwm2mDeviceProfileFormGroup . get ( 'clientLwM2mSettings.swUpdateResourc e' ) . setValidators ( [ Validators . required ] ) ;
} else {
this . lwm2mDeviceProfileFormGroup . get ( 'clientLwM2mSettings.swUpdateRecours e' ) . clearValidators ( ) ;
this . lwm2mDeviceProfileFormGroup . get ( 'clientLwM2mSettings.swUpdateResourc e' ) . clearValidators ( ) ;
}
this . lwm2mDeviceProfileFormGroup . get ( 'clientLwM2mSettings.swUpdateRecours e' ) . updateValueAndValidity ( { emitEvent : updated } ) ;
this . lwm2mDeviceProfileFormGroup . get ( 'clientLwM2mSettings.swUpdateResourc e' ) . updateValueAndValidity ( { emitEvent : updated } ) ;
}
}