forked from mysensors/MySensorsSampleController
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Reboot.js
28 lines (25 loc) · 1.05 KB
/
Reboot.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
var NodeIdToReboot = 1;
const dbAddress = '127.0.0.1';
const dbPort = 27017;
const dbName = 'MySensorsDb';
var dbc = require('mongodb').MongoClient;
dbc.connect('mongodb://' + dbAddress + ':' + dbPort + '/' + dbName, function(err, db) {
if (err) {
console.log('Error connecting to database at mongodb://' + dbAddress + ':' + dbPort + '/' + dbName);
} else {
db.collection('node', function(err, c) {
c.update({
'id': NodeIdToReboot
}, {
$set: {
'reboot': 1
}
}, function(err, result) {
if (err)
console.log("Error writing reboot request to database");
else
console.log("Reboot request saved to database");
});
});
}
});