finalizing v1.3.82

This commit is contained in:
Klaus K Wilting 2018-06-18 13:13:13 +02:00
parent d2739426e5
commit d6dc404083
4 changed files with 28 additions and 22 deletions

View File

@ -110,13 +110,13 @@ Legend for RGB LED (LoPy/LoPy4/FiPy/Lolin32 only):
You can select between different payload formats in [paxcounter.conf](src/paxcounter.conf#L40):
- *Plain* generates human readable json fields, e.g. useful for TTN console
- ***Plain*** uses big endian format and generates json fields, e.g. useful for TTN console
- *Packed* generates packed json fiels, e.g. useful for own backends
- ***Packed*** uses little endian format and generates json fields
- [*CayenneLPP*](https://mydevices.com/cayenne/docs/lora/#lora-cayenne-low-power-payload-reference-implementation) generates MyDevices Cayenne readable fields
- [***CayenneLPP***](https://mydevices.com/cayenne/docs/lora/#lora-cayenne-low-power-payload-reference-implementation) generates MyDevices Cayenne readable fields
Hereafter described is the *Plain* format. All data is represented in big-endian-format.
Hereafter described is the default *Plain* format.
**LoRaWAN Port #1:**
@ -144,6 +144,8 @@ To map a GPS capable paxcounter device and at the same time contribute to TTN co
**Decoder:**
```javascript
<object data="TTN/packed_decoder.js" type="text/plain" width="200" height="100">
</object>
function Decoder(bytes, port) {
var decoded = {};

View File

@ -11,11 +11,11 @@
; ---> SELECT TARGET PLATFORM HERE! <---
[platformio]
;env_default = heltec
env_default = heltec
;env_default = ttgov1
;env_default = ttgov2
;env_default = ttgov21
env_default = ttgobeam
;env_default = ttgobeam
;env_default = lopy
;env_default = lopy4
;env_default = fipy

View File

@ -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
};

View File

@ -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