2018-06-16 13:18:36 +02:00
|
|
|
|
|
|
|
#ifndef _PAYLOAD_H_
|
|
|
|
#define _PAYLOAD_H_
|
|
|
|
|
|
|
|
#include <Arduino.h>
|
|
|
|
|
2018-06-17 01:15:02 +02:00
|
|
|
// 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
|
2018-06-17 11:07:29 +02:00
|
|
|
#define LPP_LUMINOSITY 101 // 2 bytes, 1 lux unsigned
|
2018-06-17 01:15:02 +02:00
|
|
|
|
2018-06-16 13:18:36 +02:00
|
|
|
class TTNplain {
|
|
|
|
public:
|
|
|
|
TTNplain(uint8_t size);
|
|
|
|
~TTNplain();
|
|
|
|
|
|
|
|
void reset(void);
|
|
|
|
uint8_t getSize(void);
|
|
|
|
uint8_t *getBuffer(void);
|
|
|
|
|
|
|
|
void addCount(uint16_t value1, uint16_t value2);
|
|
|
|
void addConfig(configData_t value);
|
|
|
|
void addStatus(uint16_t voltage, uint64_t uptime, float cputemp);
|
2018-06-17 13:31:24 +02:00
|
|
|
#ifdef HAS_GPS
|
|
|
|
void addGPS(gpsStatus_t value);
|
|
|
|
#endif
|
2018-06-16 13:18:36 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
uint8_t *buffer;
|
|
|
|
uint8_t cursor;
|
|
|
|
};
|
|
|
|
|
2018-06-17 22:41:32 +02:00
|
|
|
class TTNpacked {
|
2018-06-16 19:50:36 +02:00
|
|
|
public:
|
2018-06-17 22:41:32 +02:00
|
|
|
TTNpacked(uint8_t size);
|
|
|
|
~TTNpacked();
|
2018-06-16 19:50:36 +02:00
|
|
|
|
|
|
|
void reset(void);
|
|
|
|
uint8_t getSize(void);
|
|
|
|
uint8_t *getBuffer(void);
|
|
|
|
|
|
|
|
void addCount(uint16_t value1, uint16_t value2);
|
|
|
|
void addConfig(configData_t value);
|
|
|
|
void addStatus(uint16_t voltage, uint64_t uptime, float cputemp);
|
2018-06-17 13:31:24 +02:00
|
|
|
#ifdef HAS_GPS
|
|
|
|
void addGPS(gpsStatus_t value);
|
|
|
|
#endif
|
2018-06-16 19:50:36 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
uint8_t *buffer;
|
2018-06-18 00:01:14 +02:00
|
|
|
uint8_t cursor;
|
|
|
|
void _intToBytes(uint8_t pos, int32_t i, uint8_t byteSize);
|
2018-06-17 22:41:32 +02:00
|
|
|
void writeUnixtime(uint32_t unixtime);
|
|
|
|
void writeLatLng(double latitude, double longitude);
|
|
|
|
void writeUint16(uint16_t i);
|
|
|
|
void writeUint8(uint8_t i);
|
|
|
|
void writeHumidity(float humidity);
|
|
|
|
void writeTemperature(float temperature);
|
|
|
|
void writeBitmap(bool a, bool b, bool c, bool d, bool e, bool f, bool g,
|
|
|
|
bool h);
|
2018-06-16 19:50:36 +02:00
|
|
|
};
|
|
|
|
|
2018-06-16 23:14:49 +02:00
|
|
|
class CayenneLPP {
|
|
|
|
public:
|
|
|
|
CayenneLPP(uint8_t size);
|
|
|
|
~CayenneLPP();
|
|
|
|
|
|
|
|
void reset(void);
|
|
|
|
uint8_t getSize(void);
|
|
|
|
uint8_t *getBuffer(void);
|
|
|
|
|
|
|
|
void addCount(uint16_t value1, uint16_t value2);
|
|
|
|
void addConfig(configData_t value);
|
|
|
|
void addStatus(uint16_t voltage, uint64_t uptime, float cputemp);
|
2018-06-17 13:31:24 +02:00
|
|
|
#ifdef HAS_GPS
|
|
|
|
void addGPS(gpsStatus_t value);
|
|
|
|
#endif
|
2018-06-16 23:14:49 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
uint8_t *buffer;
|
|
|
|
uint8_t maxsize;
|
|
|
|
uint8_t cursor;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // _PAYLOAD_H_
|