testing GPS (experimental)
This commit is contained in:
parent
e6db7ad314
commit
fadb38ef84
10
README.md
10
README.md
@ -119,8 +119,7 @@ Decoder:
|
|||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
function Decoder(bytes, port) {
|
function Decoder(bytes, port) {
|
||||||
// Decode an uplink message from a buffer
|
// decode counter messages
|
||||||
// (array) of bytes to an object of fields.
|
|
||||||
var decoded = {};
|
var decoded = {};
|
||||||
|
|
||||||
if (port === 1) {
|
if (port === 1) {
|
||||||
@ -128,7 +127,8 @@ function Decoder(bytes, port) {
|
|||||||
decoded.ble = (bytes[2] << 8) | bytes[3];
|
decoded.ble = (bytes[2] << 8) | bytes[3];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (port === 2) {
|
// decode GPS messages
|
||||||
|
if (port === 3) {
|
||||||
decoded.latitude = (bytes[3] << 24) | (bytes[2] << 16) | (bytes[1] << 8) | bytes[0];
|
decoded.latitude = (bytes[3] << 24) | (bytes[2] << 16) | (bytes[1] << 8) | bytes[0];
|
||||||
decoded.longitude = (bytes[7] << 24) | (bytes[6] << 16) | (bytes[5] << 8) | bytes[4];
|
decoded.longitude = (bytes[7] << 24) | (bytes[6] << 16) | (bytes[5] << 8) | bytes[4];
|
||||||
decoded.satellites = (bytes[9] << 8) | bytes[8];
|
decoded.satellites = (bytes[9] << 8) | bytes[8];
|
||||||
@ -145,10 +145,12 @@ Converter:
|
|||||||
```javascript
|
```javascript
|
||||||
function Converter(decoded, port) {
|
function Converter(decoded, port) {
|
||||||
var converted = decoded;
|
var converted = decoded;
|
||||||
|
// sum up ble + wifi counters
|
||||||
if (port === 1) {
|
if (port === 1) {
|
||||||
converted.pax = converted.ble + converted.wifi;
|
converted.pax = converted.ble + converted.wifi;
|
||||||
}
|
}
|
||||||
if (port === 2) {
|
// convert some GPS values
|
||||||
|
if (port === 3) {
|
||||||
converted.latitude = converted.latitude / 100000;
|
converted.latitude = converted.latitude / 100000;
|
||||||
converted.longitude = converted.longitude / 100000;
|
converted.longitude = converted.longitude / 100000;
|
||||||
converted.hdop = converted.hdop / 100;
|
converted.hdop = converted.hdop / 100;
|
||||||
|
Loading…
Reference in New Issue
Block a user