-
Notifications
You must be signed in to change notification settings - Fork 0
/
rfid.js
69 lines (64 loc) · 1.2 KB
/
rfid.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
var SerialPort = require("serialport").SerialPort
var PUBNUB = require("pubnub")
var serialPort = new SerialPort("/dev/cu.SLAB_USBtoUART", {
baudrate: 9600
},false);
var channel = 'eon-map-123456'
var me = {
icon: {
'marker-color': 'blue'
}
};
var them = {
icon: {
'marker-color': 'green'
}
};
var pn = PUBNUB.init({
publish_key: 'demo',
subscribe_key: 'demo'
});
var new_torchys = [
{
latlng: [28.61899,77.198],
marker: me
},
{
latlng: [28.6177,77.2011],
marker: them
},
{
latlng: [28.6172,77.1910],
marker: them
},
{
latlng: [28.617748,77.195100],
marker: them
},
{
latlng: [28.6174,77.19544],
marker: them
},
{
latlng: [28.617467,77.2022],
marker: them
}
];
serialPort.open(function (error) {
if ( error ) {
console.log('failed to open: '+error);
} else {
console.log('open');
serialPort.on('data', function(data) {
console.log('data received: ' + data);
pn.publish({
channel: channel,
message: new_torchys
});
});
// serialPort.write("ls\n", function(err, results) {
// console.log('err ' + err);
// console.log('results ' + results);
// });
}
});