Wiselib
|
A basic managed sensor concept. More...
Inherits concepts::BasicSensor_concept.
Public Types | |
enum | StateData { READY = ..., NO_VALUE = ..., INACTIVE = ... } |
State data. More... | |
Public Member Functions | |
char * | name () |
Return null-terminated character array that (roughly) describes the sensor. | |
char * | encoded_value () |
Return encoded sensor packet as described above. | |
int | state () |
Returns the current state. | |
Public Attributes | |
typedef | OsModel |
Type of Os Concept which has been set for the sensor facet. | |
typedef | value_t |
Type of value that is returned. |
A basic managed sensor concept.
A managed sensor refines the basic sensor, and provides methods to handle generic sensor types. It offers a name (as a human readable identifier, as char*), and a generic sensor representation as a char*.
The purpose of this concept is to create a standardized method of sending sensor values to a gateway station - being able to read values of any type. We therefore define a simple and efficient packet format, consisting of three fields: The first field (1 byte) defines the value type, the second field (1 byte) the length of the payload, and the third field contains the encoded sensor value (dynamic length depending on the value).
For the encoding of the sensor values, Wiselib Serialization should be used. That means, values are always encoded in network byte order (big-endian). However, there are also peculiarities for some data types that must be considered. Char pointers do not need to be null-terminated, since the packet contains a separate length field. When dealing with floating point values, usually both single and double have a length of 4 bytes - this is due to the fact that on some compilers (e.g., msp430-gcc 3.2.3), double values have only a length of 4 bytes. This is stated to preserve platform independence, also when a managed sensor is read out on a restricted platform (e.g. when using msp430-gcc 3.2.3). However, if wanted, there is an own encoding type for standard 8-byte-long double values.
enum concepts::BasicSensor_concept::StateData [inherited] |
char* concepts::ManagedSensor_concept::encoded_value | ( | ) |
Return encoded sensor packet as described above.
char* concepts::ManagedSensor_concept::name | ( | ) |
Return null-terminated character array that (roughly) describes the sensor.
E.g., "temp\0" for a temperature sensor.
int concepts::BasicSensor_concept::state | ( | ) | [inherited] |
Returns the current state.
typedef concepts::BasicSensor_concept::OsModel [inherited] |
Type of Os Concept which has been set for the sensor facet.
typedef concepts::BasicSensor_concept::value_t [inherited] |
Type of value that is returned.