Skip to content

Commit

Permalink
Use ESLint as linter.
Browse files Browse the repository at this point in the history
  • Loading branch information
bafu committed May 8, 2017
1 parent a27df39 commit d2468c3
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 37 deletions.
8 changes: 8 additions & 0 deletions .eslintrc.yaml
@@ -0,0 +1,8 @@
env:
node: true
es6: true

extends: google

rules:
comma-dangle: [2, only-multiline]
6 changes: 3 additions & 3 deletions broker.js
@@ -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/>.

Expand Down
29 changes: 15 additions & 14 deletions camera.js
@@ -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/>.

Expand All @@ -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);
Expand All @@ -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 {
Expand All @@ -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.');
}
}
);
Expand Down
12 changes: 6 additions & 6 deletions config.js
@@ -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(
Expand Down
12 changes: 6 additions & 6 deletions journal.js
@@ -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/>.

Expand All @@ -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 = [];
Expand Down Expand Up @@ -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;
}

Expand Down
14 changes: 6 additions & 8 deletions localimg.js
@@ -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/>.

Expand All @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions package.json
Expand Up @@ -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.