cayenne payload encoding modified
This commit is contained in:
parent
96a42434fd
commit
18c0c06598
@ -16,8 +16,8 @@
|
||||
;env_default = heltec
|
||||
;env_default = ttgov1
|
||||
;env_default = ttgov2
|
||||
;env_default = ttgov21
|
||||
env_default = ttgobeam
|
||||
env_default = ttgov21
|
||||
;env_default = ttgobeam
|
||||
;env_default = lopy
|
||||
;env_default = lopy4
|
||||
;env_default = fipy
|
||||
|
@ -7,7 +7,11 @@
|
||||
// Verbose enables serial output
|
||||
#define VERBOSE 1 // comment out to silence the device, for mute use build option
|
||||
|
||||
// set this to include BLE counting and vendor filter functions
|
||||
// Payload send cycle and encoding
|
||||
#define SEND_SECS 30 // payload send cycle [seconds/2] -> 240 sec.
|
||||
#define PAYLOAD_ENCODER 3 // payload encoder: 1=Plain, 2=Packed, 3=CayenneLPP dynamic, 4=CayenneLPP packed
|
||||
|
||||
// Set this to include BLE counting and vendor filter functions
|
||||
#define VENDORFILTER 1 // comment out if you want to count things, not people
|
||||
#define BLECOUNTER 1 // comment out if you don't want BLE count, saves power & memory
|
||||
|
||||
@ -35,9 +39,7 @@
|
||||
#define WIFI_MY_COUNTRY "EU" // select locale for Wifi RF settings
|
||||
#define WIFI_CHANNEL_SWITCH_INTERVAL 50 // [seconds/100] -> 0,5 sec.
|
||||
|
||||
// LoRa payload default parameters
|
||||
#define PAYLOAD_ENCODER 3 // select payload encoder: 1=Plain, 2=Packed, 3=CayenneLPP
|
||||
#define SEND_SECS 120 // payload send cycle [seconds/2] -> 240 sec.
|
||||
// LoRa parameters
|
||||
#define MEM_LOW 2048 // [Bytes] low memory threshold triggering a send cycle
|
||||
#define RETRANSMIT_RCMD 5 // [seconds] wait time before retransmitting rcommand results
|
||||
#define PAYLOAD_BUFFER_SIZE 51 // maximum size of payload block per transmit
|
||||
@ -50,7 +52,7 @@
|
||||
#define STATUSPORT 2 // Port on which device sends remote command results
|
||||
#define CONFIGPORT 3 // Port on which device sends gps query results
|
||||
#define GPSPORT 4 // Port on which device sends gps query results
|
||||
#define CAYENNEPORT 1 // Port used for Cayenne encoding
|
||||
#define CAYENNEPORT 2 // Port for Cayenne LPP 2.0 packet sensor encoding
|
||||
|
||||
// Default RGB LED luminosity (in %)
|
||||
#define RGBLUMINOSITY 30 // 30%
|
||||
|
@ -65,7 +65,8 @@ void PayloadConvert::addConfig(configData_t value) {
|
||||
cursor += 10;
|
||||
}
|
||||
|
||||
void PayloadConvert::addStatus(uint16_t voltage, uint64_t uptime, float cputemp) {
|
||||
void PayloadConvert::addStatus(uint16_t voltage, uint64_t uptime,
|
||||
float cputemp) {
|
||||
buffer[cursor++] = voltage >> 8;
|
||||
buffer[cursor++] = voltage;
|
||||
buffer[cursor++] = uptime >> 56;
|
||||
@ -82,7 +83,6 @@ void PayloadConvert::addStatus(uint16_t voltage, uint64_t uptime, float cputemp)
|
||||
buffer[cursor++] = (uint32_t)cputemp;
|
||||
}
|
||||
|
||||
|
||||
/* ---------------- packed format with LoRa serialization Encoder ---------- */
|
||||
// derived from
|
||||
// https://github.com/thesolarnomad/lora-serialization/blob/master/src/LoraEncoder.cpp
|
||||
@ -117,7 +117,8 @@ void PayloadConvert::addConfig(configData_t value) {
|
||||
value.vendorfilter ? true : false, value.gpsmode ? true : false);
|
||||
}
|
||||
|
||||
void PayloadConvert::addStatus(uint16_t voltage, uint64_t uptime, float cputemp) {
|
||||
void PayloadConvert::addStatus(uint16_t voltage, uint64_t uptime,
|
||||
float cputemp) {
|
||||
writeUint16(voltage);
|
||||
writeUptime(uptime);
|
||||
writeTemperature(cputemp);
|
||||
@ -180,16 +181,20 @@ void PayloadConvert::writeBitmap(bool a, bool b, bool c, bool d, bool e, bool f,
|
||||
/* ---------------- Cayenne LPP format ---------- */
|
||||
// http://community.mydevices.com/t/cayenne-lpp-2-0/7510
|
||||
|
||||
#elif PAYLOAD_ENCODER == 3
|
||||
#elif (PAYLOAD_ENCODER == 3 || PAYLOAD_ENCODER == 4)
|
||||
|
||||
void PayloadConvert::addCount(uint16_t value1, uint16_t value2) {
|
||||
uint16_t val1 = value1 * 100;
|
||||
uint16_t val2 = value2 * 100;
|
||||
#if (PAYLOAD_ENCODER == 3)
|
||||
buffer[cursor++] = LPP_COUNT_WIFI_CHANNEL;
|
||||
#endif
|
||||
buffer[cursor++] = LPP_ANALOG_INPUT; // workaround, type meter not found?
|
||||
buffer[cursor++] = val1 >> 8;
|
||||
buffer[cursor++] = val1;
|
||||
#if (PAYLOAD_ENCODER == 3)
|
||||
buffer[cursor++] = LPP_COUNT_BLE_CHANNEL;
|
||||
#endif
|
||||
buffer[cursor++] = LPP_ANALOG_INPUT; // workaround, type meter not found?
|
||||
buffer[cursor++] = val2 >> 8;
|
||||
buffer[cursor++] = val2;
|
||||
@ -200,7 +205,9 @@ void PayloadConvert::addGPS(gpsStatus_t value) {
|
||||
int32_t lat = value.latitude / 100;
|
||||
int32_t lon = value.longitude / 100;
|
||||
int32_t alt = value.altitude * 100;
|
||||
#if (PAYLOAD_ENCODER == 3)
|
||||
buffer[cursor++] = LPP_GPS_CHANNEL;
|
||||
#endif
|
||||
buffer[cursor++] = LPP_GPS;
|
||||
buffer[cursor++] = lat >> 16;
|
||||
buffer[cursor++] = lat >> 8;
|
||||
@ -215,18 +222,25 @@ void PayloadConvert::addGPS(gpsStatus_t value) {
|
||||
#endif
|
||||
|
||||
void PayloadConvert::addConfig(configData_t value) {
|
||||
#if (PAYLOAD_ENCODER == 3)
|
||||
buffer[cursor++] = LPP_ADR_CHANNEL;
|
||||
#endif
|
||||
buffer[cursor++] = LPP_DIGITAL_INPUT;
|
||||
buffer[cursor++] = value.adrmode;
|
||||
}
|
||||
|
||||
void PayloadConvert::addStatus(uint16_t voltage, uint64_t uptime, float celsius) {
|
||||
void PayloadConvert::addStatus(uint16_t voltage, uint64_t uptime,
|
||||
float celsius) {
|
||||
int16_t val = celsius * 10;
|
||||
#if (PAYLOAD_ENCODER == 3)
|
||||
buffer[cursor++] = LPP_BATT_CHANNEL;
|
||||
#endif
|
||||
buffer[cursor++] = LPP_ANALOG_INPUT;
|
||||
buffer[cursor++] = voltage >> 8;
|
||||
buffer[cursor++] = voltage;
|
||||
#if (PAYLOAD_ENCODER == 3)
|
||||
buffer[cursor++] = LPP_TEMP_CHANNEL;
|
||||
#endif
|
||||
buffer[cursor++] = LPP_TEMPERATURE;
|
||||
buffer[cursor++] = (uint16_t)val >> 8;
|
||||
buffer[cursor++] = (uint16_t)val;
|
||||
|
@ -1,13 +1,15 @@
|
||||
#ifndef _PAYLOAD_H_
|
||||
#define _PAYLOAD_H_
|
||||
|
||||
// MyDevices CayenneLPP channels
|
||||
// MyDevices CayenneLPP channels for dynamic sensor payload format
|
||||
#if (PAYLOAD_ENCODER == 3)
|
||||
#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
|
||||
#endif
|
||||
|
||||
// MyDevices CayenneLPP types
|
||||
#define LPP_GPS 136 // 3 byte lon/lat 0.0001 °, 3 bytes alt 0.01m
|
||||
@ -56,7 +58,7 @@ private:
|
||||
bool h);
|
||||
};
|
||||
|
||||
#elif PAYLOAD_ENCODER == 3 // format cayenne lpp
|
||||
#elif (PAYLOAD_ENCODER == 3 || PAYLOAD_ENCODER == 4) // format cayenne lpp
|
||||
|
||||
private:
|
||||
uint8_t *buffer;
|
||||
|
@ -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 == 3 ? CAYENNEPORT : port,
|
||||
LMIC_setTxData2(PAYLOAD_ENCODER == 4 ? CAYENNEPORT : port,
|
||||
payload.getBuffer(), payload.getSize(),
|
||||
(cfg.countermode & 0x02));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user