Cayenne Low Power Payload

Dependents:   LORAWAN-TTN-CAYENNE-LM35 ER4Lora gps_accelerometer sgam_mdw_test ... more

Committer:
eptak
Date:
Thu Mar 09 16:32:30 2017 +0000
Revision:
6:5a9d65b33e85
Parent:
1:3747637941bf
fix typo

Who changed what in which revision?

UserRevisionLine numberNew contents of line
eptak 0:15c6e1cab70a 1 #ifndef _CAYENNE_LPP_H_
eptak 0:15c6e1cab70a 2 #define _CAYENNE_LPP_H_
eptak 0:15c6e1cab70a 3
eptak 0:15c6e1cab70a 4 #include "mbed.h"
eptak 0:15c6e1cab70a 5
eptak 0:15c6e1cab70a 6 //LPP_BATTERY = // TODO Unsupported in IPSO Smart Object
eptak 0:15c6e1cab70a 7 //LPP_PROXIMITY = // TODO Unsupported in IPSO Smart Object
eptak 0:15c6e1cab70a 8
eptak 0:15c6e1cab70a 9 #define LPP_DIGITAL_INPUT 0 // 1 byte
eptak 0:15c6e1cab70a 10 #define LPP_DIGITAL_OUTPUT 1 // 1 byte
eptak 0:15c6e1cab70a 11 #define LPP_ANALOG_INPUT 2 // 2 bytes, 0.01 signed
eptak 0:15c6e1cab70a 12 #define LPP_ANALOG_OUTPUT 3 // 2 bytes, 0.01 signed
eptak 0:15c6e1cab70a 13 #define LPP_LUMINOSITY 101 // 2 bytes, 1 lux unsigned
eptak 0:15c6e1cab70a 14 #define LPP_PRESENCE 102 // 1 byte, 1
eptak 0:15c6e1cab70a 15 #define LPP_TEMPERATURE 103 // 2 bytes, 0.1°C signed
eptak 0:15c6e1cab70a 16 #define LPP_RELATIVE_HUMIDITY 104 // 1 byte, 0.5% unsigned
eptak 0:15c6e1cab70a 17 #define LPP_ACCELEROMETER 113 // 2 bytes per axis, 0.001G
eptak 0:15c6e1cab70a 18 #define LPP_BAROMETRIC_PRESSURE 115 // 2 bytes 0.1 hPa Unsigned
eptak 0:15c6e1cab70a 19 #define LPP_GYROMETER 134 // 2 bytes per axis, 0.01 °/s
eptak 0:15c6e1cab70a 20 #define LPP_GPS 136 // 3 byte lon/lat 0.0001 °, 3 bytes alt 0.01 meter
eptak 0:15c6e1cab70a 21
eptak 0:15c6e1cab70a 22
eptak 0:15c6e1cab70a 23 // Data ID + Data Type + Data Size
eptak 0:15c6e1cab70a 24 #define LPP_DIGITAL_INPUT_SIZE 3 // 1 byte
eptak 0:15c6e1cab70a 25 #define LPP_DIGITAL_OUTPUT_SIZE 3 // 1 byte
eptak 0:15c6e1cab70a 26 #define LPP_ANALOG_INPUT_SIZE 4 // 2 bytes, 0.01 signed
eptak 0:15c6e1cab70a 27 #define LPP_ANALOG_OUTPUT_SIZE 4 // 2 bytes, 0.01 signed
eptak 0:15c6e1cab70a 28 #define LPP_LUMINOSITY_SIZE 4 // 2 bytes, 1 lux unsigned
eptak 0:15c6e1cab70a 29 #define LPP_PRESENCE_SIZE 3 // 1 byte, 1
eptak 0:15c6e1cab70a 30 #define LPP_TEMPERATURE_SIZE 4 // 2 bytes, 0.1°C signed
eptak 0:15c6e1cab70a 31 #define LPP_RELATIVE_HUMIDITY_SIZE 3 // 1 byte, 0.5% unsigned
eptak 0:15c6e1cab70a 32 #define LPP_ACCELEROMETER_SIZE 8 // 2 bytes per axis, 0.001G
eptak 0:15c6e1cab70a 33 #define LPP_BAROMETRIC_PRESSURE_SIZE 4 // 2 bytes 0.1 hPa Unsigned
eptak 0:15c6e1cab70a 34 #define LPP_GYROMETER_SIZE 8 // 2 bytes per axis, 0.01 °/s
eptak 0:15c6e1cab70a 35 #define LPP_GPS_SIZE 11 // 3 byte lon/lat 0.0001 °, 3 bytes alt 0.01 meter
eptak 0:15c6e1cab70a 36
eptak 0:15c6e1cab70a 37
eptak 0:15c6e1cab70a 38 class CayenneLPP {
eptak 0:15c6e1cab70a 39 public:
eptak 0:15c6e1cab70a 40 CayenneLPP(uint8_t size);
eptak 0:15c6e1cab70a 41 ~CayenneLPP();
eptak 0:15c6e1cab70a 42
eptak 0:15c6e1cab70a 43 void reset(void);
eptak 0:15c6e1cab70a 44 uint8_t getSize(void);
eptak 0:15c6e1cab70a 45 uint8_t* getBuffer(void);
eptak 0:15c6e1cab70a 46 uint8_t copy(uint8_t* buffer);
eptak 0:15c6e1cab70a 47
eptak 0:15c6e1cab70a 48 uint8_t addDigitalInput(uint8_t channel, uint8_t value);
eptak 0:15c6e1cab70a 49 uint8_t addDigitalOutput(uint8_t channel, uint8_t value);
eptak 0:15c6e1cab70a 50
eptak 0:15c6e1cab70a 51 uint8_t addAnalogInput(uint8_t channel, float value);
eptak 0:15c6e1cab70a 52 uint8_t addAnalogOutput(uint8_t channel, float value);
eptak 0:15c6e1cab70a 53
eptak 0:15c6e1cab70a 54 uint8_t addLuminosity(uint8_t channel, uint16_t lux);
eptak 0:15c6e1cab70a 55 uint8_t addPresence(uint8_t channel, uint8_t value);
eptak 0:15c6e1cab70a 56 uint8_t addTemperature(uint8_t channel, float celsius);
eptak 0:15c6e1cab70a 57 uint8_t addRelativeHumidity(uint8_t channel, float rh);
eptak 0:15c6e1cab70a 58 uint8_t addAccelerometer(uint8_t channel, float x, float y, float z);
eptak 0:15c6e1cab70a 59 uint8_t addBarometricPressure(uint8_t channel, float hpa);
eptak 0:15c6e1cab70a 60 uint8_t addGyrometer(uint8_t channel, float x, float y, float z);
eptak 0:15c6e1cab70a 61 uint8_t addGPS(uint8_t channel, float latitude, float longitude, float meters);
eptak 0:15c6e1cab70a 62
eptak 0:15c6e1cab70a 63 private:
eptak 0:15c6e1cab70a 64 uint8_t *buffer;
eptak 0:15c6e1cab70a 65 uint8_t maxsize;
eptak 0:15c6e1cab70a 66 uint8_t cursor;
eptak 0:15c6e1cab70a 67
eptak 0:15c6e1cab70a 68
eptak 0:15c6e1cab70a 69 };
eptak 0:15c6e1cab70a 70
eptak 0:15c6e1cab70a 71
eptak 0:15c6e1cab70a 72 #endif