From 65e7b22149d3e0806f299bab659f8c3c466058e8 Mon Sep 17 00:00:00 2001 From: Zaid Abdulla Date: Tue, 14 May 2013 14:28:00 +0300 Subject: [PATCH] Added boot and bootstrap timestamps --- acs.coffee | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/acs.coffee b/acs.coffee index 768836f..c8ee439 100644 --- a/acs.coffee +++ b/acs.coffee @@ -33,7 +33,7 @@ writeResponse = (currentRequest, res) -> res.headers['Connection'] = 'close' if currentRequest.httpRequest.httpVersion == '1.1' else res.headers['Connection'] = 'Keep-Alive' if currentRequest.httpRequest.httpVersion == '1.0' - + if config.DEBUG_DEVICES[currentRequest.deviceId] dump = "# RESPONSE #{new Date(Date.now())}\n" + JSON.stringify(res.headers) + "\n#{res.data}\n\n" fs = require('fs').appendFile("debug/#{currentRequest.deviceId}.dump", dump, (err) -> @@ -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) )