Fixed a couple of bugs in AddObject method.

This commit is contained in:
Zaid Abdulla committed 2013-08-18 11:02:20 +03:00
1 parent 3ad8d08ea9
commit 13da4dc2da
1 file changed
+16 -15
+16 -15
View File
@@ -118,12 +118,9 @@ this.getParameterNames = (task, methodResponse, callback) ->
rootPath = '' rootPath = ''
ps = path.split('.') ps = path.split('.')
for p in ps for p in ps
if root[p]? rootPath += "#{p}."
root = root[p] root = root[p]
rootPath += "#{p}." break if not root?
else
root = null
break
else else
root = device['InternetGatewayDevice'] root = device['InternetGatewayDevice']
rootPath = 'InternetGatewayDevice.' rootPath = 'InternetGatewayDevice.'
@@ -135,7 +132,9 @@ this.getParameterNames = (task, methodResponse, callback) ->
parameters[p[0]] = 1 for p in methodResponse.parameterList parameters[p[0]] = 1 for p in methodResponse.parameterList
findMissingParameters(root, parameters, rootPath, deviceUpdates.deletedObjects) findMissingParameters(root, parameters, rootPath, deviceUpdates.deletedObjects)
else else
deviceUpdates.deletedObjects = [rootPath.slice(0, -1)] # avoid adding and deleting the same param
if rootPath isnt task.parameterPath
deviceUpdates.deletedObjects = [rootPath.slice(0, -1)]
# some devices don't return the root object as described in the standard. add manually to update timestamp # some devices don't return the root object as described in the standard. add manually to update timestamp
deviceUpdates.parameterNames.push([task.parameterPath]) if !!task.parameterPath deviceUpdates.parameterNames.push([task.parameterPath]) if !!task.parameterPath
@@ -241,14 +240,16 @@ this.addObject = (task, methodResponse, callback) ->
when 'getParameterValues' when 'getParameterValues'
this.getParameterValues(task.subtask, methodResponse, (err, status, cwmpResponse, deviceUpdates) => this.getParameterValues(task.subtask, methodResponse, (err, status, cwmpResponse, deviceUpdates) =>
common.extend(allDeviceUpdates, deviceUpdates) common.extend(allDeviceUpdates, deviceUpdates)
if deviceUpdates and deviceUpdates.parameterValues # if values are given, compare with default values
for p1 in deviceUpdates.parameterValues if task.parameterValues?
for p2 in task.parameterValues if deviceUpdates and deviceUpdates.parameterValues?
if common.endsWith(p1[0], ".#{p2[0]}") for p1 in deviceUpdates.parameterValues
t = if p2[2] then p2[2] else p1[2] for p2 in task.parameterValues
v = common.matchType(p1[1], p2[1]) if common.endsWith(p1[0], ".#{p2[0]}")
# TODO only include if writable t = if p2[2] then p2[2] else p1[2]
task.appliedParameterValues.push([p1[0], v, t]) v = common.matchType(p1[1], p2[1])
# TODO only include if writable
task.appliedParameterValues.push([p1[0], v, t])
if methodResponse.faultcode? if methodResponse.faultcode?
# Ignore GetParameterValues errors. A workaround for the crappy Seewon devices. # Ignore GetParameterValues errors. A workaround for the crappy Seewon devices.