From 62ebb534bad69a4944ce2fd739c18162271ac78a Mon Sep 17 00:00:00 2001 From: Klaus K Wilting Date: Sun, 22 Jul 2018 16:44:51 +0200 Subject: [PATCH] bugfix payload encoding --- src/paxcounter.conf | 2 +- src/payload.cpp | 11 ++++++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/paxcounter.conf b/src/paxcounter.conf index 0315b773..7481c001 100644 --- a/src/paxcounter.conf +++ b/src/paxcounter.conf @@ -40,7 +40,7 @@ #define WIFI_CHANNEL_SWITCH_INTERVAL 50 // [seconds/100] -> 0,5 sec. // LoRa payload default parameters -#define PAYLOAD_ENCODER 3 // select payload encoder: 1=Plain [default], 2=Packed, 3=CayenneLPP dynmic, 4=CayenneLPP packed +#define PAYLOAD_ENCODER 1 // select payload encoder: 1=Plain [default], 2=Packed, 3=CayenneLPP dynmic, 4=CayenneLPP packed #define SEND_SECS 30 // payload send cycle [seconds/2] -> 60 sec. #define MEM_LOW 2048 // [Bytes] low memory threshold triggering a send cycle diff --git a/src/payload.cpp b/src/payload.cpp index 433028bc..bc0da00b 100644 --- a/src/payload.cpp +++ b/src/payload.cpp @@ -219,19 +219,20 @@ void PayloadConvert::addConfig(configData_t value) { void PayloadConvert::addStatus(uint16_t voltage, uint64_t uptime, float celsius) { - uint16_t val = celsius * 10; + uint16_t temp = celsius * 10; + uint16_t volt = voltage / 10; #if (PAYLOAD_ENCODER == 3) buffer[cursor++] = LPP_BATT_CHANNEL; #endif buffer[cursor++] = LPP_ANALOG_INPUT; - buffer[cursor++] = highByte(voltage); - buffer[cursor++] = lowByte(voltage); + buffer[cursor++] = highByte(volt); + buffer[cursor++] = lowByte(volt); #if (PAYLOAD_ENCODER == 3) buffer[cursor++] = LPP_TEMP_CHANNEL; #endif buffer[cursor++] = LPP_TEMPERATURE; - buffer[cursor++] = highByte(val); - buffer[cursor++] = lowByte(val); + buffer[cursor++] = highByte(temp); + buffer[cursor++] = lowByte(temp); } #ifdef HAS_GPS