-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtxtelemetry.js
40 lines (39 loc) · 1.56 KB
/
txtelemetry.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
/**
* TxTelemetry.js 0.0.1
* (c) 2012-2013 Eric Higgins <[email protected]>
* TxTelemetry may be freely distributed under the MIT license.
* Documentation:
* https://github.com/erichiggins/TxTelemetry
**/
// Logs location details every minute.
console.info('Started');
// Get location data.
var locListen = device.location.createListener('GPS', 60 * 1000);
locListen.stop();
locListen.on('changed', function(signal) {
console.info(
'Loc: ' + signal.location.latitude +
', ' + signal.location.longitude + '\n' +
'Alt: ' + signal.location.altitude + '\n' +
'Spd: ' + signal.location.speed + '\n' +
'Dir: ' + signal.location.course);
device.messaging.sendSms({
// Change this before using!!
// Recipient phone number.
to: '000-000-0000',
body: 'Location: ' + signal.location.latitude +
', ' + signal.location.longitude + '\n' +
'Altitude: ' + signal.location.altitude + 'm\n' +
'Speed: ' + signal.location.speed + 'm/s\n' +
'Direction: ' + signal.location.course + 'degrees east of true north\n\n' +
'Vertical Accuracy: ' + (signal.location.verticalAccuracy || '?') + 'm\n' +
'Horizontal Accuracy: ' + (signal.location.horizontalAccuracy || '?') + 'm\n'
},
function(err) {
console.log(err || 'location txt was sent successfully!');
});
//console.log('Stopping GPS listener.');
//locListen.stop();
});
console.info('Starting GPS listener.');
locListen.start();