1 /*!
2  * \file      CayenneLpp.h
3  *
4  * \brief     Implements the Cayenne Low Power Protocol
5  *
6  * \copyright Revised BSD License, see section \ref LICENSE.
7  *
8  * \code
9  *                ______                              _
10  *               / _____)             _              | |
11  *              ( (____  _____ ____ _| |_ _____  ____| |__
12  *               \____ \| ___ |    (_   _) ___ |/ ___)  _ \
13  *               _____) ) ____| | | || |_| ____( (___| | | |
14  *              (______/|_____)_|_|_| \__)_____)\____)_| |_|
15  *              (C)2013-2018 Semtech
16  *
17  * \endcode
18  *
19  * \author    Miguel Luis ( Semtech )
20  */
21 #ifndef __CAYENNE_LPP_H__
22 #define __CAYENNE_LPP_H__
23 
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27 
28 #include <stdint.h>
29 
30 #define LPP_DIGITAL_INPUT       0       // 1 byte
31 #define LPP_DIGITAL_OUTPUT      1       // 1 byte
32 #define LPP_ANALOG_INPUT        2       // 2 bytes, 0.01 signed
33 #define LPP_ANALOG_OUTPUT       3       // 2 bytes, 0.01 signed
34 #define LPP_LUMINOSITY          101     // 2 bytes, 1 lux unsigned
35 #define LPP_PRESENCE            102     // 1 byte, 1
36 #define LPP_TEMPERATURE         103     // 2 bytes, 0.1°C signed
37 #define LPP_RELATIVE_HUMIDITY   104     // 1 byte, 0.5% unsigned
38 #define LPP_ACCELEROMETER       113     // 2 bytes per axis, 0.001G
39 #define LPP_BAROMETRIC_PRESSURE 115     // 2 bytes 0.1 hPa Unsigned
40 #define LPP_GYROMETER           134     // 2 bytes per axis, 0.01 °/s
41 #define LPP_GPS                 136     // 3 byte lon/lat 0.0001 °, 3 bytes alt 0.01m
42 
43 
44 // Data ID + Data Type + Data Size
45 #define LPP_DIGITAL_INPUT_SIZE       3
46 #define LPP_DIGITAL_OUTPUT_SIZE      3
47 #define LPP_ANALOG_INPUT_SIZE        4
48 #define LPP_ANALOG_OUTPUT_SIZE       4
49 #define LPP_LUMINOSITY_SIZE          4
50 #define LPP_PRESENCE_SIZE            3
51 #define LPP_TEMPERATURE_SIZE         4
52 #define LPP_RELATIVE_HUMIDITY_SIZE   3
53 #define LPP_ACCELEROMETER_SIZE       8
54 #define LPP_BAROMETRIC_PRESSURE_SIZE 4
55 #define LPP_GYROMETER_SIZE           8
56 #define LPP_GPS_SIZE                 11
57 
58 void CayenneLppInit( void );
59 
60 void CayenneLppReset( void );
61 uint8_t CayenneLppGetSize( void );
62 uint8_t* CayenneLppGetBuffer( void );
63 uint8_t CayenneLppCopy( uint8_t* buffer );
64 
65 uint8_t CayenneLppAddDigitalInput( uint8_t channel, uint8_t value );
66 uint8_t CayenneLppAddDigitalOutput( uint8_t channel, uint8_t value );
67 
68 uint8_t CayenneLppAddAnalogInput( uint8_t channel, float value );
69 uint8_t CayenneLppAddAnalogOutput( uint8_t channel, float value );
70 
71 uint8_t CayenneLppAddLuminosity( uint8_t channel, uint16_t lux );
72 uint8_t CayenneLppAddPresence( uint8_t channel, uint8_t value );
73 uint8_t CayenneLppAddTemperature( uint8_t channel, float celsius );
74 uint8_t CayenneLppAddRelativeHumidity( uint8_t channel, float rh );
75 uint8_t CayenneLppAddAccelerometer( uint8_t channel, float x, float y, float z );
76 uint8_t CayenneLppAddBarometricPressure( uint8_t channel, float hpa );
77 uint8_t CayenneLppAddGyrometer( uint8_t channel, float x, float y, float z );
78 uint8_t CayenneLppAddGps( uint8_t channel, float latitude, float longitude, float meters );
79 
80 #ifdef __cplusplus
81 }
82 #endif
83 
84 #endif // __CAYENNE_LPP_H__
85