assistedgps 0.02: Update to work with Bangle.js 2
parent
a650e5b4f2
commit
0b742e4ff1
|
|
@ -1536,13 +1536,14 @@
|
||||||
{
|
{
|
||||||
"id": "assistedgps",
|
"id": "assistedgps",
|
||||||
"name": "Assisted GPS Update (AGPS)",
|
"name": "Assisted GPS Update (AGPS)",
|
||||||
"version": "0.01",
|
"version": "0.02",
|
||||||
"description": "Downloads assisted GPS (AGPS) data to Bangle.js 1 for faster GPS startup and more accurate fixes. **No app will be installed**, this just uploads new data to the GPS chip.",
|
"description": "Downloads assisted GPS (AGPS) data to Bangle.js 1 or 2 for faster GPS startup and more accurate fixes. **No app will be installed**, this just uploads new data to the GPS chip.",
|
||||||
"icon": "app.png",
|
"icon": "app.png",
|
||||||
"type": "RAM",
|
"type": "RAM",
|
||||||
"tags": "tool,outdoors,agps",
|
"tags": "tool,outdoors,agps",
|
||||||
"supports": ["BANGLEJS"],
|
"supports": ["BANGLEJS","BANGLEJS2"],
|
||||||
"custom": "custom.html",
|
"custom": "custom.html",
|
||||||
|
"customConnect": true,
|
||||||
"storage": []
|
"storage": []
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1 +1,2 @@
|
||||||
0.01: New App!
|
0.01: New App!
|
||||||
|
0.02: Update to work with Bangle.js 2
|
||||||
|
|
|
||||||
|
|
@ -8,34 +8,47 @@
|
||||||
<p>GPS can take a long time (~5 minutes) to get an accurate position the first time it is used.
|
<p>GPS can take a long time (~5 minutes) to get an accurate position the first time it is used.
|
||||||
AGPS uploads a few hints to the GPS receiver about satellite positions that allow it
|
AGPS uploads a few hints to the GPS receiver about satellite positions that allow it
|
||||||
to get a faster, more accurate fix - however they are only valid for a short period of time.</p>
|
to get a faster, more accurate fix - however they are only valid for a short period of time.</p>
|
||||||
<p>You can upload data that covers a longer period of time, but the upload will take longer.</p>
|
<div id="banglejs1-info" style="display:none">
|
||||||
<div class="form-group">
|
<p>You can upload data that covers a longer period of time, but the upload will take longer.</p>
|
||||||
<label class="form-label">AGPS Validity time</label>
|
<div class="form-group">
|
||||||
<label class="form-radio">
|
<label class="form-label">AGPS Validity time</label>
|
||||||
<input type="radio" name="agpsperiod" value="1d"><i class="form-icon"></i> 1 day (8kB)
|
<label class="form-radio">
|
||||||
</label>
|
<input type="radio" name="agpsperiod" value="1d"><i class="form-icon"></i> 1 day (8kB)
|
||||||
<label class="form-radio">
|
</label>
|
||||||
<input type="radio" name="agpsperiod" value="2d" checked><i class="form-icon"></i> 2 days (14kB)
|
<label class="form-radio">
|
||||||
</label>
|
<input type="radio" name="agpsperiod" value="2d" checked><i class="form-icon"></i> 2 days (14kB)
|
||||||
<label class="form-radio">
|
</label>
|
||||||
<input type="radio" name="agpsperiod" value="3d"><i class="form-icon"></i> 3 days (20kB)
|
<label class="form-radio">
|
||||||
</label>
|
<input type="radio" name="agpsperiod" value="3d"><i class="form-icon"></i> 3 days (20kB)
|
||||||
<label class="form-radio">
|
</label>
|
||||||
<input type="radio" name="agpsperiod" value="1wk"><i class="form-icon"></i> 1 week (46kB)
|
<label class="form-radio">
|
||||||
</label>
|
<input type="radio" name="agpsperiod" value="1wk"><i class="form-icon"></i> 1 week (46kB)
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<p>Click <button id="upload" class="btn btn-primary">Upload</button></p>
|
<div id="banglejs2-info" style="display:none">
|
||||||
|
</div>
|
||||||
|
<p id="upload-wrap" style="display:none">Click <button id="upload" class="btn btn-primary">Upload</button></p>
|
||||||
|
|
||||||
<script src="../../core/lib/customize.js"></script>
|
<script src="../../core/lib/customize.js"></script>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
var isB1; // is Bangle.js 1?
|
||||||
|
var isB2; // is Bangle.js 2?
|
||||||
|
|
||||||
// When the 'upload' button is clicked...
|
// When the 'upload' button is clicked...
|
||||||
document.getElementById("upload").addEventListener("click", function() {
|
document.getElementById("upload").addEventListener("click", function() {
|
||||||
var radios = document.getElementsByName('agpsperiod');
|
var url;
|
||||||
var url = "https://www.espruino.com/agps/assistnow_1d.base64";
|
if (isB1) {
|
||||||
for (var i=0; i<radios.length; i++)
|
var radios = document.getElementsByName('agpsperiod');
|
||||||
if (radios[i].checked)
|
url = "https://www.espruino.com/agps/assistnow_1d.base64";
|
||||||
url = "https://www.espruino.com/agps/assistnow_"+radios[i].value+".base64";
|
for (var i=0; i<radios.length; i++)
|
||||||
|
if (radios[i].checked)
|
||||||
|
url = "https://www.espruino.com/agps/assistnow_"+radios[i].value+".base64";
|
||||||
|
}
|
||||||
|
if (isB2) {
|
||||||
|
url = "https://www.espruino.com/agps/casic.base64";
|
||||||
|
}
|
||||||
console.log("Sending...");
|
console.log("Sending...");
|
||||||
//var text = document.getElementById("agpsperiod").value;
|
//var text = document.getElementById("agpsperiod").value;
|
||||||
get(url, function(b64) {
|
get(url, function(b64) {
|
||||||
|
|
@ -48,6 +61,8 @@
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// =================================================== Bangle.js 1 UBLOX
|
||||||
|
|
||||||
function UBX_CMD(cmd) {
|
function UBX_CMD(cmd) {
|
||||||
var d = [0xB5,0x62]; // sync chars
|
var d = [0xB5,0x62]; // sync chars
|
||||||
d = d.concat(cmd);
|
d = d.concat(cmd);
|
||||||
|
|
@ -79,13 +94,31 @@
|
||||||
return UBX_CMD([].slice.call(a));
|
return UBX_CMD([].slice.call(a));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// =================================================== Bangle.js 2 CASIC
|
||||||
|
|
||||||
|
function CASIC_CHECKSUM(cmd) {
|
||||||
|
var cs = 0;
|
||||||
|
for (var i=1;i<cmd.length;i++)
|
||||||
|
cs = cs ^ cmd.charCodeAt(i);
|
||||||
|
return cmd+"*"+cs.toString(16).toUpperCase().padStart(2, '0');
|
||||||
|
}
|
||||||
|
|
||||||
|
// ===================================================
|
||||||
|
|
||||||
function jsFromBase64(b64) {
|
function jsFromBase64(b64) {
|
||||||
var bin = atob(b64);
|
var bin = atob(b64);
|
||||||
var chunkSize = 128;
|
var chunkSize = 128;
|
||||||
var js = "\x10Bangle.setGPSPower(1);\n"; // turn GPS on
|
var js = "\x10Bangle.setGPSPower(1);\n"; // turn GPS on
|
||||||
//js += `\x10Bangle.on('GPS-raw',function (d) { if (d.startsWith("\\xB5\\x62\\x05\\x01")) Terminal.println("GPS ACK"); else if (d.startsWith("\\xB5\\x62\\x05\\x00")) Terminal.println("GPS NACK"); })\n`;
|
if (isB1) { // UBLOX
|
||||||
//js += "\x10var t=getTime()+1;while(t>getTime());\n"; // wait 1 sec
|
//js += `\x10Bangle.on('GPS-raw',function (d) { if (d.startsWith("\\xB5\\x62\\x05\\x01")) Terminal.println("GPS ACK"); else if (d.startsWith("\\xB5\\x62\\x05\\x00")) Terminal.println("GPS NACK"); })\n`;
|
||||||
js += `\x10Serial1.write(atob("${btoa(String.fromCharCode.apply(null,UBX_MGA_INI_TIME_UTC()))}"))\n`; // set GPS time
|
//js += "\x10var t=getTime()+1;while(t>getTime());\n"; // wait 1 sec
|
||||||
|
js += `\x10Serial1.write(atob("${btoa(String.fromCharCode.apply(null,UBX_MGA_INI_TIME_UTC()))}"))\n`; // set GPS time
|
||||||
|
}
|
||||||
|
if (isB2) { // CASIC
|
||||||
|
|
||||||
|
// Disable BDS, use just GPS (supposedly improve lock time)
|
||||||
|
js += `\x10Serial1.println("${CASIC_CHECKSUM("$PCAS04,1")}")\n`; // set GPS-only mode
|
||||||
|
}
|
||||||
|
|
||||||
for (var i=0;i<bin.length;i+=chunkSize) {
|
for (var i=0;i<bin.length;i+=chunkSize) {
|
||||||
var chunk = bin.substr(i,chunkSize);
|
var chunk = bin.substr(i,chunkSize);
|
||||||
|
|
@ -106,6 +139,15 @@
|
||||||
oReq.send();
|
oReq.send();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Called when we know what device we're using
|
||||||
|
function onInit(device) {
|
||||||
|
isB2 = (device && device.id=="BANGLEJS2");
|
||||||
|
isB1 = !isB2;
|
||||||
|
document.getElementById("banglejs1-info").style = isB1?"":"display:none";
|
||||||
|
document.getElementById("banglejs2-info").style = isB2?"":"display:none";
|
||||||
|
document.getElementById("upload-wrap").style = "";
|
||||||
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue