From 73f19ac6548a3557461b57f54d372756cd394bcb Mon Sep 17 00:00:00 2001 From: Klaus K Wilting Date: Sun, 22 Jul 2018 17:35:26 +0200 Subject: [PATCH 1/3] payload.cpp fix cayenne battery value --- src/payload.cpp | 61 +++++++++++++++++++++++++------------------------ 1 file changed, 31 insertions(+), 30 deletions(-) diff --git a/src/payload.cpp b/src/payload.cpp index bc0da00b..ab4c587f 100644 --- a/src/payload.cpp +++ b/src/payload.cpp @@ -52,30 +52,30 @@ void PayloadConvert::addStatus(uint16_t voltage, uint64_t uptime, uint32_t temp = (uint32_t)cputemp; buffer[cursor++] = highByte(voltage); buffer[cursor++] = lowByte(voltage); - buffer[cursor++] = (byte) ((uptime & 0xFF00000000000000) >> 56 ); - buffer[cursor++] = (byte) ((uptime & 0x00FF000000000000) >> 48 ); - buffer[cursor++] = (byte) ((uptime & 0x0000FF0000000000) >> 40 ); - buffer[cursor++] = (byte) ((uptime & 0x000000FF00000000) >> 32 ); - buffer[cursor++] = (byte) ((uptime & 0x00000000FF000000) >> 24 ); - buffer[cursor++] = (byte) ((uptime & 0x0000000000FF0000) >> 16 ); - buffer[cursor++] = (byte) ((uptime & 0x000000000000FF00) >> 8 ); - buffer[cursor++] = (byte) ((uptime & 0x00000000000000FF) ); - buffer[cursor++] = (byte) ((temp & 0xFF000000) >> 24 ); - buffer[cursor++] = (byte) ((temp & 0x00FF0000) >> 16 ); - buffer[cursor++] = (byte) ((temp & 0x0000FF00) >> 8 ); - buffer[cursor++] = (byte) ((temp & 0x000000FF) ); + buffer[cursor++] = (byte)((uptime & 0xFF00000000000000) >> 56); + buffer[cursor++] = (byte)((uptime & 0x00FF000000000000) >> 48); + buffer[cursor++] = (byte)((uptime & 0x0000FF0000000000) >> 40); + buffer[cursor++] = (byte)((uptime & 0x000000FF00000000) >> 32); + buffer[cursor++] = (byte)((uptime & 0x00000000FF000000) >> 24); + buffer[cursor++] = (byte)((uptime & 0x0000000000FF0000) >> 16); + buffer[cursor++] = (byte)((uptime & 0x000000000000FF00) >> 8); + buffer[cursor++] = (byte)((uptime & 0x00000000000000FF)); + buffer[cursor++] = (byte)((temp & 0xFF000000) >> 24); + buffer[cursor++] = (byte)((temp & 0x00FF0000) >> 16); + buffer[cursor++] = (byte)((temp & 0x0000FF00) >> 8); + buffer[cursor++] = (byte)((temp & 0x000000FF)); } #ifdef HAS_GPS void PayloadConvert::addGPS(gpsStatus_t value) { - buffer[cursor++] = (byte) ((value.latitude & 0xFF000000) >> 24 ); - buffer[cursor++] = (byte) ((value.latitude & 0x00FF0000) >> 16 ); - buffer[cursor++] = (byte) ((value.latitude & 0x0000FF00) >> 8 ); - buffer[cursor++] = (byte) ((value.latitude & 0x000000FF) ); - buffer[cursor++] = (byte) ((value.longitude & 0xFF000000) >> 24 ); - buffer[cursor++] = (byte) ((value.longitude & 0x00FF0000) >> 16 ); - buffer[cursor++] = (byte) ((value.longitude & 0x0000FF00) >> 8 ); - buffer[cursor++] = (byte) ((value.longitude & 0x000000FF) ); + buffer[cursor++] = (byte)((value.latitude & 0xFF000000) >> 24); + buffer[cursor++] = (byte)((value.latitude & 0x00FF0000) >> 16); + buffer[cursor++] = (byte)((value.latitude & 0x0000FF00) >> 8); + buffer[cursor++] = (byte)((value.latitude & 0x000000FF)); + buffer[cursor++] = (byte)((value.longitude & 0xFF000000) >> 24); + buffer[cursor++] = (byte)((value.longitude & 0x00FF0000) >> 16); + buffer[cursor++] = (byte)((value.longitude & 0x0000FF00) >> 8); + buffer[cursor++] = (byte)((value.longitude & 0x000000FF)); buffer[cursor++] = value.satellites; buffer[cursor++] = highByte(value.hdop); buffer[cursor++] = lowByte(value.hdop); @@ -221,12 +221,14 @@ void PayloadConvert::addStatus(uint16_t voltage, uint64_t uptime, float celsius) { uint16_t temp = celsius * 10; uint16_t volt = voltage / 10; +#ifdef HAS_BATTERY_PROBE #if (PAYLOAD_ENCODER == 3) buffer[cursor++] = LPP_BATT_CHANNEL; #endif buffer[cursor++] = LPP_ANALOG_INPUT; buffer[cursor++] = highByte(volt); buffer[cursor++] = lowByte(volt); +#endif #if (PAYLOAD_ENCODER == 3) buffer[cursor++] = LPP_TEMP_CHANNEL; #endif @@ -244,16 +246,15 @@ void PayloadConvert::addGPS(gpsStatus_t value) { buffer[cursor++] = LPP_GPS_CHANNEL; #endif buffer[cursor++] = LPP_GPS; - buffer[cursor++] = (byte) ((lat & 0xFF0000) >> 16 ); - buffer[cursor++] = (byte) ((lat & 0x00FF00) >> 8 ); - buffer[cursor++] = (byte) ((lat & 0x0000FF) ); - buffer[cursor++] = (byte) ((lon & 0xFF0000) >> 16 ); - buffer[cursor++] = (byte) ((lon & 0x00FF00) >> 8 ); - buffer[cursor++] = (byte) ((lon & 0x0000FF) ); - buffer[cursor++] = (byte) ((alt & 0xFF0000) >> 16 ); - buffer[cursor++] = (byte) ((alt & 0x00FF00) >> 8 ); - buffer[cursor++] = (byte) ((alt & 0x0000FF) ); - + buffer[cursor++] = (byte)((lat & 0xFF0000) >> 16); + buffer[cursor++] = (byte)((lat & 0x00FF00) >> 8); + buffer[cursor++] = (byte)((lat & 0x0000FF)); + buffer[cursor++] = (byte)((lon & 0xFF0000) >> 16); + buffer[cursor++] = (byte)((lon & 0x00FF00) >> 8); + buffer[cursor++] = (byte)((lon & 0x0000FF)); + buffer[cursor++] = (byte)((alt & 0xFF0000) >> 16); + buffer[cursor++] = (byte)((alt & 0x00FF00) >> 8); + buffer[cursor++] = (byte)((alt & 0x0000FF)); } #endif From 487b2ff9fb7c4853958a333069d92c3863e09fa7 Mon Sep 17 00:00:00 2001 From: Klaus K Wilting Date: Sun, 22 Jul 2018 18:04:09 +0200 Subject: [PATCH 2/3] senddata.cpp bugfix Cayenneport --- src/senddata.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/senddata.cpp b/src/senddata.cpp index 3f39faea..fc0123b7 100644 --- a/src/senddata.cpp +++ b/src/senddata.cpp @@ -9,7 +9,7 @@ void senddata(uint8_t port) { ESP_LOGI(TAG, "LoRa busy, data not sent"); sprintf(display_line7, "LORA BUSY"); } else { - LMIC_setTxData2(PAYLOAD_ENCODER == 4 ? CAYENNEPORT : port, + LMIC_setTxData2(PAYLOAD_ENCODER <= 3 ? port : CAYENNEPORT, payload.getBuffer(), payload.getSize(), (cfg.countermode & 0x02)); From 32246105756d73400503827400def5e61685d86a Mon Sep 17 00:00:00 2001 From: Klaus K Wilting Date: Sun, 22 Jul 2018 18:13:21 +0200 Subject: [PATCH 3/3] cayenne lpp port selection fixed --- src/paxcounter.conf | 3 ++- src/senddata.cpp | 7 ++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/paxcounter.conf b/src/paxcounter.conf index 7481c001..15bce027 100644 --- a/src/paxcounter.conf +++ b/src/paxcounter.conf @@ -56,7 +56,8 @@ #define CONFIGPORT 3 // Port on which device sends gps query results #define GPSPORT 4 // Port on which device sends gps query results #define BUTTONPORT 5 // Port on which device sends button pressed signal -#define CAYENNEPORT 2 // Port for Cayenne LPP 2.0 packet sensor encoding +#define LPP1PORT 1 // Port for Cayenne LPP 1.0 dynamic sensor encoding +#define LPP2PORT 2 // Port for Cayenne LPP 2.0 packed sensor encoding // Some hardware settings #define RGBLUMINOSITY 30 // RGB LED luminosity [default = 30%] diff --git a/src/senddata.cpp b/src/senddata.cpp index fc0123b7..8efe7fd3 100644 --- a/src/senddata.cpp +++ b/src/senddata.cpp @@ -9,9 +9,10 @@ void senddata(uint8_t port) { ESP_LOGI(TAG, "LoRa busy, data not sent"); sprintf(display_line7, "LORA BUSY"); } else { - LMIC_setTxData2(PAYLOAD_ENCODER <= 3 ? port : CAYENNEPORT, - payload.getBuffer(), payload.getSize(), - (cfg.countermode & 0x02)); + LMIC_setTxData2( + PAYLOAD_ENCODER <= 2 ? port + : (PAYLOAD_ENCODER == 4 ? LPP2PORT : LPP1PORT), + payload.getBuffer(), payload.getSize(), (cfg.countermode & 0x02)); ESP_LOGI(TAG, "%d bytes queued to send on LoRa", payload.getSize()); sprintf(display_line7, "PACKET QUEUED");