Aruna
aruna::sensor::water_status_t Struct Reference

#include <Water.h>

Inheritance diagram for aruna::sensor::water_status_t:
Collaboration diagram for aruna::sensor::water_status_t:

Public Member Functions

void update_description (uint8_t water_level)
 updates description with water level. More...
 
void encode (uint8_t *buffer) override
 
void decode (uint8_t *to_decode) override
 
uint8_t get_encode_size () override
 
 water_status_t ()
 water-specific SIS status More...
 
- Public Member Functions inherited from aruna::sis::status_t
 status_t (type_t type)
 
virtual ~status_t ()
 

Public Attributes

char location [7] = "NOTDEV"
 
uint8_t water_level_mm = 0
 
- Public Attributes inherited from aruna::sis::status_t
level_t level = level_t::NOTIFY
 
char description [32]
 
type_t type
 

Detailed Description

Definition at line 15 of file Water.h.

Constructor & Destructor Documentation

◆ water_status_t()

water_status_t::water_status_t ( )

water-specific SIS status

Definition at line 68 of file Water.cpp.

68  : status_t(type_t::WATER) {
69 }
status_t(type_t type)
Definition: sisTypes.h:43

Member Function Documentation

◆ decode()

void water_status_t::decode ( uint8_t *  to_decode)
overridevirtual

Reimplemented from aruna::sis::status_t.

Definition at line 56 of file Water.cpp.

56  {
57  status_t::decode(to_decode);
58  uint8_t start_byte = status_t::get_encode_size();
59  water_level_mm = to_decode[start_byte];
60 // TODO decoding of location is not always correct.
61  memcpy(location, (char *) &to_decode[start_byte + 2], to_decode[start_byte + 1]);
62 }

◆ encode()

void water_status_t::encode ( uint8_t *  buffer)
overridevirtual

Reimplemented from aruna::sis::status_t.

Definition at line 47 of file Water.cpp.

47  {
48 // standard encoding
49  status_t::encode(buffer);
50  uint8_t start_byte = status_t::get_encode_size();
51  buffer[start_byte] = water_level_mm;
52  buffer[start_byte + 1] = strlen(location);
53  memcpy((char *) &buffer[start_byte + 2], location, strlen(location));
54 }

◆ get_encode_size()

uint8_t water_status_t::get_encode_size ( )
overridevirtual

Reimplemented from aruna::sis::status_t.

Definition at line 64 of file Water.cpp.

64  {
65  return status_t::get_encode_size() + strlen(location) + 2;
66 }

◆ update_description()

void water_status_t::update_description ( uint8_t  water_level)

updates description with water level.

Parameters
water_level,uint_8current water level

Definition at line 43 of file Water.cpp.

43  {
44  snprintf(description, sizeof(description), "%imm water in %s", water_level, location);
45 }
char description[32]
Definition: sisTypes.h:40
Here is the caller graph for this function:

Member Data Documentation

◆ location

char aruna::sensor::water_status_t::location[7] = "NOTDEV"

Definition at line 18 of file Water.h.

◆ water_level_mm

uint8_t aruna::sensor::water_status_t::water_level_mm = 0

Definition at line 20 of file Water.h.


The documentation for this struct was generated from the following files: