diff --git a/libs/control/ptz.js b/libs/control/ptz.js index 5b37d33c..580f312a 100644 --- a/libs/control/ptz.js +++ b/libs/control/ptz.js @@ -1,5 +1,6 @@ var os = require('os'); var exec = require('child_process').exec; +var request = require('request') module.exports = function(s,config,lang,app,io){ const moveLock = {} const startMove = async function(options,callback){ @@ -195,14 +196,14 @@ module.exports = function(s,config,lang,app,io){ }else{ const controlUrlStopTimeout = parseInt(monitorConfig.details.control_url_stop_timeout) || 1000 var stopCamera = function(){ - var stopURL = controlBaseUrl + monitorConfig.details[`control_url_${options.direction}_stop`] - var options = s.cameraControlOptionsFromUrl(stopURL,monitorConfig) - var requestOptions = { + let stopURL = controlBaseUrl + monitorConfig.details[`control_url_${options.direction}_stop`] + let controlOptions = s.cameraControlOptionsFromUrl(stopURL,monitorConfig) + let requestOptions = { url : stopURL, - method : options.method, + method : controlOptions.method, auth : { - user : options.username, - pass : options.password + user : controlOptions.username, + pass : controlOptions.password } } if(monitorConfig.details.control_digest_auth === '1'){ @@ -221,12 +222,14 @@ module.exports = function(s,config,lang,app,io){ if(options.direction === 'stopMove'){ stopCamera() }else{ - var requestOptions = { + let controlURL = controlBaseUrl + monitorConfig.details[`control_url_${options.direction}`] + let controlOptions = s.cameraControlOptionsFromUrl(controlURL,monitorConfig) + let requestOptions = { url: controlURL, - method: controlURLOptions.method, + method: controlOptions.method, auth: { - user: controlURLOptions.username, - pass: controlURLOptions.password + user: controlOptions.username, + pass: controlOptions.password } } if(monitorConfig.details.control_digest_auth === '1'){ @@ -257,4 +260,4 @@ module.exports = function(s,config,lang,app,io){ startMove: startMove, stopMove: stopMove, } -} +} \ No newline at end of file diff --git a/libs/webServerPaths.js b/libs/webServerPaths.js index 80cb3116..d3543b1a 100644 --- a/libs/webServerPaths.js +++ b/libs/webServerPaths.js @@ -1716,6 +1716,12 @@ module.exports = function(s,config,lang,app,io){ res.setHeader('Content-Type', 'application/json'); s.auth(req.params,function(user){ s.cameraControl(req.params,function(msg){ + let d = { + id: req.params.id, + ke: req.params.ke, + direction: req.params.direction, + details: s.parseJSON(req.query.data) + } s.userLog(d,msg) res.end(s.prettyPrint(msg)) });