Added boot and bootstrap timestamps

This commit is contained in:
Zaid Abdulla committed 2013-05-14 14:28:00 +03:00
1 parent 9f156c2c88
commit 65e7b22149
1 file changed
+6 -2
+6 -2
View File
@@ -52,8 +52,10 @@ updateDevice = (currentRequest, actions, callback) ->
now = new Date(Date.now())
updates = {}
deletes = {}
if actions.inform
if actions.inform?
updates['_last_inform'] = now
updates['_lastBoot'] = now if '1 BOOT' in actions.inform
updates['_lastBootstrap'] = now if '0 BOOTSTRAP' in actions.inform
if actions.parameterValues?
for p in actions.parameterValues
@@ -146,6 +148,7 @@ isTaskExpired = (task) ->
return true
return false
nextTask = (currentRequest) ->
cur = db.tasksCollection.find({'device' : currentRequest.deviceId}).sort(['timestamp']).limit(1)
cur.nextObject((err, task) ->
@@ -190,6 +193,7 @@ nextTask = (currentRequest) ->
runTask(currentRequest, task, {})
)
listener = (httpRequest, httpResponse) ->
if httpRequest.method != 'POST'
#console.log '>>> 405 Method Not Allowed'
@@ -244,7 +248,7 @@ listener = (httpRequest, httpResponse) ->
if config.LOG_INFORMS
util.log("#{currentRequest.deviceId}: Inform (#{cwmpRequest.methodRequest.event}); retry count #{cwmpRequest.methodRequest.retryCount}")
updateDevice(currentRequest, {'inform' : true, 'parameterValues' : cwmpRequest.methodRequest.parameterList}, (err) ->
updateDevice(currentRequest, {'inform' : cwmpRequest.methodRequest.event, 'parameterValues' : cwmpRequest.methodRequest.parameterList}, (err) ->
res = tr069.response(cwmpRequest.id, cwmpResponse, cookies)
writeResponse(currentRequest, res)
)