-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathskyspy.js
46 lines (38 loc) · 1.35 KB
/
skyspy.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
var sbs1 = require('sbs1');
var Tabletop = require('tabletop');
var public_spreadsheet_url = 'https://docs.google.com/spreadsheets/d/1O4UfWT17szjydo5TQrqNYcEDRwm1H-tjv-sriv01Z68/pubhtml';
function init() {
Tabletop.init( {
key: public_spreadsheet_url,
callback: showInfo,
simpleSheet: true } )
}
function showInfo(data, tabletop) {
hex_ids = [];
for (var i=0; i < data.length; ++i) {
hex_ids.push(data[i]["mode_s_code_hex"]);
};
var client = sbs1.createClient();
client.on('message', function(msg) {
if (msg.message_type === sbs1.MessageType.TRANSMISSION && msg.transmission_type === sbs1.TransmissionType.ES_AIRBORNE_POS) {
/*
console.log('transmission_type: ' + msg.transmission_type);
console.log('session id: ' + msg.session_id);
console.log('aircraft id: ' + msg.aircraft_id);
console.log('hex_ident: ' + msg.hex_ident);
console.log('latitude: ' + msg.lat);
console.log('longitude: ' + msg.lon);
console.log('flight: ' + msg.callsign);
console.log('squawk: ' + msg.squawk);
console.log('altitude: ' + msg.altitude);
*/
var hex_id = msg.hex_ident;
for (var i=0; i < hex_ids.length; ++i) {
if (hex_ids[i] == hex_id) {
console.log("BOGEY DETECTED");
};
}
}
});
}
init();