bastien vincke
/
SmartCampus_Lorawan
First program for SmartCampus LoRaWan
SmartFormat.h@52:bfaf25ee5cd5, 2020-02-05 (annotated)
- Committer:
- bastienvincke
- Date:
- Wed Feb 05 13:17:21 2020 +0000
- Revision:
- 52:bfaf25ee5cd5
- Parent:
- 51:885c5ed083d1
bv
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
bastienvincke | 51:885c5ed083d1 | 1 | #ifndef _SMARTFORMAT_H_ |
bastienvincke | 51:885c5ed083d1 | 2 | #define _SMARTFORMAT_H_ |
bastienvincke | 51:885c5ed083d1 | 3 | |
bastienvincke | 51:885c5ed083d1 | 4 | #include "mbed.h" |
bastienvincke | 51:885c5ed083d1 | 5 | |
bastienvincke | 51:885c5ed083d1 | 6 | const uint16_t SF_DIGITAL_INPUT=3200; |
bastienvincke | 51:885c5ed083d1 | 7 | const uint16_t SF_DIGITAL_OUTPUT=3201; |
bastienvincke | 51:885c5ed083d1 | 8 | const uint16_t SF_ANALOG_INPUT=3202; |
bastienvincke | 51:885c5ed083d1 | 9 | const uint16_t SF_ANALOG_OUTPUT=3203; |
bastienvincke | 51:885c5ed083d1 | 10 | const uint16_t SF_GENERIC_SENSOR=3300; |
bastienvincke | 51:885c5ed083d1 | 11 | const uint16_t SF_ILLUMINANCE=3301; |
bastienvincke | 51:885c5ed083d1 | 12 | const uint16_t SF_PRESENCE=3302; |
bastienvincke | 51:885c5ed083d1 | 13 | const uint16_t SF_TEMPERATURE=3303; |
bastienvincke | 51:885c5ed083d1 | 14 | const uint16_t SF_HUMIDITY=3304; |
bastienvincke | 51:885c5ed083d1 | 15 | const uint16_t SF_POWER_MEASUREMENT=3305; |
bastienvincke | 51:885c5ed083d1 | 16 | const uint16_t SF_ACTUATION=3306; |
bastienvincke | 51:885c5ed083d1 | 17 | const uint16_t SF_SET_POINT=3308; |
bastienvincke | 51:885c5ed083d1 | 18 | const uint16_t SF_LOAD_CONTROL=3310; |
bastienvincke | 51:885c5ed083d1 | 19 | const uint16_t SF_LIGHT_CONTROL=3311; |
bastienvincke | 51:885c5ed083d1 | 20 | const uint16_t SF_POWER_CONTROL=3312; |
bastienvincke | 51:885c5ed083d1 | 21 | const uint16_t SF_ACCELEROMETER=3313; |
bastienvincke | 51:885c5ed083d1 | 22 | const uint16_t SF_MAGNETOMETER=3314; |
bastienvincke | 51:885c5ed083d1 | 23 | const uint16_t SF_BAROMETER=3315; |
bastienvincke | 51:885c5ed083d1 | 24 | const uint16_t SF_VOLTAGE=3316; |
bastienvincke | 51:885c5ed083d1 | 25 | const uint16_t SF_CURRENT=3317; |
bastienvincke | 51:885c5ed083d1 | 26 | const uint16_t SF_FREQUENCY=3318; |
bastienvincke | 51:885c5ed083d1 | 27 | const uint16_t SF_DEPTH=3319; |
bastienvincke | 51:885c5ed083d1 | 28 | const uint16_t SF_PERCENTAGE=3320; |
bastienvincke | 51:885c5ed083d1 | 29 | const uint16_t SF_ALTITUDE=3321; |
bastienvincke | 51:885c5ed083d1 | 30 | const uint16_t SF_LOAD=3322; |
bastienvincke | 51:885c5ed083d1 | 31 | const uint16_t SF_PRESSURE=3323; |
bastienvincke | 51:885c5ed083d1 | 32 | const uint16_t SF_DISTANCE=3330; |
bastienvincke | 51:885c5ed083d1 | 33 | const uint16_t SF_ENERGY=3331; |
bastienvincke | 51:885c5ed083d1 | 34 | const uint16_t SF_DIRECTION=3332; |
bastienvincke | 51:885c5ed083d1 | 35 | const uint16_t SF_TIME=3333; |
bastienvincke | 51:885c5ed083d1 | 36 | const uint16_t SF_GYROMETER=3334; |
bastienvincke | 51:885c5ed083d1 | 37 | const uint16_t SF_COLOUR=3335; |
bastienvincke | 51:885c5ed083d1 | 38 | const uint16_t SF_LOCATION=3336; |
bastienvincke | 51:885c5ed083d1 | 39 | |
bastienvincke | 51:885c5ed083d1 | 40 | |
bastienvincke | 51:885c5ed083d1 | 41 | // Data ID + Data Type + Data Size |
bastienvincke | 51:885c5ed083d1 | 42 | #define SF_DIGITAL_INPUT_SIZE 1 // 1 ou 0 (8bits) |
bastienvincke | 51:885c5ed083d1 | 43 | #define SF_DIGITAL_OUTPUT_SIZE 1 // 1 ou 0 (8bits) |
bastienvincke | 51:885c5ed083d1 | 44 | #define SF_ANALOG_INPUT_SIZE 4 // float 32 bits |
bastienvincke | 51:885c5ed083d1 | 45 | #define SF_ANALOG_OUTPUT_SIZE 4 // float 32 bits |
bastienvincke | 51:885c5ed083d1 | 46 | #define SF_GENERIC_SENSOR_SIZE 4 // float 32 bits |
bastienvincke | 51:885c5ed083d1 | 47 | #define SF_ILLUMINANCE_SIZE 4 // float 32 bits |
bastienvincke | 51:885c5ed083d1 | 48 | #define SF_PRESENCE_SIZE 2 |
bastienvincke | 51:885c5ed083d1 | 49 | #define SF_TEMPERATURE_SIZE 4 // float 32 bits |
bastienvincke | 51:885c5ed083d1 | 50 | #define SF_HUMIDITY_SIZE 4 // float 32 bits |
bastienvincke | 51:885c5ed083d1 | 51 | #define SF_POWER_MEASUREMENT_SIZE 4 // float 32 bits |
bastienvincke | 51:885c5ed083d1 | 52 | #define SF_ACTUATION_SIZE 4 // float 32 bits |
bastienvincke | 51:885c5ed083d1 | 53 | #define SF_SET_POINT_SIZE 4 // float 32 bits |
bastienvincke | 51:885c5ed083d1 | 54 | #define SF_LOAD_CONTROL_SIZE 1 // 1 ou 0 (8bits) |
bastienvincke | 51:885c5ed083d1 | 55 | #define SF_LIGHT_CONTROL_SIZE 1 // 1 ou 0 (8bits) |
bastienvincke | 51:885c5ed083d1 | 56 | #define SF_POWER_CONTROL_SIZE 4 // float 32 bits |
bastienvincke | 51:885c5ed083d1 | 57 | #define SF_ACCELEROMETER_SIZE 4 // float 32 bits |
bastienvincke | 51:885c5ed083d1 | 58 | #define SF_MAGNETOMETER_SIZE 4 // float 32 bits |
bastienvincke | 51:885c5ed083d1 | 59 | #define SF_BAROMETER_SIZE 4 // float 32 bits |
bastienvincke | 51:885c5ed083d1 | 60 | #define SF_VOLTAGE_SIZE 4 // float 32 bits |
bastienvincke | 51:885c5ed083d1 | 61 | #define SF_CURRENT_SIZE 4 // float 32 bits |
bastienvincke | 51:885c5ed083d1 | 62 | #define SF_VOLTAGE_SIZE 4 // float 32 bits |
bastienvincke | 51:885c5ed083d1 | 63 | #define SF_FREQUENCY_SIZE 4 // float 32 bits |
bastienvincke | 51:885c5ed083d1 | 64 | #define SF_DEPTH_SIZE 4 // float 32 bits |
bastienvincke | 51:885c5ed083d1 | 65 | #define SF_PERCENTAGE_SIZE 4 // float 32 bits |
bastienvincke | 51:885c5ed083d1 | 66 | #define SF_ALTITUDE_SIZE 4 // float 32 bits |
bastienvincke | 51:885c5ed083d1 | 67 | #define SF_LOAD_SIZE 4 // float 32 bits |
bastienvincke | 51:885c5ed083d1 | 68 | #define SF_PRESSURE_SIZE 4 // float 32 bits |
bastienvincke | 51:885c5ed083d1 | 69 | #define SF_DISTANCE_SIZE 4 // float 32 bits |
bastienvincke | 51:885c5ed083d1 | 70 | #define SF_ENERGY_SIZE 4 // float 32 bits |
bastienvincke | 51:885c5ed083d1 | 71 | #define SF_DIRECTION_SIZE 4 // float 32 bits |
bastienvincke | 51:885c5ed083d1 | 72 | #define SF_TIME_SIZE 4 // float 32 bits |
bastienvincke | 51:885c5ed083d1 | 73 | #define SF_GYROMETER_SIZE 4 // float 32 bits |
bastienvincke | 51:885c5ed083d1 | 74 | #define SF_COLOUR_SIZE 4 // int 32 bits RGBA |
bastienvincke | 51:885c5ed083d1 | 75 | #define SF_LOCATION_SIZE 12 // 3*float - latitude longitude altitude |
bastienvincke | 51:885c5ed083d1 | 76 | |
bastienvincke | 51:885c5ed083d1 | 77 | |
bastienvincke | 51:885c5ed083d1 | 78 | class SmartFormat { |
bastienvincke | 51:885c5ed083d1 | 79 | public: |
bastienvincke | 51:885c5ed083d1 | 80 | SmartFormat(uint8_t size, uint16_t id); |
bastienvincke | 51:885c5ed083d1 | 81 | ~SmartFormat(); |
bastienvincke | 51:885c5ed083d1 | 82 | |
bastienvincke | 51:885c5ed083d1 | 83 | void reset(void); |
bastienvincke | 51:885c5ed083d1 | 84 | uint8_t getSize(void); |
bastienvincke | 51:885c5ed083d1 | 85 | uint8_t* getBuffer(void); |
bastienvincke | 51:885c5ed083d1 | 86 | uint8_t copy(uint8_t* buffer); |
bastienvincke | 51:885c5ed083d1 | 87 | |
bastienvincke | 51:885c5ed083d1 | 88 | uint8_t add_Digital_Input(uint8_t value); |
bastienvincke | 51:885c5ed083d1 | 89 | uint8_t add_Digital_Output(uint8_t value); |
bastienvincke | 51:885c5ed083d1 | 90 | uint8_t add_Analog_Input(float value); |
bastienvincke | 51:885c5ed083d1 | 91 | uint8_t add_Analog_Onput(float value); |
bastienvincke | 51:885c5ed083d1 | 92 | uint8_t add_Generic_Sensor(float value); |
bastienvincke | 51:885c5ed083d1 | 93 | uint8_t add_Illuminance(float value); |
bastienvincke | 51:885c5ed083d1 | 94 | uint8_t add_Presence(int16_t value); |
bastienvincke | 51:885c5ed083d1 | 95 | uint8_t add_Temperature(float value); |
bastienvincke | 51:885c5ed083d1 | 96 | uint8_t add_Humidity(float value); |
bastienvincke | 51:885c5ed083d1 | 97 | uint8_t add_Power_Measurement(float value); |
bastienvincke | 51:885c5ed083d1 | 98 | uint8_t add_Actuation(float value); |
bastienvincke | 51:885c5ed083d1 | 99 | uint8_t add_Set_Point(float value); |
bastienvincke | 51:885c5ed083d1 | 100 | uint8_t add_Load_Control(uint8_t value); |
bastienvincke | 51:885c5ed083d1 | 101 | uint8_t add_Light_Control(uint8_t value); |
bastienvincke | 51:885c5ed083d1 | 102 | uint8_t add_Power_Control(float value); |
bastienvincke | 51:885c5ed083d1 | 103 | uint8_t add_Accelerometer(float value); |
bastienvincke | 51:885c5ed083d1 | 104 | uint8_t add_Magnetometer(float value); |
bastienvincke | 51:885c5ed083d1 | 105 | uint8_t add_Barometer(float value); |
bastienvincke | 51:885c5ed083d1 | 106 | uint8_t add_Voltage(float value); |
bastienvincke | 51:885c5ed083d1 | 107 | uint8_t add_Current(float value); |
bastienvincke | 51:885c5ed083d1 | 108 | uint8_t add_Frequency(float value); |
bastienvincke | 51:885c5ed083d1 | 109 | uint8_t add_Depth(float value); |
bastienvincke | 51:885c5ed083d1 | 110 | uint8_t add_Percentage(float value); |
bastienvincke | 51:885c5ed083d1 | 111 | uint8_t add_Altitude(float value); |
bastienvincke | 51:885c5ed083d1 | 112 | uint8_t add_Load(float value); |
bastienvincke | 51:885c5ed083d1 | 113 | uint8_t add_Pressure(float value); |
bastienvincke | 51:885c5ed083d1 | 114 | uint8_t add_Distance(float value); |
bastienvincke | 51:885c5ed083d1 | 115 | uint8_t add_Energy(float value); |
bastienvincke | 51:885c5ed083d1 | 116 | uint8_t add_Direction(float value); |
bastienvincke | 51:885c5ed083d1 | 117 | uint8_t add_Time(float value); |
bastienvincke | 51:885c5ed083d1 | 118 | uint8_t add_Gyrometer(float value); |
bastienvincke | 51:885c5ed083d1 | 119 | uint8_t add_Colour(int32_t value); |
bastienvincke | 51:885c5ed083d1 | 120 | uint8_t add_Location(float latitude, float longitude, float altitude); |
bastienvincke | 51:885c5ed083d1 | 121 | |
bastienvincke | 51:885c5ed083d1 | 122 | private: |
bastienvincke | 51:885c5ed083d1 | 123 | uint8_t *buffer; |
bastienvincke | 51:885c5ed083d1 | 124 | uint8_t maxsize; |
bastienvincke | 51:885c5ed083d1 | 125 | uint8_t cursor; |
bastienvincke | 51:885c5ed083d1 | 126 | |
bastienvincke | 51:885c5ed083d1 | 127 | |
bastienvincke | 51:885c5ed083d1 | 128 | }; |
bastienvincke | 51:885c5ed083d1 | 129 | |
bastienvincke | 51:885c5ed083d1 | 130 | |
bastienvincke | 51:885c5ed083d1 | 131 | #endif |