From d8c3b73334c8fdb471f71b9c4a9091873182f752 Mon Sep 17 00:00:00 2001 From: Gordon Williams Date: Tue, 11 Feb 2020 09:49:12 +0000 Subject: [PATCH] Add GPS code --- testing/GPS-comms.js | 67 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 testing/GPS-comms.js diff --git a/testing/GPS-comms.js b/testing/GPS-comms.js new file mode 100644 index 000000000..67df178f8 --- /dev/null +++ b/testing/GPS-comms.js @@ -0,0 +1,67 @@ +/* This code allows you to communicate with the GPS +receiver in Bangle.js in order to set it up. + +Protocol spec: + +https://cdn.sparkfun.com/assets/0/b/0/f/7/u-blox8-M8_ReceiverDescrProtSpec__UBX-13003221__Public.pdf + +*/ + +Bangle.setGPSPower(1) +//Bangle.on('GPS',print); + +Bangle.on('GPS-raw',function (d) { + if (d[0]=="$") return; + if (d.startsWith("\xB5\x62\x05\x01")) print("GPS ACK"); + else if (d.startsWith("\xB5\x62\x05\x00")) print("GPS NACK"); + // 181,98 sync chars + else print("GPS",E.toUint8Array(d).join(",")); +}); +function writeGPScmd(cmd) { + var d = [0xB5,0x62]; // sync chars + d = d.concat(cmd); + var a=0,b=0; + for (var i=2;i