diff --git a/include/payload.h b/include/payload.h index aaa38566..5acd0a76 100644 --- a/include/payload.h +++ b/include/payload.h @@ -15,7 +15,7 @@ #define LPP_MSG_CHANNEL 28 #define LPP_HUMIDITY_CHANNEL 29 #define LPP_BAROMETER_CHANNEL 30 -#define LPP_GAS_CHANNEL 31 +#define LPP_GAS_CHANNEL 31 #endif diff --git a/src/cyclic.cpp b/src/cyclic.cpp index 99329040..4bdaa77d 100644 --- a/src/cyclic.cpp +++ b/src/cyclic.cpp @@ -102,11 +102,11 @@ void do_timesync() { } else { ESP_LOGI(TAG, "No valid GPS time"); } -#endif +#endif // HAS_GPS // Schedule a network time request at the next possible time LMIC_requestNetworkTime(user_request_network_time_callback, &userUTCTime); ESP_LOGI(TAG, "Network time request scheduled"); -#endif +#endif // TIME_SYNC } // do_timesync() #ifndef VERBOSE diff --git a/src/lmic_config.h b/src/lmic_config.h index bfa52ec3..5197f046 100644 --- a/src/lmic_config.h +++ b/src/lmic_config.h @@ -22,7 +22,7 @@ //#define LMIC_USE_INTERRUPTS //time sync via LoRaWAN network, is not yet supported by TTN (LoRaWAN spec v1.0.3) -//#define LMIC_ENABLE_DeviceTimeReq 1 +#define LMIC_ENABLE_DeviceTimeReq 1 // 16 μs per tick // LMIC requires ticks to be 15.5μs - 100 μs long diff --git a/src/payload.cpp b/src/payload.cpp index c6721b00..3a9432d9 100644 --- a/src/payload.cpp +++ b/src/payload.cpp @@ -242,8 +242,10 @@ void PayloadConvert::writeBitmap(bool a, bool b, bool c, bool d, bool e, bool f, writeUint8(bitmap); } -/* ---------------- Cayenne LPP format ---------- */ -// http://community.mydevices.com/t/cayenne-lpp-2-0/7510 +/* ---------------- Cayenne LPP 2.0 format ---------- */ +// see specs http://community.mydevices.com/t/cayenne-lpp-2-0/7510 +// PAYLOAD_ENCODER == 3 -> Dynamic Sensor Payload, using channels -> FPort 1 +// PAYLOAD_ENCODER == 4 -> Packed Sensor Payload, not using channels -> FPort 2 #elif (PAYLOAD_ENCODER == 3 || PAYLOAD_ENCODER == 4) @@ -251,13 +253,15 @@ void PayloadConvert::addCount(uint16_t value1, uint16_t value2) { #if (PAYLOAD_ENCODER == 3) buffer[cursor++] = LPP_COUNT_WIFI_CHANNEL; #endif - buffer[cursor++] = LPP_TEMPERATURE; + buffer[cursor++] = + LPP_LUMINOSITY; // workaround since cayenne has no data type meter buffer[cursor++] = highByte(value1); buffer[cursor++] = lowByte(value1); #if (PAYLOAD_ENCODER == 3) buffer[cursor++] = LPP_COUNT_BLE_CHANNEL; #endif - buffer[cursor++] = LPP_HUMIDITY; + buffer[cursor++] = + LPP_LUMINOSITY; // workaround since cayenne has no data type meter buffer[cursor++] = highByte(value2); buffer[cursor++] = lowByte(value2); } diff --git a/src/senddata.cpp b/src/senddata.cpp index 50a160c0..bc010c12 100644 --- a/src/senddata.cpp +++ b/src/senddata.cpp @@ -4,7 +4,7 @@ // put data to send in RTos Queues used for transmit over channels Lora and SPI void SendData(uint8_t port) { - MessageBuffer_t SendBuffer; + MessageBuffer_t SendBuffer; // contains MessageSize, MessagePort, Message[] SendBuffer.MessageSize = payload.getSize(); SendBuffer.MessagePort = port; @@ -14,12 +14,6 @@ void SendData(uint8_t port) { lora_enqueuedata(&SendBuffer); spi_enqueuedata(&SendBuffer); - // clear counter if not in cumulative counter mode - if ((port == COUNTERPORT) && (cfg.countermode != 1)) { - reset_counters(); // clear macs container and reset all counters - get_salt(); // get new salt for salting hashes - ESP_LOGI(TAG, "Counter cleared"); - } } // SendData // interrupt triggered function to prepare payload to send @@ -30,6 +24,13 @@ void sendPayload() { payload.addCount(macs_wifi, cfg.blescan ? macs_ble : 0); // append GPS data, if present + // clear counter if not in cumulative counter mode + if (cfg.countermode != 1) { + reset_counters(); // clear macs container and reset all counters + get_salt(); // get new salt for salting hashes + ESP_LOGI(TAG, "Counter cleared"); + } + #ifdef HAS_GPS // show NMEA data in debug mode, useful for debugging GPS on board // connection