From 3f45c7e88771736bae719bdd996e19f31609a4cf Mon Sep 17 00:00:00 2001 From: Zaid Abdulla Date: Wed, 3 Apr 2013 09:15:46 +0300 Subject: [PATCH] Include xsi:type attribute with SetParameterValues method --- acs.coffee | 6 +++++- api.coffee | 16 ++++++++++++++++ presets.coffee | 13 +++++++------ tr-069.coffee | 6 ++++-- 4 files changed, 32 insertions(+), 9 deletions(-) diff --git a/acs.coffee b/acs.coffee index dbb3276..768836f 100644 --- a/acs.coffee +++ b/acs.coffee @@ -67,6 +67,10 @@ updateDevice = (currentRequest, actions, callback) -> updates["#{path}_orig"] = origValue updates["#{path}_value"] = v updates["#{path}_timestamp"] = now + if p[2]? + updates["#{path}_type"] = p[2] + else + deletes["#{path}_type"] = 1 if actions.parameterNames? for p in actions.parameterNames @@ -144,7 +148,7 @@ isTaskExpired = (task) -> nextTask = (currentRequest) -> cur = db.tasksCollection.find({'device' : currentRequest.deviceId}).sort(['timestamp']).limit(1) - cur.nextObject( (err, task) -> + cur.nextObject((err, task) -> cwmpResponse = {} if not task diff --git a/api.coffee b/api.coffee index a09a8f1..7bed34a 100644 --- a/api.coffee +++ b/api.coffee @@ -85,6 +85,22 @@ sanitizeTask = (deviceId, task, callback) -> task.parameterNames = parameterNames 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 # TODO implement setParameterValues callback(task) diff --git a/presets.coffee b/presets.coffee index ac5194d..c0ce6b5 100644 --- a/presets.coffee +++ b/presets.coffee @@ -71,15 +71,16 @@ exports.assertPresets = (deviceId, presetsHash, callback) -> getParameterValues = [] setParameterValues = [] for c in configurations + param = common.getParamValueFromPath(device, c.name) + continue if not param? # ignore parameters that don't exist + switch c.type when 'value' - src = common.getParamValueFromPath(device, "#{c.name}._value") - if src isnt undefined # ignore parameters that don't exist - dst = common.matchType(src, c.value) - if src != dst - setParameterValues.push([c.name, dst]) + dst = common.matchType(param._value, c.value) + if param._value != dst + setParameterValues.push([c.name, dst, param._type]) when 'age' - timeDiff = (now - common.getParamValueFromPath(device, "#{c.name}._timestamp")) / 1000 + timeDiff = (now - param._timestamp) / 1000 if (c.age - timeDiff < config.PRESETS_TIME_PADDING) expiry = Math.min(expiry, c.age) getParameterValues.push(c.name) diff --git a/tr-069.coffee b/tr-069.coffee index a50a33c..7dae2ab 100644 --- a/tr-069.coffee +++ b/tr-069.coffee @@ -56,7 +56,7 @@ parameterValueList = (xml) -> value = JSON.parse(value) catch err value = null - valueList.push([name, value]) + valueList.push([name, value, valueType]) return valueList @@ -86,7 +86,9 @@ cpeSetParameterValues = (xml, methodRequest) -> for i in methodRequest.parameterList pvs = paramList.node('ParameterValueStruct') 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 el.node('ParameterKey').text(if methodRequest.parameterKey? then methodRequest.parameterKey else '')