STIMA  3
typedef.h
1 #ifndef TYPEDEF_H_
2 #define TYPEDEF_H_
3 #include <mqtt_config.h>
4 #include <mutex.hpp>
5 
10 #define CONSTANTDATA_BTABLE_LENGTH (7)
11 
16 #define CONSTANTDATA_VALUE_LENGTH (33)
17 
22 #define MAX_CONSTANTDATA_COUNT (5)
23 
24 
30  float temperature;
31  int humidity;
32  int pm2;
33  int pm10;
34  int co2;
35  summarydata_t() {
36  temperature=NAN;
37  humidity=-999;
38  pm2=-999;
39  pm10=-999;
40  co2=-999;
41  }
42 };
43 
48 typedef struct {
49  char btable[CONSTANTDATA_BTABLE_LENGTH];
50  char value[CONSTANTDATA_VALUE_LENGTH];
52 
57 struct georef_t
58 {
59  char lon[11];
60  char lat[11];
61  time_t timestamp;
62  cpp_freertos::MutexStandard* mutex;
63 };
64 
69 struct station_t
70 {
71  char longitude[11];
72  char latitude[11];
73  char network[31];
74  char ident[10];
75  char server[41];
76  char ntp_server[41];
77  char mqtt_server[41];
78  int sampletime;
79  char user[10];
80  char password[31];
81  char stationslug[31];
82  char boardslug[31];
83  char mqttrootpath[10];
84  char mqttmaintpath[10];
85  constantdata_t constantdata[MAX_CONSTANTDATA_COUNT];
87 
88  //define your default values here, if there are different values in config.json, they are overwritten.
89  station_t() {
90  longitude[0] = '\0';
91  latitude[0] = '\0';
92  network[0] = '\0';
93  strcpy(server,"rmap.cc");
94  strcpy(ntp_server, "europe.pool.ntp.org");
95  strcpy(mqtt_server, "rmap.cc");
96  sampletime = DEFAULT_SAMPLETIME;
97  user[0] = '\0';
98  password[0] = '\0';
99  strcpy(stationslug, "stimawifi");
100  strcpy(boardslug, "default");
101  strcpy(mqttrootpath, "sample");
102  strcpy(mqttmaintpath,"maint");
104  }
105 };
106 
111 struct sensor_t
112 {
113  char driver[SENSORDRIVER_DRIVER_LEN]; // driver name
114  int node; // RF24Nework node id (radio driver)
115  char type[SENSORDRIVER_TYPE_LEN]; // sensor type name
116  int address; // i2c address
117  char timerange[SENSORDRIVER_META_LEN]; // timerange for mqtt pubblish
118  char level [SENSORDRIVER_META_LEN]; // level for mqtt pubblish
119 
120  sensor_t() : address(-1) {
121  driver[0]='\0';
122  node = -1;
123  type[0]='\0';
124  timerange[0]='\0';
125  level[0]='\0';
126  }
127 };
128 
134 {
135  uint8_t sent;
137  char payload[MQTT_MESSAGE_LENGTH];
138 };
139 
145 enum status_e { unknown, ok, error };
146 
152 {
153  status_e novalue;
154  status_e sensor;
155  status_e geodef;
156 };
157 
163 {
164  status_e connect;
165  status_e publish;
166 };
167 
173 {
174  status_e receive;
175 };
176 
182 {
183  status_e receive;
184 };
185 
191 {
192  status_e database;
193 };
194 
200 {
206 };
207 
208 
214 {
215  char dtstart[20]; //"YYYY-MM-GGTHH:MM:SS";
216  char dtend[20]; //"YYYY-MM-GGTHH:MM:SS";
217 };
218 
219 #endif
#define MQTT_MESSAGE_LENGTH
Length in bytes for mqtt message.
Definition: mqtt_config.h:60
#define MQTT_ROOT_TOPIC_LENGTH
Length in bytes for mqtt root topic.
Definition: mqtt_config.h:30
#define MQTT_SENSOR_TOPIC_LENGTH
Length in bytes for mqtt sensor topic.
Definition: mqtt_config.h:48
#define CONSTANTDATA_VALUE_LENGTH
Maximum lenght of value plus terminator for one constant data.
Definition: constantdata_config.h:36
#define CONSTANTDATA_BTABLE_LENGTH
Maximum lenght of btable code plus terminator that describe one constant data.
Definition: constantdata_config.h:30
Definition: sensor_config.h:18
Definition: typedef.h:191
status_e database
stato di funzionamento del DataBase
Definition: typedef.h:192
Definition: typedef.h:58
char lon[11]
longitudine in sessadecimale 5 decimali rappresentazione intera
Definition: typedef.h:59
char lat[11]
latitudine in sessadecimale 5 decimali rappresentazione intera
Definition: typedef.h:60
time_t timestamp
timestamp delle coordinate
Definition: typedef.h:61
cpp_freertos::MutexStandard * mutex
mutex per l'accesso ai dati
Definition: typedef.h:62
Definition: typedef.h:182
status_e receive
stato della ricezione dei dati per georeferenziazione
Definition: typedef.h:183
Definition: typedef.h:152
status_e geodef
stato dei dati di georefenzazione per la pubblicazione
Definition: typedef.h:155
status_e sensor
stato dei sensori
Definition: typedef.h:154
status_e novalue
stato delle misurazioni
Definition: typedef.h:153
Definition: typedef.h:134
Definition: typedef.h:163
status_e connect
stato della connessione MQTT
Definition: typedef.h:164
status_e publish
stato della pubblicazione dati MQTT
Definition: typedef.h:165
Definition: typedef.h:214
sensors configuration.
Definition: typedef.h:112
Definition: typedef.h:70
char stationslug[31]
nome sintetico della stazione
Definition: typedef.h:81
char mqttrootpath[10]
radice del topic MQTT per i dati
Definition: typedef.h:83
char ident[10]
identificativo per stazioni mobili
Definition: typedef.h:74
char longitude[11]
longitudine in sessadecimale 5 decimali rappresentazione intera
Definition: typedef.h:71
char password[31]
password
Definition: typedef.h:80
char network[31]
rete osservativa della stazione
Definition: typedef.h:73
uint8_t constantdata_count
configured constantdata number
Definition: typedef.h:86
int sampletime
intervallo tra le misurazioni in secondi
Definition: typedef.h:78
constantdata_t constantdata[MAX_CONSTANTDATA_COUNT]
Constantdata buffer for storing constant station data parameter (metadati)
Definition: typedef.h:85
char mqttmaintpath[10]
radice del topic MQTT per i dati amministrativi
Definition: typedef.h:84
char user[10]
utente
Definition: typedef.h:79
char latitude[11]
latitudine in sessadecimale 5 decimali rappresentazione intera
Definition: typedef.h:72
char boardslug[31]
nome sintetico della board
Definition: typedef.h:82
char ntp_server[41]
server NTP
Definition: typedef.h:76
char mqtt_server[41]
broker MQTT
Definition: typedef.h:77
char server[41]
server RMAP
Definition: typedef.h:75
Definition: typedef.h:200
udpStatus_t udp
Stati relativi al thread di ricezione UDP dei dati di georeferenziazione.
Definition: typedef.h:203
measureStatus_t measure
Stati relativi al thread di misura.
Definition: typedef.h:201
publishStatus_t publish
Stati relativi al thread di pubblicazione.
Definition: typedef.h:202
dbStatus_t db
Stati relativi al thread di gestione del DataBase.
Definition: typedef.h:205
gpsStatus_t gps
Stati relativi al thread di ricezione GPS (porta seriale) dei dati di georeferenziazione.
Definition: typedef.h:204
Definition: typedef.h:29
Definition: typedef.h:173
status_e receive
stato della ricezione dei dati per georeferenziazione
Definition: typedef.h:174