From bdad2f9a322d50ceb2c775ca6a0a8da1381f2335 Mon Sep 17 00:00:00 2001 From: Zaid Abdulla Date: Thu, 4 Feb 2021 22:54:30 -0800 Subject: [PATCH] Implicit fetch of 'writable' attribute The writable attribute may not already be present when attempting to modify parameters included in the inform message. For other parameters the writable attrbiute is guarenteed to have already been fetched during discovery. --- lib/session.ts | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/lib/session.ts b/lib/session.ts index abf4e66..f350a6e 100644 --- a/lib/session.ts +++ b/lib/session.ts @@ -910,10 +910,15 @@ function runDeclarations( if (!unpacked) unpacked = device.unpack(sessionContext.deviceData, path); - for (const u of unpacked) + for (const u of unpacked) { mergeAttributeValues(u, declaration.attrSet, declaration.defer); + // Ensure writable attr is available + mergeAttributeTimestamps(u, { writable: 1 }); + } } else { mergeAttributeValues(path, declaration.attrSet, declaration.defer); + // Ensure writable attr is available + mergeAttributeTimestamps(path, { writable: 1 }); } } @@ -937,14 +942,15 @@ function runDeclarations( keys = {}; } - if ( - ((path.wildcard | path.alias) & ((1 << (path.length - 1)) - 1)) === - 0 - ) { + if (!parent.wildcard && !parent.alias) { parent = sessionContext.deviceData.paths.add(parent); if (!unpacked) unpacked = device.unpack(sessionContext.deviceData, path); + // Ensure writable attr is available + mergeAttributeTimestamps(parent, { writable: 1 }); + for (const u of unpacked) mergeAttributeTimestamps(u, { writable: 1 }); + processInstances( sessionContext, parent, @@ -960,13 +966,19 @@ function runDeclarations( parent ); for (const par of parentsUnpacked) { + const up = device.unpack( + sessionContext.deviceData, + par.concat(path.slice(-1)) + ); + + // Ensure writable attr is available + mergeAttributeTimestamps(par, { writable: 1 }); + for (const u of up) mergeAttributeTimestamps(u, { writable: 1 }); + processInstances( sessionContext, par, - device.unpack( - sessionContext.deviceData, - par.concat(path.slice(-1)) - ), + up, keys, minInstances, maxInstances,