diff options
Diffstat (limited to 'src/include/gnunet_sensor_util_lib.h')
-rw-r--r-- | src/include/gnunet_sensor_util_lib.h | 91 |
1 files changed, 91 insertions, 0 deletions
diff --git a/src/include/gnunet_sensor_util_lib.h b/src/include/gnunet_sensor_util_lib.h index 15fb61b4c..56e0bc868 100644 --- a/src/include/gnunet_sensor_util_lib.h +++ b/src/include/gnunet_sensor_util_lib.h | |||
@@ -188,6 +188,78 @@ struct SensorInfo | |||
188 | }; | 188 | }; |
189 | 189 | ||
190 | /** | 190 | /** |
191 | * Carries a single reading from a sensor | ||
192 | */ | ||
193 | struct GNUNET_SENSOR_Reading | ||
194 | { | ||
195 | |||
196 | /** | ||
197 | * Sensor this reading is related to | ||
198 | */ | ||
199 | struct SensorInfo *sensor; | ||
200 | |||
201 | /** | ||
202 | * Timestamp of taking the reading | ||
203 | */ | ||
204 | uint64_t timestamp; | ||
205 | |||
206 | /** | ||
207 | * Reading value | ||
208 | */ | ||
209 | void *value; | ||
210 | |||
211 | /** | ||
212 | * Size of @value | ||
213 | */ | ||
214 | uint16_t value_size; | ||
215 | |||
216 | }; | ||
217 | |||
218 | GNUNET_NETWORK_STRUCT_BEGIN | ||
219 | |||
220 | /** | ||
221 | * Used to communicate sensor readings to | ||
222 | * collection points (SENSORDASHBAORD service) | ||
223 | */ | ||
224 | struct GNUNET_SENSOR_ReadingMessage | ||
225 | { | ||
226 | |||
227 | /** | ||
228 | * GNUNET general message header | ||
229 | */ | ||
230 | struct GNUNET_MessageHeader header; | ||
231 | |||
232 | /** | ||
233 | * Size of the sensor name value, allocated | ||
234 | * at position 0 after this struct | ||
235 | */ | ||
236 | uint16_t sensorname_size; | ||
237 | |||
238 | /** | ||
239 | * First part of sensor version number | ||
240 | */ | ||
241 | uint16_t sensorversion_major; | ||
242 | |||
243 | /** | ||
244 | * Second part of sensor version number | ||
245 | */ | ||
246 | uint16_t sensorversion_minor; | ||
247 | |||
248 | /** | ||
249 | * Timestamp of recorded reading | ||
250 | */ | ||
251 | uint64_t timestamp; | ||
252 | |||
253 | /** | ||
254 | * Size of reading value, allocation | ||
255 | * at poistion 1 after this struct | ||
256 | */ | ||
257 | uint16_t value_size; | ||
258 | |||
259 | }; | ||
260 | GNUNET_NETWORK_STRUCT_END | ||
261 | |||
262 | /** | ||
191 | * Reads sensor definitions from local data files | 263 | * Reads sensor definitions from local data files |
192 | * | 264 | * |
193 | * @return a multihashmap of loaded sensors | 265 | * @return a multihashmap of loaded sensors |
@@ -203,6 +275,25 @@ GNUNET_SENSOR_load_all_sensors (); | |||
203 | char * | 275 | char * |
204 | GNUNET_SENSOR_get_sensor_dir (); | 276 | GNUNET_SENSOR_get_sensor_dir (); |
205 | 277 | ||
278 | /** | ||
279 | * Parses a sensor reading message struct | ||
280 | * | ||
281 | * @param msg message header received | ||
282 | * @param sensors multihashmap of loaded sensors | ||
283 | * @return sensor reading struct or NULL if error | ||
284 | */ | ||
285 | struct GNUNET_SENSOR_Reading * | ||
286 | GNUNET_SENSOR_parse_reading_message (const struct GNUNET_MessageHeader *msg, | ||
287 | struct GNUNET_CONTAINER_MultiHashMap *sensors); | ||
288 | |||
289 | /** | ||
290 | * Destroys a group of sensors in a hashmap and the hashmap itself | ||
291 | * | ||
292 | * @param sensors hashmap containing the sensors | ||
293 | */ | ||
294 | void | ||
295 | GNUNET_SENSOR_destroy_sensors (struct GNUNET_CONTAINER_MultiHashMap *sensors); | ||
296 | |||
206 | #if 0 /* keep Emacsens' auto-indent happy */ | 297 | #if 0 /* keep Emacsens' auto-indent happy */ |
207 | { | 298 | { |
208 | #endif | 299 | #endif |