|
|
@ -264,59 +264,27 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro |
|
|
const telemetryArray: Array<string> = []; |
|
|
const telemetryArray: Array<string> = []; |
|
|
const keyNameNew = {}; |
|
|
const keyNameNew = {}; |
|
|
const observeJson: ObjectLwM2M[] = JSON.parse(JSON.stringify(val)); |
|
|
const observeJson: ObjectLwM2M[] = JSON.parse(JSON.stringify(val)); |
|
|
const paths = new Set<string>(); |
|
|
|
|
|
let pathObj; |
|
|
|
|
|
let pathInst; |
|
|
|
|
|
let pathRes; |
|
|
|
|
|
observeJson.forEach(obj => { |
|
|
observeJson.forEach(obj => { |
|
|
for (const [key, value] of Object.entries(obj)) { |
|
|
if (obj.hasOwnProperty(INSTANCES) && Array.isArray(obj.instances)) { |
|
|
if (key === ID) { |
|
|
obj.instances.forEach(instance => { |
|
|
pathObj = value; |
|
|
if (instance.hasOwnProperty(RESOURCES) && Array.isArray(instance.resources)) { |
|
|
} |
|
|
instance.resources.forEach(resource => { |
|
|
if (key === INSTANCES) { |
|
|
let pathRes = `/${obj.id}/${instance.id}/${resource.id}`; |
|
|
const instancesJson = value as Instance[]; |
|
|
if (resource.attribute) { |
|
|
if (instancesJson.length > 0) { |
|
|
attributeArray.push(pathRes); |
|
|
instancesJson.forEach(instance => { |
|
|
} |
|
|
for (const [instanceKey, instanceValue] of Object.entries(instance)) { |
|
|
if (resource.telemetry) { |
|
|
if (instanceKey === ID) { |
|
|
telemetryArray.push(pathRes); |
|
|
pathInst = instanceValue; |
|
|
} |
|
|
} |
|
|
if (resource.attribute || resource.telemetry) { |
|
|
if (instanceKey === RESOURCES) { |
|
|
keyNameNew[pathRes] = resource.keyName; |
|
|
const resourcesJson = instanceValue as ResourceLwM2M[]; |
|
|
if (resource.observe) { |
|
|
if (resourcesJson.length > 0) { |
|
|
observeArray.push(pathRes); |
|
|
resourcesJson.forEach(res => { |
|
|
|
|
|
for (const [resourceKey, value] of Object.entries(res)) { |
|
|
|
|
|
if (resourceKey === ID) { |
|
|
|
|
|
pathRes = `/${pathObj}/${pathInst}/${value}`; |
|
|
|
|
|
} else if (resourceKey === ATTRIBUTE && value) { |
|
|
|
|
|
attributeArray.push(pathRes); |
|
|
|
|
|
paths.add(pathRes); |
|
|
|
|
|
} else if (resourceKey === TELEMETRY && value) { |
|
|
|
|
|
telemetryArray.push(pathRes); |
|
|
|
|
|
paths.add(pathRes); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
/** |
|
|
|
|
|
* only if these paths are marked in ATTRIBUTE or TELEMETRY |
|
|
|
|
|
*/ |
|
|
|
|
|
resourcesJson.forEach(res => { |
|
|
|
|
|
for (const [resourceKey, value] of Object.entries(res)) { |
|
|
|
|
|
if (resourceKey === ID) { |
|
|
|
|
|
pathRes = `/${pathObj}/${pathInst}/${value}`; |
|
|
|
|
|
} else if (resourceKey === OBSERVE && paths.has(pathRes) && value) { |
|
|
|
|
|
observeArray.push(pathRes); |
|
|
|
|
|
} else if (resourceKey === KEY_NAME && paths.has(pathRes)) { |
|
|
|
|
|
keyNameNew[pathRes] = value; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
}); |
|
|
}) |
|
|
} |
|
|
} |
|
|
} |
|
|
}) |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
if (isUndefined(this.configurationValue.observeAttr)) { |
|
|
if (isUndefined(this.configurationValue.observeAttr)) { |
|
|
|