-
Notifications
You must be signed in to change notification settings - Fork 5
/
testIpCam.js
65 lines (54 loc) · 1.16 KB
/
testIpCam.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
var ipcam = require('./ipcam');
var sricam_af004 = require('./sricamAF004');
var querystring = require ('querystring');
var requestor = require ('./requestor');
var host = {
ip: '10.0.0.4'
};
var credentials = {
login:"",
pwd: ""
};
ipcam.setup(
{
ip: '10.0.0.4'
},
{
login: "admin",
pwd: ""
}, sricam_af004);
var controller = ipcam.methods;
var protocol='http://';
function get(url,success,error){
console.log("get from url: "+url);
requestor.on('connection-error', function(err){
console.log("error: "+err);
if(error){
error(err);
}
});
requestor.sendRequest('1',url,{
callback: function(data){
console.log("success: "+data);
if(success){
success(data);
}
},
encoding: 'UTF-8'
});
}
function commandFor(start,stop,duration){
console.log("send start url");
get(start,
function(data){
console.log("prepare stop url");
setTimeout(function(){get(stop)}, duration);
},
function(err){
console.log("Error: "+err);
}
)
}
var urlStart = controller.decode('camera.control.ptz.move', 'left',true);
var urlStop = controller.decode('camera.control.ptz.stop', 'left',true);
commandFor(urlStart,urlStop,3000);