From b1de323ed5c834363dc920fc514ffdf678cc1cc2 Mon Sep 17 00:00:00 2001 From: Klaus K Wilting Date: Sun, 17 Jun 2018 13:31:24 +0200 Subject: [PATCH] payload encoder fix HAS GPS --- platformio.ini | 4 ++-- src/payload.cpp | 6 ++++++ src/payload.h | 12 +++++++++--- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/platformio.ini b/platformio.ini index 787cf3ae..0caca06f 100644 --- a/platformio.ini +++ b/platformio.ini @@ -15,8 +15,8 @@ ;env_default = ttgov1 ;env_default = ttgov2 ;env_default = ttgov21 -env_default = ttgobeam -;env_default = lopy +;env_default = ttgobeam +env_default = lopy ;env_default = lopy4 ;env_default = fipy ;env_default = lolin32lite diff --git a/src/payload.cpp b/src/payload.cpp index 72c4005e..54e32398 100644 --- a/src/payload.cpp +++ b/src/payload.cpp @@ -24,6 +24,7 @@ void TTNplain::addCount(uint16_t value1, uint16_t value2) { buffer[cursor++] = value2; } +#ifdef HAS_GPS void TTNplain::addGPS(gpsStatus_t value) { buffer[cursor++] = value.latitude >> 24; buffer[cursor++] = value.latitude >> 16; @@ -39,6 +40,7 @@ void TTNplain::addGPS(gpsStatus_t value) { buffer[cursor++] = value.altitude >> 8; buffer[cursor++] = value.altitude; } +#endif void TTNplain::addConfig(configData_t value) { buffer[cursor++] = value.lorasf; @@ -99,6 +101,7 @@ void TTNserialized::addCount(uint16_t value1, uint16_t value2) { message.writeUint16(value2); } +#ifdef HAS_GPS void TTNserialized::addGPS(gpsStatus_t value) { LoraEncoder message(buffer); message.writeLatLng(value.latitude, value.longitude); @@ -106,6 +109,7 @@ void TTNserialized::addGPS(gpsStatus_t value) { message.writeUint16(value.hdop); message.writeUint16(value.altitude); } +#endif void TTNserialized::addConfig(configData_t value) { LoraEncoder message(buffer); @@ -156,6 +160,7 @@ void CayenneLPP::addCount(uint16_t value1, uint16_t value2) { buffer[cursor++] = value2; } +#ifdef HAS_GPS void CayenneLPP::addGPS(gpsStatus_t value) { int32_t lat = value.latitude / 100; int32_t lon = value.longitude / 100; @@ -172,6 +177,7 @@ void CayenneLPP::addGPS(gpsStatus_t value) { buffer[cursor++] = alt >> 8; buffer[cursor++] = alt; } +#endif void CayenneLPP::addConfig(configData_t value) { buffer[cursor++] = LPP_ADR_CHANNEL; diff --git a/src/payload.h b/src/payload.h index 7e372702..13d3b8e1 100644 --- a/src/payload.h +++ b/src/payload.h @@ -30,9 +30,11 @@ public: uint8_t *getBuffer(void); void addCount(uint16_t value1, uint16_t value2); - void addGPS(gpsStatus_t value); void addConfig(configData_t value); void addStatus(uint16_t voltage, uint64_t uptime, float cputemp); +#ifdef HAS_GPS + void addGPS(gpsStatus_t value); +#endif private: uint8_t *buffer; @@ -50,9 +52,11 @@ public: uint8_t *getBuffer(void); void addCount(uint16_t value1, uint16_t value2); - void addGPS(gpsStatus_t value); void addConfig(configData_t value); void addStatus(uint16_t voltage, uint64_t uptime, float cputemp); +#ifdef HAS_GPS + void addGPS(gpsStatus_t value); +#endif private: uint8_t *buffer; @@ -69,9 +73,11 @@ public: uint8_t *getBuffer(void); void addCount(uint16_t value1, uint16_t value2); - void addGPS(gpsStatus_t value); void addConfig(configData_t value); void addStatus(uint16_t voltage, uint64_t uptime, float cputemp); +#ifdef HAS_GPS + void addGPS(gpsStatus_t value); +#endif private: uint8_t *buffer;