From b47c58436f194d1420232a382b640dce16488cba Mon Sep 17 00:00:00 2001 From: Klaus K Wilting Date: Sun, 17 Jun 2018 01:15:02 +0200 Subject: [PATCH] new payload encoder (experimental) --- src/globals.h | 12 ++++-------- src/main.cpp | 11 +++-------- src/paxcounter.conf | 1 - src/payload.cpp | 6 +----- src/payload.h | 31 ++++++++++++++----------------- 5 files changed, 22 insertions(+), 39 deletions(-) diff --git a/src/globals.h b/src/globals.h index be2a175e..a0473663 100644 --- a/src/globals.h +++ b/src/globals.h @@ -45,17 +45,13 @@ extern gpsStatus_t gps_status; // struct for storing gps data extern TinyGPSPlus gps; // Make TinyGPS++ instance globally availabe #endif -/* // payload encoder -#if (PAYLOAD_ENCODER == 1) +#if PAYLOAD_ENCODER == 1 extern TTNplain payload; -#elif (PAYLOAD_ENCODER == 2) +#elif PAYLOAD_ENCODER == 2 extern TTNserialized payload; -#elif (PAYLOAD_ENCODER == 3) +#elif PAYLOAD_ENCODER == 3 extern CayenneLPP payload; #else #error "No valid payload converter defined" -#endif -*/ - -extern TTNplain payload; \ No newline at end of file +#endif \ No newline at end of file diff --git a/src/main.cpp b/src/main.cpp index 277a40ef..ac5588fa 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -70,21 +70,16 @@ portMUX_TYPE timerMux = std::set macs; // associative container holds total of unique MAC // adress hashes (Wifi + BLE) -/* // initialize payload encoder -#if (PAYLOAD_ENCODER == 1) +#if PAYLOAD_ENCODER == 1 TTNplain payload(PAYLOAD_BUFFER_SIZE); -#elif (PAYLOAD_ENCODER == 2) +#elif PAYLOAD_ENCODER == 2 TTNserialized payload(PAYLOAD_BUFFER_SIZE); -#elif (PAYLOAD_ENCODER == 3) +#elif PAYLOAD_ENCODER == 3 CayenneLPP payload(PAYLOAD_BUFFER_SIZE); #else #error "No valid payload converter defined" #endif -*/ - -TTNplain payload(PAYLOAD_BUFFER_SIZE); - // this variables will be changed in the ISR, and read in main loop static volatile int ButtonPressedIRQ = 0, DisplayTimerIRQ = 0, diff --git a/src/paxcounter.conf b/src/paxcounter.conf index 9a122198..c15f8db4 100644 --- a/src/paxcounter.conf +++ b/src/paxcounter.conf @@ -43,7 +43,6 @@ #define RETRANSMIT_RCMD 5 // [seconds] wait time before retransmitting rcommand results #define PAYLOAD_ENCODER 1 // select payload encoder: 1 = Plain [default], 2 = Lora-serialized, 3 = CayenneLPP #define PAYLOAD_BUFFER_SIZE 51 // maximum size of payload block per transmit -//#define CAYENNE_LPP 1 // uncomment this, if you need Cayenne LPP payload encoding // Default LoRa Spreadfactor #define LORASFDEFAULT 9 // 7 ... 12 SF, according to LoRaWAN specs diff --git a/src/payload.cpp b/src/payload.cpp index 608bc3db..60fb217f 100644 --- a/src/payload.cpp +++ b/src/payload.cpp @@ -130,8 +130,6 @@ void TTNserialized::addStatus(uint16_t voltage, uint64_t uptime, /* ---------------- Cayenne LPP format ---------- */ -#ifdef CAYENNE_LPP - CayenneLPP::CayenneLPP(uint8_t size) { buffer = (uint8_t *)malloc(size); cursor = 0; @@ -190,6 +188,4 @@ void CayenneLPP::addStatus(uint16_t voltage, uint64_t uptime, float cputemp) { buffer[cursor++] = LPP_TEMPERATURE; buffer[cursor++] = (uint16_t) cputemp >> 8; buffer[cursor++] = (uint16_t) cputemp; -} - -#endif // CAYENNE_LPP \ No newline at end of file +} \ No newline at end of file diff --git a/src/payload.h b/src/payload.h index ae30baf5..41865006 100644 --- a/src/payload.h +++ b/src/payload.h @@ -5,6 +5,20 @@ #include #include "LoraEncoder.h" +// MyDevices CayenneLPP channels +#define LPP_GPS_CHANNEL 20 +#define LPP_COUNT_WIFI_CHANNEL 21 +#define LPP_COUNT_BLE_CHANNEL 22 +#define LPP_BATT_CHANNEL 23 +#define LPP_ADR_CHANNEL 25 +#define LPP_TEMP_CHANNEL 26 +// MyDevices CayenneLPP types +#define LPP_GPS 136 // 3 byte lon/lat 0.0001 °, 3 bytes alt 0.01m +#define LPP_TEMPERATURE 103 // 2 bytes, 0.1°C signed +#define LPP_DIGITAL_INPUT 0 // 1 byte +#define LPP_DIGITAL_OUTPUT 1 // 1 byte +#define LPP_ANALOG_INPUT 2 // 2 bytes, 0.01 signed + class TTNplain { public: TTNplain(uint8_t size); @@ -44,21 +58,6 @@ private: LoraEncoder message(byte *buffer); }; -#ifdef CAYENNE_LPP -// LPP channels -#define LPP_GPS_CHANNEL 20 -#define LPP_COUNT_WIFI_CHANNEL 21 -#define LPP_COUNT_BLE_CHANNEL 22 -#define LPP_BATT_CHANNEL 23 -#define LPP_ADR_CHANNEL 25 -#define LPP_TEMP_CHANNEL 26 -// LPP types -#define LPP_GPS 136 // 3 byte lon/lat 0.0001 °, 3 bytes alt 0.01m -#define LPP_TEMPERATURE 103 // 2 bytes, 0.1°C signed -#define LPP_DIGITAL_INPUT 0 // 1 byte -#define LPP_DIGITAL_OUTPUT 1 // 1 byte -#define LPP_ANALOG_INPUT 2 // 2 bytes, 0.01 signed - class CayenneLPP { public: CayenneLPP(uint8_t size); @@ -79,6 +78,4 @@ private: uint8_t cursor; }; -#endif // CAYENNE_LPP - #endif // _PAYLOAD_H_