payload encoder and readme.md updated

This commit is contained in:
Klaus K Wilting committed 2018-07-15 19:08:18 +02:00
1 parent b75337c679
commit 48d1c3d3e2
5 files changed
+54 -30

No files matched your search

+1 -2
View File
@@ -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;
}
+11 -7
View File
@@ -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']);
}
}
+7 -6
View File
@@ -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%
+1 -1
View File
@@ -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) {