-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathapp.js
More file actions
50 lines (43 loc) · 1.62 KB
/
Copy pathapp.js
File metadata and controls
50 lines (43 loc) · 1.62 KB
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
40
41
42
43
44
45
46
47
48
49
50
var ChainOf = require("chainof"),
utils = require('./lib/utils'),
chain = new ChainOf();
//------------------------------------------------//
//begin autogenerated by skawtus
//------------------------------------------------//
var default_payload = {
device: {
type: "ee15bcea-c04e-4152-91cf-fd6c90a79538", //skawtus generated device guid
account: "8fb01791-b7e6-4f41-abae-2a0cbf473d79", //skawtus generated account
period: 5000 //skawtus generated polling period in milliseconds
}
};
var out_http = require('./lib/out/skawtus_http'),
out_mqtt = require('./lib/out/skawtus_mqtt'),
out_local_json = require('./lib/out/local_json'),
in_wifi = require('./lib/in/wifi/wifi_sensor'),
in_flow = require('./lib/in/gpio/flow-sensor/YF-S201.js'),
in_temp = require('./lib/in/one-wire/temperature/DS18B20.js'),
in_gps = require('./lib/in/serial/gps/nmea-0183.js');
function buildChain(){
chain.clear();
chain.use(in_wifi.check);
chain.use(in_flow.check);
chain.use(in_temp.check);
chain.use(in_gps.check);
chain.use(out_http.sendGet);
chain.use(out_local_json.write);
chain.use(log);
}
//------------------------------------------------//
//end autogenerated content
//------------------------------------------------//
function log(payload, callback){
console.log( JSON.stringify(payload, null, ' ') );
callback(payload);
}
function checkState(payload){
chain.run(payload);
setTimeout(checkState, payload.device.period, utils.clone(default_payload) );
}
buildChain();
checkState( utils.clone(default_payload) );