bugfix payload encoding

This commit is contained in:
Klaus K Wilting 2018-07-22 16:44:51 +02:00
parent 46bca9e5f2
commit 62ebb534ba
2 changed files with 7 additions and 6 deletions

View File

@ -40,7 +40,7 @@
#define WIFI_CHANNEL_SWITCH_INTERVAL 50 // [seconds/100] -> 0,5 sec. #define WIFI_CHANNEL_SWITCH_INTERVAL 50 // [seconds/100] -> 0,5 sec.
// LoRa payload default parameters // 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 SEND_SECS 30 // payload send cycle [seconds/2] -> 60 sec.
#define MEM_LOW 2048 // [Bytes] low memory threshold triggering a send cycle #define MEM_LOW 2048 // [Bytes] low memory threshold triggering a send cycle

View File

@ -219,19 +219,20 @@ void PayloadConvert::addConfig(configData_t value) {
void PayloadConvert::addStatus(uint16_t voltage, uint64_t uptime, void PayloadConvert::addStatus(uint16_t voltage, uint64_t uptime,
float celsius) { float celsius) {
uint16_t val = celsius * 10; uint16_t temp = celsius * 10;
uint16_t volt = voltage / 10;
#if (PAYLOAD_ENCODER == 3) #if (PAYLOAD_ENCODER == 3)
buffer[cursor++] = LPP_BATT_CHANNEL; buffer[cursor++] = LPP_BATT_CHANNEL;
#endif #endif
buffer[cursor++] = LPP_ANALOG_INPUT; buffer[cursor++] = LPP_ANALOG_INPUT;
buffer[cursor++] = highByte(voltage); buffer[cursor++] = highByte(volt);
buffer[cursor++] = lowByte(voltage); buffer[cursor++] = lowByte(volt);
#if (PAYLOAD_ENCODER == 3) #if (PAYLOAD_ENCODER == 3)
buffer[cursor++] = LPP_TEMP_CHANNEL; buffer[cursor++] = LPP_TEMP_CHANNEL;
#endif #endif
buffer[cursor++] = LPP_TEMPERATURE; buffer[cursor++] = LPP_TEMPERATURE;
buffer[cursor++] = highByte(val); buffer[cursor++] = highByte(temp);
buffer[cursor++] = lowByte(val); buffer[cursor++] = lowByte(temp);
} }
#ifdef HAS_GPS #ifdef HAS_GPS