I just have to let the timeout run its duration it seems. If I try to clear the timeout when I get a fix it seems to produce an error every other (e.g. all even times/2times) time it searches.
Serial4.setup(9600,{tx:C10,rx:C11});
var SleepDuration = null;
var SearchDuration = null;
var foundFix = 0;
function Start_GPS(){
console.log("Starting GPS...");
//Reset fix found
foundFix=0;
//After 120 seconds disable the GPS regardless
SearchDuration = setTimeout(function (e) { Stop_GPS(); }, 60000);
//Set enable pin mode
pinMode(A9,'output');
//Set enable pin to high
digitalWrite(A9,1);
//load gps
var gps = require("GPS").connect(Serial4, function(data) {
console.log(data);
//Check if we have a fix
if(data.fix>0)
{
console.log("Send SMS:" + data.lat + "|" + data.lon);
foundFix=1;
Stop_GPS();
}
});
}
function Stop_GPS(){
var gps="";
digitalWrite(A9,0);
console.log("Disabling GPS...");
}
function onInit(){
//SleepDuration = setTimeout(function (e) {onInit(); }, 360000);
console.log("Starting up device & Setting timers...");
setInterval(function (e) { Start_GPS(); }, 360000);
Start_GPS();
}
onInit();
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
I just have to let the timeout run its duration it seems. If I try to clear the timeout when I get a fix it seems to produce an error every other (e.g. all even times/2times) time it searches.