-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgps_app.js
31 lines (29 loc) · 1.03 KB
/
gps_app.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
28
29
30
31
module.exports = function(RED) {
function GPSNode(config) {
var gps_api = require('./gps_api.js');
var gps_data = require('./gps_data.js');
RED.nodes.createNode(this,config);
// config before being triggered by input
gps_api.get_gps_config(function(data) {
if (data === 'Config does not exist') {
console.log("No config.");
}
if(data === null) {
console.log("Config read failed");
}
gps_api.configure_gps(function(configdata) {
console.log('config callback data: ' + configdata);
});
});
var node = this;
node.on('input', function(msg) {
gps_data.get_gps_data(function(gpsdata) {
console.log("=======================GPS Data:");
console.log(gpsdata);
msg.payload = JSON.stringify(gpsdata);
node.send(msg);
});
});
}
RED.nodes.registerType("GPS IOx connector",GPSNode);
}