bugfix cayenne encoding

This commit is contained in:
Klaus K Wilting 2018-11-18 12:09:18 +01:00
parent b38d9ab980
commit 02b3f1e2d4
5 changed files with 20 additions and 15 deletions

View File

@ -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

View File

@ -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

View File

@ -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);
}

View File

@ -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