diff --git a/acs.coffee b/acs.coffee index 52db487..f0fc488 100644 --- a/acs.coffee +++ b/acs.coffee @@ -117,11 +117,9 @@ updateDevice = (currentRequest, actions, callback) -> ) else if updates['_lastBootstrap']? # reinitialize on bootstrap event (e.g. firmware upgrade) - db.devicesCollection.update({'_id' : currentRequest.deviceId}, {'$unset' : 'InternetGatewayDevice'}, {safe: true}, (err, count) -> - task = {device : currentRequest.deviceId, name : 'init', timestamp : config.INIT_TIMESTAMP} - apiFunctions.insertTasks(task, (err) -> - callback(err) if callback? - ) + task = {device : currentRequest.deviceId, name : 'init', timestamp : config.INIT_TIMESTAMP} + apiFunctions.insertTasks(task, (err) -> + callback(err) if callback? ) else callback() if callback? diff --git a/tasks.coffee b/tasks.coffee index 60593fe..f28fa4f 100644 --- a/tasks.coffee +++ b/tasks.coffee @@ -108,21 +108,25 @@ this.getParameterNames = (task, methodResponse, callback) -> deviceUpdates = {parameterNames : methodResponse.parameterList} path = if common.endsWith(task.parameterPath, '.') then task.parameterPath.slice(0, -1) else task.parameterPath projection = {} - projection[path] = 1 + projection[path] = 1 if !!task.parameterPath # delete nonexisting params db.devicesCollection.findOne({_id : task.device}, projection, (err, device) -> if device - root = device - rootPath = '' - ps = path.split('.') - for p in ps - if root[p]? - root = root[p] - rootPath += "#{p}." - else - root = null - break + if !!task.parameterPath + root = device + rootPath = '' + ps = path.split('.') + for p in ps + if root[p]? + root = root[p] + rootPath += "#{p}." + else + root = null + break + else + root = device['InternetGatewayDevice'] + rootPath = 'InternetGatewayDevice.' if root deviceUpdates.deletedObjects = []