Permalink
Browse files

Use ESLint as linter.

  • Loading branch information...
Bofu Chen (bafu)
Bofu Chen (bafu) committed May 8, 2017
1 parent a27df39 commit d2468c3b1528ce40dacf1c85840a71542a2bbfb2
Showing with 48 additions and 37 deletions.
  1. +8 −0 .eslintrc.yaml
  2. +3 −3 broker.js
  3. +15 −14 camera.js
  4. +6 −6 config.js
  5. +6 −6 journal.js
  6. +6 −8 localimg.js
  7. +4 −0 package.json
@@ -0,0 +1,8 @@
env:
node: true
es6: true
extends: google
rules:
comma-dangle: [2, only-multiline]
@@ -1,17 +1,17 @@
// Copyright 2017 DT42
//
// This file is part of BerryNet.
//
//
// BerryNet is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
//
// BerryNet is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
//
// You should have received a copy of the GNU General Public License
// along with BerryNet. If not, see <http://www.gnu.org/licenses/>.
@@ -1,17 +1,17 @@
// Copyright 2017 DT42
//
//
// This file is part of BerryNet.
//
//
// BerryNet is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
//
// BerryNet is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
//
// You should have received a copy of the GNU General Public License
// along with BerryNet. If not, see <http://www.gnu.org/licenses/>.
@@ -28,11 +28,12 @@ const client = mqtt.connect(broker);
const topicActionLog = config.topicActionLog;
const topicActionInference = config.topicActionInference;
const topicEventCamera = config.topicEventCamera;
const topicNotifyEmail = config.topicNotifyEmail;
const camera_uri = config.ipcameraSnapshot;
const snapshot_file = '/tmp/snapshot.jpg';
const camera_cmd = '/usr/bin/raspistill';
const camera_args = ['-vf', '-hf', '-w', '1024', '-h', '768', '-o', snapshot_file];
const cameraURI = config.ipcameraSnapshot;
const snapshotFile = '/tmp/snapshot.jpg';
const cameraCmd = '/usr/bin/raspistill';
const cameraArgs = ['-vf', '-hf',
'-w', '1024', '-h', '768',
'-o', snapshotFile];
function log(m) {
client.publish(topicActionLog, m);
@@ -51,8 +52,8 @@ client.on('message', (t, m) => {
if (action == 'snapshot_picam') {
// Take a snapshot from RPi3 camera. The snapshot will be displayed
// on dashboard.
spawnsync(camera_cmd, camera_args);
fs.readFile(snapshot_file, function(err, data) {
spawnsync(cameraCmd, cameraArgs);
fs.readFile(snapshotFile, function(err, data) {
if (err) {
log('camera client: cannot get image.');
} else {
@@ -64,13 +65,13 @@ client.on('message', (t, m) => {
// Take a snapshot from IP camera. The snapshot will be sent to
// configured email address.
request.get(
{uri: camera_uri, encoding: null},
{uri: cameraURI, encoding: null},
(e, res, body) => {
if (!e && res.statusCode == 200) {
log('camera client: publishing image.')
log('camera client: publishing image.');
client.publish(topicActionInference, body);
} else {
log('camera client: cannot get image.')
log('camera client: cannot get image.');
}
}
);
@@ -1,33 +1,33 @@
// Copyright 2017 DT42
//
//
// This file is part of BerryNet.
//
//
// BerryNet is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
//
// BerryNet is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
//
// You should have received a copy of the GNU General Public License
// along with BerryNet. If not, see <http://www.gnu.org/licenses/>.
'use strict';
const path = require('path');
var config = {};
let config = {};
// system configs
config.projectDir = __dirname;
config.inferenceEngine = 'detector'; // {classifier, detector}
// gateway configs
function padTopicBase(topic) {
return path.join(config.topicBase, topic)
return path.join(config.topicBase, topic);
}
config.snapshot = path.join(
@@ -1,17 +1,17 @@
// Copyright 2017 DT42
//
//
// This file is part of BerryNet.
//
//
// BerryNet is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
//
// BerryNet is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
//
// You should have received a copy of the GNU General Public License
// along with BerryNet. If not, see <http://www.gnu.org/licenses/>.
@@ -27,7 +27,7 @@ const client = mqtt.connect(broker);
const topicActionLog = config.topicActionLog;
const topicNotifyEmail = config.topicNotifyEmail;
const topicDashboardLog = config.topicDashboardLog;
const dashboard_pic_topic = config.topicDashboardSnapshot;
const topicDashboardSnapshot = config.topicDashboardSnapshot;
const snapshot = config.snapshot;
let logs = [];
@@ -57,7 +57,7 @@ client.on('message', (t, m) => {
if (t == topicNotifyEmail) {
const filename = 'snapshot.jpg';
saveBufferToImage(m, snapshot);
client.publish(dashboard_pic_topic, filename);
client.publish(topicDashboardSnapshot, filename);
return;
}
@@ -1,17 +1,17 @@
// Copyright 2017 DT42
//
//
// This file is part of BerryNet.
//
//
// BerryNet is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
//
// BerryNet is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
//
// You should have received a copy of the GNU General Public License
// along with BerryNet. If not, see <http://www.gnu.org/licenses/>.
@@ -28,10 +28,8 @@
'use strict';
const mqtt = require('mqtt')
const request = require('request')
const spawnsync = require('child_process').spawnSync
const fs = require('fs')
const mqtt = require('mqtt');
const fs = require('fs');
const config = require('./config');
const broker = config.brokerHost;
@@ -15,5 +15,9 @@
"pino": "^2.13.0",
"prompt": "^1.0.0",
"request": "^2.79.0"
},
"devDependencies": {
"eslint": "^3.19.0",
"eslint-config-google": "^0.7.1"
}
}

0 comments on commit d2468c3

Please sign in to comment.