![]() |
HAN-FUN API
1.5.3
This project provides the common implementation of ULE Alliance's HAN-FUN application protocol.
|
This module contains common helper classes, functions and definitions. More...
Data Structures | |
struct | HF::Common::ByteArray |
This class represents a byte array. More... | |
struct | HF::Common::Serializable |
This represents the common interface for message serialization. More... | |
struct | HF::Common::SerializableHelper< T, typename > |
Wrapper for classes that implement the Serializable concept. More... | |
struct | HF::Common::SerializableHelper< T, EnableIf(IsClassPointer(T))> |
Wrapper to pointers for classes that implement the Serializable concept. More... | |
struct | HF::Common::SerializableHelper< T, EnableIf(IsIntegral(T))> |
Wrapper for base integer types implementing the Serializable API. More... | |
struct | HF::Common::SerializableHelper< Common::ByteArray > |
Wrapper for Common::ByteArray implementing the Serializable API. More... | |
struct | HF::Common::SerializableHelper< std::string > |
Wrapper for std::string implementing the Serializable API. More... | |
struct | HF::Common::SerializableHelper< std::vector< uint8_t > > |
Wrapper for std::vector implementing the Serializable API. More... | |
struct | HF::Common::Cloneable< T > |
This class represents the interface that cloneable objects need to implement. More... | |
struct | HF::Common::Interface |
Interface UID. More... | |
class | HF::Common::Pointer< T > |
Simple raw pointer wrapper. More... | |
struct | HF::Common::IEntries< T > |
Basic API for persistent storage implementations. More... | |
Macros | |
#define | UNUSED(x) (void) x |
Helper macro to remove warning about unused function/method argument. | |
#define | HF_SERIALIZABLE_CHECK(__array, __offset, __size) |
Helper macro to check if the given __array has enough size so __size bytes can be written/read from the given __offset . More... | |
#define | HF_NOTIFY_HELPER(_Type, _old_value, _new_value) |
Helper macro to implement attribute notifications. More... | |
#define | HF_SETTER_HELPER(_Type, _name, _value) |
Helper macro to implement attribute setters. More... | |
#define | HF_ASSERT(_expr, _block) |
Helper macro to check for correct assumptions. More... | |
Enumerations | |
enum | HF::Common::Precision { HF::Common::BASE = 0x00, HF::Common::MILI = 0x10, HF::Common::MICRO = 0x11, HF::Common::NANO = 0x12, HF::Common::PICO = 0x13, HF::Common::KILO = 0x20, HF::Common::MEGA = 0x21, HF::Common::GIGA = 0x22, HF::Common::TERA = 0x23 } |
These constants represent precisions that a measurement can be in. More... | |
enum | HF::Common::Time { HF::Common::UPTIME = 0x00, HF::Common::UTC = 0x01 } |
This represents the type of time that is associated with a time measurement. More... | |
enum | HF::Common::Result { HF::Common::OK = 0x00, HF::Common::FAIL_AUTH = 0x01, HF::Common::FAIL_ARG = 0x02, HF::Common::FAIL_SUPPORT = 0x03, HF::Common::FAIL_RO_ATTR = 0x04, HF::Common::FAIL_READ_SESSION = 0x20, HF::Common::FAIL_MODIFIED = 0x21, HF::Common::FAIL_RESOURCES = 0xFE, HF::Common::FAIL_UNKNOWN = 0xFF } |
Commands result codes. More... | |
Functions | |
template<typename T , typename P = float> | |
T | HF::Common::from_percent (P value) |
Convert a percentage value into the [0,std::numeric_limits<T>::max()] range. More... | |
template<typename T , typename P = float> | |
P | HF::Common::to_percent (T value) |
Convert a value in the [0,std::numeric_limits<T>::max()] range into a percentage. More... | |
std::ostream & | operator<< (std::ostream &stream, const uint8_t byte) |
Convert the given byte into a string and write it to the given stream . More... | |
std::ostream & | operator<< (std::ostream &stream, const HF::Common::ByteArray &array) |
Convert the given packet into a string and write it to the given stream if stream == std::cout || stream == std::cerr . More... | |
std::ostream & | operator<< (std::ostream &stream, const HF::Common::Interface interface) |
Convert the given interface into a string and write it to the given stream . More... | |
Variables | |
constexpr uint8_t | HF::CORE_VERSION = 2 |
Core Service & Interfaces major version supported. More... | |
constexpr uint8_t | HF::PROFILES_VERSION = 1 |
Profiles major version supported. More... | |
constexpr uint8_t | HF::INTERFACES_VERSION = 1 |
Interfaces major version supported. More... | |
This module contains common helper classes, functions and definitions.
#define HF_ASSERT | ( | _expr, | |
_block | |||
) |
Helper macro to check for correct assumptions.
_expr
twice.[in] | _expr | helper class that wraps the attribute. |
[in] | _block | code block to run if the condition fails. |
Definition at line 125 of file inc/hanfun/common.h.
Referenced by HF::Interfaces::SimpleVisualEffects::BlinkEffect::pack(), HF::Interfaces::SimpleVisualEffects::BreatheEffect::pack(), HF::Core::GroupManagement::Group::reserve(), HF::Core::Time::Server::tick(), HF::Interfaces::SimpleVisualEffects::BlinkEffect::unpack(), HF::Core::SUOTA::CheckVersionResponse::unpack(), HF::Core::Scheduling::Entry< _Type >::unpack(), and HF::Interfaces::SimpleVisualEffects::BreatheEffect::unpack().
#define HF_NOTIFY_HELPER | ( | _Type, | |
_old_value, | |||
_new_value | |||
) |
Helper macro to implement attribute notifications.
[in] | _Type | helper class that wraps the attribute. |
[in] | _old_value | the previous value of the attribute. |
[in] | _new_value | the current value of the attribute. |
Definition at line 88 of file inc/hanfun/common.h.
#define HF_SERIALIZABLE_CHECK | ( | __array, | |
__offset, | |||
__size | |||
) |
Helper macro to check if the given __array
has enough size so __size
bytes can be written/read from the given __offset
.
return 0;
when there aren't enough resources, i.e. the __array
size is not sufficient for reading/writing to.[in] | __array | reference to the ByteArray containing the data. |
[in] | __offset | offset index to check available data from. |
[in] | __size | number of bytes required. |
Definition at line 74 of file inc/hanfun/common.h.
Referenced by msg_t::pack(), HF::Interfaces::SimpleVisualEffects::OnEffect::pack(), HF::UID::UID_T::pack(), HF::Core::SessionManagement::GetEntriesMessage::pack(), HF::UID::NONE::pack(), HF::Interfaces::SimpleVisualEffects::BlinkEffect::pack(), hello_msg_t::pack(), HF::Core::SUOTA::CheckVersionResponse::pack(), HF::Interfaces::SimplePowerMeter::Measurement::pack(), HF::Core::GroupTable::Response::pack(), HF::Interfaces::SimpleVisualEffects::FadeEffect::pack(), HF::UID::ByteArray< MAC, 6, MAC_UID >::pack(), HF::Core::Scheduling::Entry< _Type >::pack(), HF::Core::SUOTA::UpgradeStatus::pack(), HF::Core::GroupTable::ReadEntries::pack(), HF::Interfaces::SimpleVisualEffects::BreatheEffect::pack(), HF::Core::GroupTable::ReadEntriesResponse::pack(), HF::Core::Scheduling::GetEntryResponse< _Type >::pack(), HF::Attributes::Attribute< bool >::pack(), HF::UID::URI::pack(), HF::Common::SerializableHelper< bool >::pack(), HF::Common::SerializableHelper< T, EnableIf(IsClassPointer(T))>::pack(), HF::Common::SerializableHelper< T, EnableIf(IsIntegral(T))>::pack(), HF::Attributes::Attribute< T, _Owner, EnableIf(IsParent(HF::Interface, _Owner))>::pack(), HF::Common::SerializableHelper< Common::ByteArray >::pack(), HF::Common::SerializableHelper< std::vector< uint8_t > >::pack(), HF::Protocol::SetAttributePack::Response::Result::pack(), HF::Interfaces::SimpleVisualEffects::OnEffect::unpack(), msg_t::unpack(), HF::UID::UID_T::unpack(), HF::Core::SessionManagement::GetEntriesMessage::unpack(), HF::UID::NONE::unpack(), HF::Interfaces::SimpleVisualEffects::BlinkEffect::unpack(), HF::Core::SUOTA::CheckVersionResponse::unpack(), HF::Interfaces::SimplePowerMeter::Measurement::unpack(), hello_msg_t::unpack(), HF::Core::GroupTable::Response::unpack(), HF::Interfaces::SimpleVisualEffects::FadeEffect::unpack(), HF::Attributes::UIDS::unpack(), HF::UID::ByteArray< MAC, 6, MAC_UID >::unpack(), HF::Core::Scheduling::Entry< _Type >::unpack(), HF::Core::GroupTable::ReadEntries::unpack(), HF::Core::SUOTA::UpgradeStatus::unpack(), HF::Interfaces::SimpleVisualEffects::BreatheEffect::unpack(), HF::Core::GroupTable::ReadEntriesResponse::unpack(), HF::Core::Scheduling::GetEntryResponse< _Type >::unpack(), HF::Attributes::Attribute< bool >::unpack(), HF::UID::URI::unpack(), HF::Common::SerializableHelper< bool >::unpack(), HF::Common::SerializableHelper< T, EnableIf(IsClassPointer(T))>::unpack(), HF::Common::SerializableHelper< T, EnableIf(IsIntegral(T))>::unpack(), HF::Attributes::Attribute< T, _Owner, EnableIf(IsParent(HF::Interface, _Owner))>::unpack(), HF::Common::SerializableHelper< Common::ByteArray >::unpack(), HF::Common::SerializableHelper< std::vector< uint8_t > >::unpack(), and HF::Protocol::SetAttributePack::Response::Result::unpack().
#define HF_SETTER_HELPER | ( | _Type, | |
_name, | |||
_value | |||
) |
Helper macro to implement attribute setters.
[in] | _Type | helper class that wraps the attribute. |
[in] | _name | name of the attribute to generate the setter for. |
[in] | _value | name of the variable containing the new value. |
Definition at line 105 of file inc/hanfun/common.h.
These constants represent precisions that a measurement can be in.
Enumerator | |
---|---|
BASE | Base unit. |
MILI | Mili. |
MICRO | Micro. |
NANO | Nano. |
PICO | Pico. |
KILO | Kilo. |
MEGA | Mega. |
GIGA | Giga. |
TERA | Tera. |
Definition at line 210 of file inc/hanfun/common.h.
enum HF::Common::Result |
Commands result codes.
Definition at line 1107 of file inc/hanfun/common.h.
enum HF::Common::Time |
This represents the type of time that is associated with a time measurement.
Enumerator | |
---|---|
UPTIME | Uptime. |
UTC | UTC time. |
Definition at line 227 of file inc/hanfun/common.h.
T HF::Common::from_percent | ( | P | value | ) |
Convert a percentage value into the [0,std::numeric_limits<T>::max()] range.
[in] | value | the percentage value to convert. |
T | integer type to convert to. |
Definition at line 1346 of file inc/hanfun/common.h.
std::ostream& operator<< | ( | std::ostream & | stream, |
const uint8_t | byte | ||
) |
Convert the given byte
into a string and write it to the given stream
.
[in] | stream | out stream to write the string to. |
[in] | byte | byte value to convert to a string. |
stream
std::ostream& operator<< | ( | std::ostream & | stream, |
const HF::Common::ByteArray & | array | ||
) |
Convert the given packet
into a string and write it to the given stream
if stream == std::cout || stream == std::cerr
.
Otherwise send bytes to stream.
[in] | stream | out stream to write the string/bytes to. |
[in] | array | byte array to convert to a string/sent to the stream. |
stream
std::ostream& operator<< | ( | std::ostream & | stream, |
const HF::Common::Interface | interface | ||
) |
Convert the given interface
into a string and write it to the given stream
.
[in] | stream | out stream to write the string to. |
[in] | interface | interface value to convert to a string. |
stream
P HF::Common::to_percent | ( | T | value | ) |
Convert a value in the [0,std::numeric_limits<T>::max()] range into a percentage.
[in] | value | the value to convert to the percentage. |
T | integer type to convert from. |
Definition at line 1362 of file inc/hanfun/common.h.
constexpr uint8_t HF::CORE_VERSION = 2 |
Core Service & Interfaces major version supported.
Definition at line 151 of file inc/hanfun/common.h.
constexpr uint8_t HF::INTERFACES_VERSION = 1 |
Interfaces major version supported.
Definition at line 153 of file inc/hanfun/common.h.
constexpr uint8_t HF::PROFILES_VERSION = 1 |
Profiles major version supported.
Definition at line 152 of file inc/hanfun/common.h.