1
0
Fork 0

agpsdata - Switch off gps power after updating

master
Martin Boonk 2023-01-12 21:55:56 +01:00
parent 88fef317e5
commit 0da69c3ffa
1 changed files with 9 additions and 8 deletions

View File

@ -10,20 +10,22 @@ readSettings();
function setAGPS(b64) { function setAGPS(b64) {
return new Promise(function(resolve, reject) { return new Promise(function(resolve, reject) {
var initCommands = "Bangle.setGPSPower(1);\n"; // turn GPS on
const gnsstype = settings.gnsstype || 1; // default GPS const gnsstype = settings.gnsstype || 1; // default GPS
initCommands += `Serial1.println("${CASIC_CHECKSUM("$PCAS04," + gnsstype)}")\n`; // set GNSS mode
// What about: // What about:
// NAV-TIMEUTC (0x01 0x10) // NAV-TIMEUTC (0x01 0x10)
// NAV-PV (0x01 0x03) // NAV-PV (0x01 0x03)
// or AGPS.zip uses AID-INI (0x0B 0x01) // or AGPS.zip uses AID-INI (0x0B 0x01)
Bangle.setGPSPower(1,"agpsdata"); // turn GPS on
eval(initCommands); Serial1.println(CASIC_CHECKSUM("$PCAS04," + gnsstype)); // set GNSS mode
try { try {
writeChunks(atob(b64), resolve); writeChunks(atob(b64), ()=>{
Bangle.setGPSPower(0,"agpsdata");
resolve();
});
} catch (e) { } catch (e) {
console.log("error:", e); console.log("error:", e);
Bangle.setGPSPower(0,"agpsdata");
reject(); reject();
} }
}); });
@ -36,9 +38,8 @@ function writeChunks(bin, resolve) {
setTimeout(function() { setTimeout(function() {
if (chunkI < bin.length) { if (chunkI < bin.length) {
var chunk = bin.substr(chunkI, chunkSize); var chunk = bin.substr(chunkI, chunkSize);
js = `Serial1.write(atob("${btoa(chunk)}"))\n`; Serial1.write(atob(btoa(chunk)));
eval(js);
chunkI += chunkSize; chunkI += chunkSize;
writeChunks(bin, resolve); writeChunks(bin, resolve);
} else { } else {