The friendly Operating System for the Internet of Things
phydat.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2015 Freie Universit├Ąt Berlin
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v2.1. See the file LICENSE in the top level
6  * directory for more details.
7  */
8 
35 #ifndef SECT_DATA_H
36 #define SECT_DATA_H
37 
38 #include <stdint.h>
39 #include <errno.h>
40 
41 #ifdef __cplusplus
42 extern "C" {
43 #endif
44 
56 #define PHYDAT_DIM (3U)
57 
61 #define PHYDAT_SCALE_STR_MAXLEN (sizeof("*E-128\0"))
62 
74 enum {
75  /* generic values */
78  /* temperature */
82  /* illuminance */
84  /* dimension */
88  /* kinetic */
91  /* weight */
94  /* electricity */
98  /* pressure */
101  /* light */
103  /* logical */
108  /* aggregate values */
111  /* extend this list as needed */
112 };
113 
135 typedef struct {
136  int16_t val[PHYDAT_DIM];
137  uint8_t unit;
138  int8_t scale;
139 } phydat_t;
140 
147 void phydat_dump(phydat_t *data, uint8_t dim);
148 
157 const char *phydat_unit_to_str(uint8_t unit);
158 
168 char phydat_scale_to_str(int8_t scale);
169 
170 #ifdef __cplusplus
171 }
172 #endif
173 
174 #endif /* SECT_DATA_H */
175 
square meters
Definition: phydat.h:86
#define PHYDAT_DIM
The fixed number of dimensions we work with.
Definition: phydat.h:56
cubic meters
Definition: phydat.h:87
Ampere.
Definition: phydat.h:95
const char * phydat_unit_to_str(uint8_t unit)
Convert the given unit to a string.
Candela.
Definition: phydat.h:102
Pascal.
Definition: phydat.h:100
the three dimensions contain sec, min, and hours
Definition: phydat.h:109
meters
Definition: phydat.h:85
Volts.
Definition: phydat.h:96
the 3 dimensions contain days, months and years
Definition: phydat.h:110
char phydat_scale_to_str(int8_t scale)
Convert the given scale factor to a NULL terminated string.
degree per second
Definition: phydat.h:90
Generic data structure for expressing physical values.
Definition: phydat.h:135
Lux (lx)
Definition: phydat.h:83
degree Celsius
Definition: phydat.h:79
out of 100
Definition: phydat.h:105
void phydat_dump(phydat_t *data, uint8_t dim)
Dump the given data container to STDIO.
Kelvin.
Definition: phydat.h:81
uint8_t unit
the (physical) unit of the data
Definition: phydat.h:137
grams - not using the SI unit (kg) here to make scale handling simpler
Definition: phydat.h:92
boolean value [0|1]
Definition: phydat.h:104
Beer?
Definition: phydat.h:99
out of 1000
Definition: phydat.h:106
data has no physical unit
Definition: phydat.h:77
int8_t scale
the scale factor, 10^*scale*
Definition: phydat.h:138
degree Fahrenheit
Definition: phydat.h:80
part per million
Definition: phydat.h:107
gauss
Definition: phydat.h:97
unit undefined
Definition: phydat.h:76
gravitational force
Definition: phydat.h:89