"use strict";
var Cylon = require("cylon");
Cylon
.robot()
.connection("tessel", { adaptor: "tessel", port: "A" })
.device("gps", { driver: "gps-a2235h" })
.on("ready", function(bot) {
var satsInRange = 0;
var satsFixed = 0;
console.log("GPS module powered and ready. Waiting for satellites...");
bot.gps.on("error", function(err) {
console.log(err);
});
bot.gps.on("coordinates", function(c) {
console.log("Lat:", c.lat, "\tLon:", c.lon, "\tTimestamp:", c.timestamp);
});
bot.gps.on("altitude", function(alt) {
var a = alt.alt,
t = alt.timestamp;
console.log("Got an altitude of", a, "meters (timestamp: " + t + ")");
});
bot.gps.on("satellite-list-partial", function(data) {
satsInRange = data.satsInView;
console.log(satsInRange, "satellites in range,", satsFixed, "fixed.");
});
bot.gps.on("fix", function(data) {
satsFixed = data.numSat;
console.log(satsInRange, "satellites in range,", satsFixed, "fixed.");
});
});
Cylon.start();