payload encoder and readme.md updated
This commit is contained in:
parent
b75337c679
commit
48d1c3d3e2
44
README.md
44
README.md
@ -121,26 +121,46 @@ If you're using [TheThingsNetwork](https://www.thethingsnetwork.org/) (TTN) you
|
||||
|
||||
To track a paxcounter device with on board GPS and at the same time contribute to TTN coverage mapping, you simply activate the [TTNmapper integration](https://www.thethingsnetwork.org/docs/applications/ttnmapper/) in TTN Console. The formats *plain* and *packed* generate the fields `latitude`, `longitude` and `hdop` required by ttnmapper.
|
||||
|
||||
Hereafter described is the default *plain* format.
|
||||
Hereafter described is the default *plain* format, which uses MSB bit numbering.
|
||||
|
||||
**LoRaWAN Port #1:**
|
||||
|
||||
Paxcounter data
|
||||
**Port #1:** Paxcount data
|
||||
|
||||
byte 1-2: Number of unique pax, first seen on Wifi
|
||||
byte 3-4: Number of unique pax, first seen on Bluetooth [0 if BT disabled]
|
||||
bytes 5-18: GPS data (only, if GPS is present and has a fix) format see Port #4
|
||||
|
||||
GPS data (only, if GPS is present and has a fix)
|
||||
**Port #2:** Device status query result
|
||||
|
||||
bytes 5-8: GPS latitude
|
||||
bytes 9-12: GPS longitude
|
||||
bytes 13-14: GPS number of satellites
|
||||
bytes 15-16: GPS HDOP
|
||||
bytes 17-18: GPS altitude [meter]
|
||||
byte 1-2: Voltage [mV]
|
||||
byte 3-11: Uptime [seconds]
|
||||
bytes 12-16: CPU temperate [°C]
|
||||
|
||||
**LoRaWAN Port #2:**
|
||||
**Port #3:** Device configuration query result
|
||||
|
||||
byte 1: LoRa spread factor
|
||||
byte 2: ADR mode on/off
|
||||
byte 3: Screensaver on/off
|
||||
byte 4: Display on/off
|
||||
byte 5: Counter mode
|
||||
bytes 6-7: RSSI limit
|
||||
byte 8: Payload send cycle
|
||||
byte 9: Wifi channel switch cycle
|
||||
byte 10: Bluetooth scan duration
|
||||
byte 11: Bluetooth scanning on/off
|
||||
byte 12: Wifi antenna internal/external
|
||||
byte 13: Vendortfilter on/off
|
||||
byte 14: RGB Led luminosity [%]
|
||||
byte 15: GPS data on/off
|
||||
bytes 16-26: Software version in ASCII
|
||||
|
||||
**Port #4:** GPS query result
|
||||
|
||||
bytes 1-4: GPS latitude
|
||||
bytes 5-8: GPS longitude
|
||||
bytes 9-10: GPS number of satellites
|
||||
bytes 11-12: GPS HDOP
|
||||
bytes 13-14: GPS altitude [meter]
|
||||
|
||||
- see remote control -
|
||||
|
||||
[**plain_decoder.js**](src/TTN/plain_decoder.js)
|
||||
|
||||
|
@ -9,12 +9,11 @@ function Converter(decoded, port) {
|
||||
converted.pax = converted.ble + converted.wifi;
|
||||
}
|
||||
|
||||
/*
|
||||
if (port === 2) {
|
||||
converted.voltage /= 1000;
|
||||
converted.uptime /= 60;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
return converted;
|
||||
}
|
@ -18,15 +18,19 @@ function Decoder(bytes, port) {
|
||||
|
||||
if (port === 2) {
|
||||
// device status data
|
||||
if (bytes.length === 12) {
|
||||
return decode(bytes, [uint16, uptime, temperature], ['voltage', 'uptime', 'cputemp']);
|
||||
}
|
||||
// device config data
|
||||
if (bytes.length === 8) {
|
||||
return decode(bytes, [uint8, uint16, uint8, uint8, uint8, uint8, bitmap], ['lorasf', 'rssilimit', 'sendcycle', 'wifichancycle', 'blescantime', 'rgblum', 'flags']);
|
||||
}
|
||||
return decode(bytes, [uint16, uptime, temperature], ['voltage', 'uptime', 'cputemp']);
|
||||
}
|
||||
|
||||
|
||||
if (port === 3) {
|
||||
// device config data
|
||||
return decode(bytes, [uint8, uint16, uint8, uint8, uint8, uint8, bitmap], ['lorasf', 'rssilimit', 'sendcycle', 'wifichancycle', 'blescantime', 'rgblum', 'flags']);
|
||||
}
|
||||
|
||||
if (port === 4) {
|
||||
// gps data
|
||||
return decode(bytes, [latLng, latLng, uint8, hdop, uint16], ['latitude', 'longitude', 'sats', 'hdop', 'altitude']);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -41,14 +41,15 @@
|
||||
#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
|
||||
|
||||
// Default LoRa Spreadfactor
|
||||
#define LORASFDEFAULT 9 // 7 ... 12 SF, according to LoRaWAN specs
|
||||
#define MAXLORARETRY 500 // maximum count of TX retries if LoRa busy
|
||||
#define PAYLOADPORT 1 // LoRaWAN Port on which device sends counts
|
||||
#define RCMDPORT 2 // LoRaWAN Port on which device listenes for remote commands
|
||||
#define STATUSPORT 2 // LoRaWAN Port on which device sends remote command results
|
||||
#define GPSPORT 3 // LoRaWAN Port on which device sends gps query results
|
||||
|
||||
// Ports on which the device sends and listenes on LoRaWAN and SPI
|
||||
#define PAYLOADPORT 1 // Port on which device sends counts
|
||||
#define RCMDPORT 2 // Port on which device listenes for remote commands
|
||||
#define STATUSPORT 2 // Port on which device sends remote command results
|
||||
#define CONFIGPORT 3 // Port on which device sends gps query results
|
||||
#define GPSPORT 4 // Port on which device sends gps query results
|
||||
|
||||
// Default RGB LED luminosity (in %)
|
||||
#define RGBLUMINOSITY 30 // 30%
|
||||
|
@ -273,7 +273,7 @@ void get_config(uint8_t val) {
|
||||
ESP_LOGI(TAG, "Remote command: get device configuration");
|
||||
payload.reset();
|
||||
payload.addConfig(cfg);
|
||||
senddata(STATUSPORT);
|
||||
senddata(CONFIGPORT);
|
||||
};
|
||||
|
||||
void get_status(uint8_t val) {
|
||||
|
Loading…
Reference in New Issue
Block a user