forked from homebridge/HAP-NodeJS
-
Notifications
You must be signed in to change notification settings - Fork 1
/
CameraCore.js
39 lines (31 loc) · 1.04 KB
/
CameraCore.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
var storage = require('node-persist');
var uuid = require('./').uuid;
var Accessory = require('./').Accessory;
var Camera = require('./').Camera;
console.log("HAP-NodeJS starting...");
// Initialize our storage system
storage.initSync();
// Start by creating our Bridge which will host all loaded Accessories
var cameraAccessory = new Accessory('Node Camera', uuid.generate("Node Camera"));
var cameraSource = new Camera();
cameraAccessory.configureCameraSource(cameraSource);
cameraAccessory.on('identify', function(paired, callback) {
console.log("Node Camera identify");
callback(); // success
});
// Publish the camera on the local network.
cameraAccessory.publish({
username: "EC:22:3D:D3:CE:CE",
port: 51062,
pincode: "031-45-154",
category: Accessory.Categories.CAMERA
}, true);
var signals = { 'SIGINT': 2, 'SIGTERM': 15 };
Object.keys(signals).forEach(function (signal) {
process.on(signal, function () {
cameraAccessory.unpublish();
setTimeout(function (){
process.exit(128 + signals[signal]);
}, 1000)
});
});