52 lines
921 B
C++
52 lines
921 B
C++
#ifndef __SENSOR_DATA_H__
|
|
#define __SENSOR_DATA_H__
|
|
|
|
#include <cfloat>
|
|
#include <cstdint>
|
|
#include <string>
|
|
|
|
struct SensorFields {
|
|
float o3;
|
|
float co2;
|
|
float h2s;
|
|
float cl2;
|
|
float nh3;
|
|
float tvoc;
|
|
float ch2o;
|
|
float c2h5oh;
|
|
float ch4;
|
|
float o2;
|
|
float aqs;
|
|
float humidity;
|
|
float temperature;
|
|
float pm1d0;
|
|
float pm2d5;
|
|
float pm10;
|
|
float windspeed;
|
|
float winddirection;
|
|
float airpressure;
|
|
float voice;
|
|
};
|
|
|
|
struct Message {
|
|
char magic_header[8];
|
|
uint16_t sensor_id;
|
|
uint8_t _padding[2];
|
|
union {
|
|
SensorFields fields;
|
|
float data[sizeof(SensorFields) / sizeof(float)];
|
|
};
|
|
};
|
|
|
|
struct SensorInfo {
|
|
std::string name;
|
|
float resolution;
|
|
float minRange;
|
|
float maxRange;
|
|
};
|
|
|
|
int parseSensorData(char* buffer, Message* message);
|
|
bool validateMeasurement(Message* message);
|
|
|
|
#endif /* __SENSOR_DATA_H__ */
|