Include xsi:type attribute with SetParameterValues method
This commit is contained in:
1 parent
5934178d91
commit
3f45c7e887
4 files changed
+32
-9
No files matched your search
+5
-1
@@ -67,6 +67,10 @@ updateDevice = (currentRequest, actions, callback) ->
|
|||||||
updates["#{path}_orig"] = origValue
|
updates["#{path}_orig"] = origValue
|
||||||
updates["#{path}_value"] = v
|
updates["#{path}_value"] = v
|
||||||
updates["#{path}_timestamp"] = now
|
updates["#{path}_timestamp"] = now
|
||||||
|
if p[2]?
|
||||||
|
updates["#{path}_type"] = p[2]
|
||||||
|
else
|
||||||
|
deletes["#{path}_type"] = 1
|
||||||
|
|
||||||
if actions.parameterNames?
|
if actions.parameterNames?
|
||||||
for p in actions.parameterNames
|
for p in actions.parameterNames
|
||||||
@@ -144,7 +148,7 @@ isTaskExpired = (task) ->
|
|||||||
|
|
||||||
nextTask = (currentRequest) ->
|
nextTask = (currentRequest) ->
|
||||||
cur = db.tasksCollection.find({'device' : currentRequest.deviceId}).sort(['timestamp']).limit(1)
|
cur = db.tasksCollection.find({'device' : currentRequest.deviceId}).sort(['timestamp']).limit(1)
|
||||||
cur.nextObject( (err, task) ->
|
cur.nextObject((err, task) ->
|
||||||
cwmpResponse = {}
|
cwmpResponse = {}
|
||||||
|
|
||||||
if not task
|
if not task
|
||||||
|
|||||||
+16
@@ -85,6 +85,22 @@ sanitizeTask = (deviceId, task, callback) ->
|
|||||||
task.parameterNames = parameterNames
|
task.parameterNames = parameterNames
|
||||||
callback(task)
|
callback(task)
|
||||||
)
|
)
|
||||||
|
when 'setParameterValues'
|
||||||
|
projection = {}
|
||||||
|
values = {}
|
||||||
|
for p in task.parameterValues
|
||||||
|
for pp in expandParam(p[0])
|
||||||
|
projection[pp] = 1
|
||||||
|
values[pp] = p[1]
|
||||||
|
db.devicesCollection.findOne({_id : deviceId}, projection, (err, device) ->
|
||||||
|
parameterValues = []
|
||||||
|
for k of projection
|
||||||
|
param = common.getParamValueFromPath(device, k)
|
||||||
|
if param?
|
||||||
|
parameterValues.push([k, values[k], param._type])
|
||||||
|
task.parameterValues = parameterValues
|
||||||
|
callback(task)
|
||||||
|
)
|
||||||
else
|
else
|
||||||
# TODO implement setParameterValues
|
# TODO implement setParameterValues
|
||||||
callback(task)
|
callback(task)
|
||||||
|
|||||||
+7
-6
@@ -71,15 +71,16 @@ exports.assertPresets = (deviceId, presetsHash, callback) ->
|
|||||||
getParameterValues = []
|
getParameterValues = []
|
||||||
setParameterValues = []
|
setParameterValues = []
|
||||||
for c in configurations
|
for c in configurations
|
||||||
|
param = common.getParamValueFromPath(device, c.name)
|
||||||
|
continue if not param? # ignore parameters that don't exist
|
||||||
|
|
||||||
switch c.type
|
switch c.type
|
||||||
when 'value'
|
when 'value'
|
||||||
src = common.getParamValueFromPath(device, "#{c.name}._value")
|
dst = common.matchType(param._value, c.value)
|
||||||
if src isnt undefined # ignore parameters that don't exist
|
if param._value != dst
|
||||||
dst = common.matchType(src, c.value)
|
setParameterValues.push([c.name, dst, param._type])
|
||||||
if src != dst
|
|
||||||
setParameterValues.push([c.name, dst])
|
|
||||||
when 'age'
|
when 'age'
|
||||||
timeDiff = (now - common.getParamValueFromPath(device, "#{c.name}._timestamp")) / 1000
|
timeDiff = (now - param._timestamp) / 1000
|
||||||
if (c.age - timeDiff < config.PRESETS_TIME_PADDING)
|
if (c.age - timeDiff < config.PRESETS_TIME_PADDING)
|
||||||
expiry = Math.min(expiry, c.age)
|
expiry = Math.min(expiry, c.age)
|
||||||
getParameterValues.push(c.name)
|
getParameterValues.push(c.name)
|
||||||
|
|||||||
+4
-2
@@ -56,7 +56,7 @@ parameterValueList = (xml) ->
|
|||||||
value = JSON.parse(value)
|
value = JSON.parse(value)
|
||||||
catch err
|
catch err
|
||||||
value = null
|
value = null
|
||||||
valueList.push([name, value])
|
valueList.push([name, value, valueType])
|
||||||
return valueList
|
return valueList
|
||||||
|
|
||||||
|
|
||||||
@@ -86,7 +86,9 @@ cpeSetParameterValues = (xml, methodRequest) ->
|
|||||||
for i in methodRequest.parameterList
|
for i in methodRequest.parameterList
|
||||||
pvs = paramList.node('ParameterValueStruct')
|
pvs = paramList.node('ParameterValueStruct')
|
||||||
pvs.node('Name').text(i[0])
|
pvs.node('Name').text(i[0])
|
||||||
pvs.node('Value').text(i[1])
|
v = pvs.node('Value')
|
||||||
|
v.text(i[1])
|
||||||
|
v.attr({'xsi:type' : i[2]}) if i[2]?
|
||||||
# Huawei CPEs need this element present otherwise won't respond
|
# Huawei CPEs need this element present otherwise won't respond
|
||||||
el.node('ParameterKey').text(if methodRequest.parameterKey? then methodRequest.parameterKey else '')
|
el.node('ParameterKey').text(if methodRequest.parameterKey? then methodRequest.parameterKey else '')
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user