Skip to content

Commit

Permalink
Fix foscam manual photo taking
Browse files Browse the repository at this point in the history
  • Loading branch information
imbrianj committed Feb 27, 2018
1 parent ebce1b2 commit 42fa7a7
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 17 deletions.
2 changes: 1 addition & 1 deletion cache/version.txt
@@ -1 +1 @@
1519085681168
1519716744562
30 changes: 17 additions & 13 deletions devices/foscam/controller.js
Expand Up @@ -29,7 +29,7 @@ module.exports = (function () {
* @fileoverview Basic control of Foscam IP camera.
*/
return {
version : 20180219,
version : 20180226,

inputs : ['command', 'list'],

Expand Down Expand Up @@ -115,19 +115,19 @@ module.exports = (function () {
dataReply = '',
path = '/images/foscam/photos/';

request = http.request(imageUrl).on('response', function (response) {
response.setEncoding('binary');
request = http.request(imageUrl).on('response', function (response) {
response.setEncoding('binary');

response.on('data', function (response) {
dataReply += response;
});
response.on('data', function (response) {
dataReply += response;
});

response.once('end', function () {
console.log('\x1b[35m' + title + '\x1b[0m: Read raw image');
response.once('end', function () {
console.log('\x1b[35m' + title + '\x1b[0m: Read raw image');

foscam.callback(null, { rawImage : dataReply, fileName : path + fileName }, true);
});
});
foscam.callback(null, { rawImage : dataReply, fileName : path + fileName }, true);
});
});

request.end();
},
Expand Down Expand Up @@ -193,7 +193,7 @@ module.exports = (function () {
photos = [],
filename;

fs.readdir(path, function(err, items) {
fs.readdir((__dirname + '/../..' + path), function(err, items) {
var foscamData = deviceState.getDeviceState(foscam.deviceId) || { value : null },
i = 0;

Expand Down Expand Up @@ -295,8 +295,10 @@ module.exports = (function () {
foscam.list = config.list || '';
foscam.devicePort = config.device.devicePort || 80;
foscam.callback = callback;
foscam.issuer = config.issuer || 'localhost';

if (foscam.list) {
this.getStoredPhotos(foscam);
this.getStoredVideos(foscam);
}

Expand All @@ -313,12 +315,14 @@ module.exports = (function () {
}

else {
that.getStoredPhotos(foscam);

console.log('\x1b[35m' + title + '\x1b[0m: Image saved as ' + fileName);
}
});
}

callback(err, dataReply);
callback(err, dataReply, !dataReply.photos);
};

that.getRawPhoto(foscam, fileName);
Expand Down
2 changes: 1 addition & 1 deletion js/combo.min.js

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion lib/staticAssets.js
Expand Up @@ -251,7 +251,8 @@ module.exports = (function () {
generate.once('close', function (code) {
if (code === 0) {
console.log('\x1b[31m=====================================================================\x1b[0m');
console.log('\x1b[31mWARNING\x1b[0m: SSL keys generated. You will need to restart to make use of SSL.');
console.log('\x1b[31mWARNING\x1b[0m: SSL keys generated. You will need to restart to make use of');
console.log('\x1b[31mSSL.');
console.log('\x1b[31m=====================================================================\x1b[0m');
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -23,7 +23,7 @@
"xml2js": "~0.4.19"
},
"devDependencies": {
"grunt": "~1.0.1",
"grunt": "~1.0.2",
"grunt-cli": "~1.2.0",
"grunt-contrib-concat": "~1.0.1",
"grunt-contrib-cssmin": "~2.2.1",
Expand Down

0 comments on commit 42fa7a7

Please sign in to comment.