new payload encoder (experimental)
This commit is contained in:
parent
93de42e09b
commit
b47c58436f
@ -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;
|
||||
#endif
|
11
src/main.cpp
11
src/main.cpp
@ -70,21 +70,16 @@ portMUX_TYPE timerMux =
|
||||
std::set<uint16_t> 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,
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
}
|
@ -5,6 +5,20 @@
|
||||
#include <Arduino.h>
|
||||
#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_
|
||||
|
Loading…
Reference in New Issue
Block a user