Fixed bug where addObject task doesn't return response
This commit is contained in:
1 parent
bcfd56d868
commit
c268f6a321
1 file changed
+42
-39
+42
-39
@@ -221,47 +221,50 @@ this.addObject = (task, methodResponse, callback) ->
|
||||
callback(null, STATUS_STARTED, {methodRequest : {type : 'AddObject', objectName : "#{task.objectName}."}})
|
||||
return
|
||||
|
||||
if task.subtask.name is 'getParameterNames'
|
||||
this.getParameterNames(task.subtask, methodResponse, (err, status, cwmpResponse, deviceUpdates) =>
|
||||
common.extend(allDeviceUpdates, deviceUpdates)
|
||||
if deviceUpdates and deviceUpdates.parameterNames
|
||||
for p in deviceUpdates.parameterNames
|
||||
task.parameterNames.push(p[0]) if not common.endsWith(p[0], '.')
|
||||
subtask = () =>
|
||||
switch task.subtask.name
|
||||
when 'getParameterNames'
|
||||
this.getParameterNames(task.subtask, methodResponse, (err, status, cwmpResponse, deviceUpdates) =>
|
||||
common.extend(allDeviceUpdates, deviceUpdates)
|
||||
if deviceUpdates and deviceUpdates.parameterNames
|
||||
for p in deviceUpdates.parameterNames
|
||||
task.parameterNames.push(p[0]) if not common.endsWith(p[0], '.')
|
||||
|
||||
if status is STATUS_FINISHED
|
||||
task.subtask = {name : 'getParameterValues', parameterNames : task.parameterNames}
|
||||
else if status is STATUS_STARTED
|
||||
callback(err, STATUS_STARTED, cwmpResponse, allDeviceUpdates)
|
||||
else
|
||||
throw Error('Unexpected subtask status')
|
||||
)
|
||||
if status is STATUS_FINISHED
|
||||
task.subtask = {name : 'getParameterValues', parameterNames : task.parameterNames}
|
||||
subtask()
|
||||
else if status is STATUS_STARTED
|
||||
callback(err, STATUS_STARTED, cwmpResponse, allDeviceUpdates)
|
||||
else
|
||||
throw Error('Unexpected subtask status')
|
||||
)
|
||||
when 'getParameterValues'
|
||||
this.getParameterValues(task.subtask, methodResponse, (err, status, cwmpResponse, deviceUpdates) =>
|
||||
common.extend(allDeviceUpdates, deviceUpdates)
|
||||
if deviceUpdates and deviceUpdates.parameterValues
|
||||
for p1 in deviceUpdates.parameterValues
|
||||
for p2 in task.parameterValues
|
||||
if common.endsWith(p1[0], ".#{p2[0]}")
|
||||
t = if p2[2] then p2[2] else p1[2]
|
||||
v = common.matchType(p1[1], p2[1])
|
||||
# TODO only include if writable
|
||||
task.appliedParameterValues.push([p1[0], v, t])
|
||||
|
||||
if task.subtask.name is 'getParameterValues'
|
||||
this.getParameterValues(task.subtask, methodResponse, (err, status, cwmpResponse, deviceUpdates) =>
|
||||
common.extend(allDeviceUpdates, deviceUpdates)
|
||||
if deviceUpdates and deviceUpdates.parameterValues
|
||||
for p1 in deviceUpdates.parameterValues
|
||||
for p2 in task.parameterValues
|
||||
if common.endsWith(p1[0], ".#{p2[0]}")
|
||||
t = if p2[2] then p2[2] else p1[2]
|
||||
v = common.matchType(p1[1], p2[1])
|
||||
# TODO only include if writable
|
||||
task.appliedParameterValues.push([p1[0], v, t])
|
||||
|
||||
if methodResponse.faultcode?
|
||||
# Ignore GetParameterValues errors. A workaround for the crappy Seewon devices.
|
||||
methodResponse = {parameterList : {}}
|
||||
if status is STATUS_FINISHED and task.appliedParameterValues.length > 0
|
||||
task.subtask = {name : 'setParameterValues', parameterValues : task.appliedParameterValues}
|
||||
else
|
||||
callback(err, status, cwmpResponse, allDeviceUpdates)
|
||||
)
|
||||
|
||||
if task.subtask.name is 'setParameterValues'
|
||||
this.setParameterValues(task.subtask, methodResponse, (err, status, cwmpResponse, deviceUpdates) =>
|
||||
common.extend(allDeviceUpdates, deviceUpdates)
|
||||
callback(err, status, cwmpResponse, allDeviceUpdates)
|
||||
)
|
||||
if methodResponse.faultcode?
|
||||
# Ignore GetParameterValues errors. A workaround for the crappy Seewon devices.
|
||||
methodResponse = {parameterList : {}}
|
||||
if status is STATUS_FINISHED and task.appliedParameterValues.length > 0
|
||||
task.subtask = {name : 'setParameterValues', parameterValues : task.appliedParameterValues}
|
||||
subtask()
|
||||
else
|
||||
callback(err, status, cwmpResponse, allDeviceUpdates)
|
||||
)
|
||||
when 'setParameterValues'
|
||||
this.setParameterValues(task.subtask, methodResponse, (err, status, cwmpResponse, deviceUpdates) =>
|
||||
common.extend(allDeviceUpdates, deviceUpdates)
|
||||
callback(err, status, cwmpResponse, allDeviceUpdates)
|
||||
)
|
||||
subtask()
|
||||
|
||||
|
||||
this.deleteObject = (task, methodResponse, callback) ->
|
||||
|
||||
Reference in new issue
Block a user