Commit 5f3cf1e3a2a77a13cde03d3309540824d43cf059
1 parent
c14e2c81
Lwm2m: front: update filter for keyName
Showing
3 changed files
with
14 additions
and
44 deletions
... | ... | @@ -154,7 +154,7 @@ public class LwM2MTransportServiceImpl implements LwM2MTransportService { |
154 | 154 | lwM2MClient.setLwM2MTransportServiceImpl(this); |
155 | 155 | lwM2MClient.setSessionUuid(UUID.randomUUID()); |
156 | 156 | this.sentLogsToThingsboard(LOG_LW2M_INFO + ": Client Registered", registration); |
157 | -// this.setLwM2mFromClientValue(lwServer, registration, lwM2MClient); | |
157 | + this.setLwM2mFromClientValue(lwServer, registration, lwM2MClient); | |
158 | 158 | SessionInfoProto sessionInfo = this.getValidateSessionInfo(registration); |
159 | 159 | if (sessionInfo != null) { |
160 | 160 | lwM2MClient.setDeviceUuid(new UUID(sessionInfo.getDeviceIdMSB(), sessionInfo.getDeviceIdLSB())); | ... | ... |
... | ... | @@ -93,7 +93,7 @@ public class LwM2MClient implements Cloneable { |
93 | 93 | this.pendingRequests.remove(path); |
94 | 94 | if (this.pendingRequests.size() == 0) { |
95 | 95 | this.initValue(); |
96 | -// this.lwM2MTransportServiceImpl.putDelayedUpdateResourcesThingsboard(this); | |
96 | + this.lwM2MTransportServiceImpl.putDelayedUpdateResourcesThingsboard(this); | |
97 | 97 | } |
98 | 98 | } |
99 | 99 | |
... | ... | @@ -106,7 +106,7 @@ public class LwM2MClient implements Cloneable { |
106 | 106 | ((LwM2mObjectInstance)((ReadResponse)resp).getContent()).getResources().forEach((k, v) -> { |
107 | 107 | String rez = pathIds.toString() + "/" + k; |
108 | 108 | if (((LwM2mObjectInstance) ((ReadResponse) resp).getContent()).getResource(k) instanceof LwM2mMultipleResource){ |
109 | -// this.resources.put(rez, new ResourceValue(v.getInstances().values(), null, true)); | |
109 | + this.resources.put(rez, new ResourceValue(v.getValues(), null, true)); | |
110 | 110 | } |
111 | 111 | else { |
112 | 112 | this.resources.put(rez, new ResourceValue(null, v.getValue(), false)); | ... | ... |
... | ... | @@ -271,6 +271,7 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro |
271 | 271 | const observeArray: Array<string> = []; |
272 | 272 | const attributeArray: Array<string> = []; |
273 | 273 | const telemetryArray: Array<string> = []; |
274 | + const keyNameNew = {}; | |
274 | 275 | const observeJson: ObjectLwM2M[] = JSON.parse(JSON.stringify(val)); |
275 | 276 | const paths = new Set<string>(); |
276 | 277 | let pathObj; |
... | ... | @@ -293,18 +294,22 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro |
293 | 294 | const resourcesJson = instanceValue as ResourceLwM2M[]; |
294 | 295 | if (resourcesJson.length > 0) { |
295 | 296 | resourcesJson.forEach(res => { |
296 | - for (const [resourceKey, idResource] of Object.entries(res)) { | |
297 | + for (const [resourceKey, value] of Object.entries(res)) { | |
297 | 298 | if (resourceKey === 'id') { |
298 | - pathRes = `/${pathObj}/${pathInst}/${idResource}`; | |
299 | - } else if (resourceKey === 'observe' && idResource) { | |
299 | + pathRes = `/${pathObj}/${pathInst}/${value}`; | |
300 | + } else if (resourceKey === 'observe' && value) { | |
300 | 301 | observeArray.push(pathRes); |
301 | - } else if (resourceKey === 'attribute' && idResource) { | |
302 | + } else if (resourceKey === 'attribute' && value) { | |
302 | 303 | attributeArray.push(pathRes); |
303 | 304 | paths.add(pathRes); |
304 | - } else if (resourceKey === 'telemetry' && idResource) { | |
305 | + } else if (resourceKey === 'telemetry' && value) { | |
305 | 306 | telemetryArray.push(pathRes); |
306 | 307 | paths.add(pathRes); |
307 | 308 | } |
309 | + else if (resourceKey === this.keyName && paths.has(pathRes)) { | |
310 | + console.warn(pathRes, value); | |
311 | + keyNameNew[pathRes] = value; | |
312 | + } | |
308 | 313 | } |
309 | 314 | }); |
310 | 315 | } |
... | ... | @@ -326,7 +331,7 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro |
326 | 331 | this.configurationValue[this.observeAttr][this.attribute] = attributeArray; |
327 | 332 | this.configurationValue[this.observeAttr][this.telemetry] = telemetryArray; |
328 | 333 | } |
329 | - this.updateKeyName(paths); | |
334 | + this.configurationValue[this.observeAttr][this.keyName] = this.sortObjectKeyPathJson('keyName', keyNameNew); | |
330 | 335 | } |
331 | 336 | |
332 | 337 | sortObjectKeyPathJson = (key: string, value: object): object => { |
... | ... | @@ -352,41 +357,6 @@ export class Lwm2mDeviceProfileTransportConfigurationComponent implements Contro |
352 | 357 | }); |
353 | 358 | } |
354 | 359 | |
355 | - private updateKeyName = (paths: Set<string>): void => { | |
356 | - const keyNameNew = {}; | |
357 | - paths.forEach(path => { | |
358 | - const pathParameter = this.findIndexesForIds(path); | |
359 | - if (pathParameter.length === 3) { | |
360 | - keyNameNew[path] = this.lwm2mDeviceProfileFormGroup.get('observeAttrTelemetry').value | |
361 | - .clientLwM2M[pathParameter[0]].instances[pathParameter[1]].resources[pathParameter[2]][this.keyName]; | |
362 | - } | |
363 | - }); | |
364 | - this.configurationValue[this.observeAttr][this.keyName] = this.sortObjectKeyPathJson('keyName', keyNameNew); | |
365 | - } | |
366 | - | |
367 | - private findIndexesForIds = (path: string): number[] => { | |
368 | - const [objectId, instanceId, resourceId] = Array.from(path.substring(1).split('/'), Number); | |
369 | - // TODO: All paths to map | |
370 | - const pathParameterIndexes: number[] = []; | |
371 | - const objectsOld = this.lwm2mDeviceProfileFormGroup.get('observeAttrTelemetry').value.clientLwM2M as ObjectLwM2M[]; | |
372 | - let isIdIndex = (element) => element.id === objectId; | |
373 | - const objIndex = objectsOld.findIndex(isIdIndex); | |
374 | - if (objIndex >= 0) { | |
375 | - pathParameterIndexes.push(objIndex); | |
376 | - isIdIndex = (element) => element.id === instanceId; | |
377 | - const instIndex = objectsOld[objIndex].instances.findIndex(isIdIndex); | |
378 | - if (instIndex >= 0) { | |
379 | - pathParameterIndexes.push(instIndex); | |
380 | - isIdIndex = (element) => element.id === resourceId; | |
381 | - const resIndex = objectsOld[objIndex].instances[instIndex].resources.findIndex(isIdIndex); | |
382 | - if (resIndex >= 0) { | |
383 | - pathParameterIndexes.push(resIndex); | |
384 | - } | |
385 | - } | |
386 | - } | |
387 | - return pathParameterIndexes; | |
388 | - } | |
389 | - | |
390 | 360 | private getObjectsFromJsonAllConfig = (): number[] => { |
391 | 361 | const objectsIds = new Set<number>(); |
392 | 362 | if (this.configurationValue[this.observeAttr]) { | ... | ... |