finalizing v1.3.82
This commit is contained in:
1 parent
d2739426e5
commit
d6dc404083
4 files changed
+28
-22
No files matched your search
+18
-13
@@ -7,22 +7,22 @@ function Decoder(bytes, port) {
|
||||
|
||||
if (port === 1) {
|
||||
// only counter data, no gps
|
||||
if (bytes.length == 4) {
|
||||
if (bytes.length === 4) {
|
||||
return decode(bytes, [uint16, uint16], ['wifi', 'ble']);
|
||||
}
|
||||
// combined counter and gps data
|
||||
if (bytes.length > 4) {
|
||||
return decode(bytes, [uint16, uint16, latlng, uint8, uint16, uint16], ['wifi', 'ble', 'coords', 'sats', 'hdop', 'altitude']);
|
||||
if (bytes.length === 17) {
|
||||
return decode(bytes, [uint16, uint16, latLng, latLng, uint8, hdop, uint16], ['wifi', 'ble', 'latitude', 'longitude', 'sats', 'hdop', 'altitude']);
|
||||
}
|
||||
}
|
||||
|
||||
if (port === 2) {
|
||||
// device status data
|
||||
if (bytes.length == 12) {
|
||||
if (bytes.length === 12) {
|
||||
return decode(bytes, [uint16, uptime, temperature], ['voltage', 'uptime', 'cputemp']);
|
||||
}
|
||||
// device config data
|
||||
if (bytes.length == 8) {
|
||||
if (bytes.length === 8) {
|
||||
return decode(bytes, [uint8, uint16, uint8, uint8, uint8, uint8, bitmap], ['lorasf', 'rssilimit', 'sendcycle', 'wifichancycle', 'blescantime', 'rgblum', 'flags']);
|
||||
}
|
||||
}
|
||||
@@ -67,15 +67,19 @@ uint16.BYTES = 2;
|
||||
|
||||
var latLng = function (bytes) {
|
||||
if (bytes.length !== latLng.BYTES) {
|
||||
throw new Error('Lat/Long must have exactly 8 bytes');
|
||||
throw new Error('Lat/Long must have exactly 4 bytes');
|
||||
}
|
||||
|
||||
var lat = bytesToInt(bytes.slice(0, latLng.BYTES / 2));
|
||||
var lng = bytesToInt(bytes.slice(latLng.BYTES / 2, latLng.BYTES));
|
||||
|
||||
return [lat / 1e6, lng / 1e6];
|
||||
return bytesToInt(bytes) / 1e6;
|
||||
};
|
||||
latLng.BYTES = 8;
|
||||
latLng.BYTES = 4;
|
||||
|
||||
var hdop = function (bytes) {
|
||||
if (bytes.length !== hdop.BYTES) {
|
||||
throw new Error('hdop must have exactly 2 bytes');
|
||||
}
|
||||
return bytesToInt(bytes) / 100;
|
||||
};
|
||||
hdop.BYTES = 2;
|
||||
|
||||
var temperature = function (bytes) {
|
||||
if (bytes.length !== temperature.BYTES) {
|
||||
@@ -118,7 +122,7 @@ var bitmap = function (byte) {
|
||||
}
|
||||
var i = bytesToInt(byte);
|
||||
var bm = ('00000000' + Number(i).toString(2)).substr(-8).split('').map(Number).map(Boolean);
|
||||
return ['adr', 'screensaver', 'display', 'countermode', 'blescan', 'antenna', 'filter', 'gpsmode']
|
||||
return ['adr', 'screensaver', 'screen', 'countermode', 'blescan', 'antenna', 'filter', 'gpsmode']
|
||||
.reduce(function (obj, pos, index) {
|
||||
obj[pos] = bm[index];
|
||||
return obj;
|
||||
@@ -156,6 +160,7 @@ if (typeof module === 'object' && typeof module.exports !== 'undefined') {
|
||||
temperature: temperature,
|
||||
humidity: humidity,
|
||||
latLng: latLng,
|
||||
hdop: hdop,
|
||||
bitmap: bitmap,
|
||||
decode: decode
|
||||
};
|
||||
|
||||
+2
-3
@@ -37,9 +37,8 @@
|
||||
#define WIFI_CHANNEL_SWITCH_INTERVAL 50 // [seconds/100] -> 0,5 sec.
|
||||
|
||||
// LoRa payload parameters
|
||||
#define PAYLOAD_ENCODER 2 // select payload encoder: 1=Plain [default], 2=Packed, 3=CayenneLPP
|
||||
//#define SEND_SECS 120 // payload send cycle [seconds/2] -> 240 sec.
|
||||
#define SEND_SECS 30 // payload send cycle [seconds/2] -> 60 sec.
|
||||
#define PAYLOAD_ENCODER 1 // select payload encoder: 1=Plain [default], 2=Packed, 3=CayenneLPP
|
||||
#define SEND_SECS 120 // payload send cycle [seconds/2] -> 240 sec.
|
||||
#define MEM_LOW 2048 // [Bytes] low memory threshold triggering a send cycle
|
||||
#define RETRANSMIT_RCMD 5 // [seconds] wait time before retransmitting rcommand results
|
||||
#define PAYLOAD_BUFFER_SIZE 51 // maximum size of payload block per transmit
|
||||
|
||||
Reference in new issue
Block a user