71 lines
2.8 KiB
C++
71 lines
2.8 KiB
C++
// Adapted from https://developer.mbed.org/teams/myDevicesIoT/code/Cayenne-LPP/
|
|
|
|
// Copyright © 2017 The Things Network
|
|
// Use of this source code is governed by the MIT license that can be found in the LICENSE file.
|
|
|
|
#ifndef _EASYTHERM_LPP_H_
|
|
#define _EASYTHERM_LPP_H_
|
|
|
|
#include <Arduino.h>
|
|
|
|
#define LPP_DIGITAL_INPUT 0x00 // input, 1 byte
|
|
#define LPP_DIGITAL_OUTPUT 0x01 // output, 1 byte
|
|
#define LPP_ANALOG_INPUT 0x02 // input, 2 bytes, 0.01 signed
|
|
#define LPP_ANALOG_OUTPUT 0x03 // output, 2 bytes, 0.01 signed
|
|
#define LPP_TEMPERATURE 0x04 // input, 2 bytes, 0.1°C signed
|
|
#define LPP_RELATIVE_HUMIDITY 0x05 // input, 1 byte, 0.5% unsigned
|
|
#define LPP_ACCELERATION 0x06 // input, 2 bytes, 0.001G
|
|
#define LPP_BAROMETRIC_PRESSURE 0x07// input, 2 bytes 0.1 hPa unsigned
|
|
#define LPP_ANGLE_VELOCITY 0x08 // input, 2 bytes, 0.01 °/s
|
|
#define LPP_LUMINOSITY 0x09 // input, 2 bytes, 1 lux unsigned
|
|
#define LPP_BATTERY_VOLTAGE 0x0A // input, 2 bytes, 1mV unsigned
|
|
#define LPP_BATTERY_STATUS 0x0B // input, 1 byte 1%, 255 == unknown
|
|
|
|
// Data ID + Data Type + Data Size
|
|
#define LPP_DIGITAL_INPUT_SIZE 3 // 1 byte
|
|
#define LPP_DIGITAL_OUTPUT_SIZE 3 // 1 byte
|
|
#define LPP_ANALOG_INPUT_SIZE 4 // 2 bytes, 0.01 signed
|
|
#define LPP_ANALOG_OUTPUT_SIZE 4 // 2 bytes, 0.01 signed
|
|
#define LPP_TEMPERATURE_SIZE 4 // input, 2 bytes, 0.1°C signed
|
|
#define LPP_RELATIVE_HUMIDITY_SIZE 3 // input, 1 byte, 0.5% unsigned
|
|
#define LPP_ACCELERATION_SIZE 4 // input, 2 bytes, 0.001G
|
|
#define LPP_BAROMETRIC_PRESSURE 4 // input, 2 bytes 0.1 hPa unsigned
|
|
#define LPP_ANGLE_VELOCITY 4 // input, 2 bytes, 0.01 °/s
|
|
#define LPP_LUMINOSITY_SIZE 4 // 2 bytes, 1 lux unsigned
|
|
#define LPP_BATTERY_VOLTAGE_SIZE 4 // 2 bytes, 1mV unsigned
|
|
#define LPP_BATTERY_STATUS_SIZE 3 // 1 byte 1%
|
|
|
|
class ETCPLPP
|
|
{
|
|
public:
|
|
ETCPLPP(uint8_t size);
|
|
~ETCPLPP();
|
|
|
|
void reset(void);
|
|
uint8_t getSize(void);
|
|
uint8_t *getBuffer(void);
|
|
uint8_t copy(uint8_t *buffer);
|
|
|
|
uint8_t addDigitalInput(uint8_t channel, uint8_t value);
|
|
uint8_t addDigitalOutput(uint8_t channel, uint8_t value);
|
|
|
|
uint8_t addAnalogInput(uint8_t channel, float value);
|
|
uint8_t addAnalogOutput(uint8_t channel, float value);
|
|
|
|
uint8_t addLuminosity(uint8_t channel, uint16_t lux);
|
|
uint8_t addPresence(uint8_t channel, uint8_t value);
|
|
uint8_t addTemperature(uint8_t channel, float celsius);
|
|
uint8_t addRelativeHumidity(uint8_t channel, float rh);
|
|
uint8_t addAccelerometer(uint8_t channel, float x, float y, float z);
|
|
uint8_t addBarometricPressure(uint8_t channel, float hpa);
|
|
uint8_t addGyrometer(uint8_t channel, float x, float y, float z);
|
|
uint8_t addGPS(uint8_t channel, float latitude, float longitude, float meters);
|
|
|
|
private:
|
|
uint8_t *buffer;
|
|
uint8_t maxsize;
|
|
uint8_t cursor;
|
|
};
|
|
|
|
#endif
|