![]() |
HAN-FUN API
1.5.3
This project provides the common implementation of ULE Alliance's HAN-FUN application protocol.
|
#include <protocol.h>
Inherited by HF::Core::BatchProgramManagement::Action.
Data Structures | |
struct | Interface |
Interface Address. More... | |
Public Types | |
enum | Type { COMMAND_REQ = 0x01, COMMAND_RESP_REQ = 0x02, COMMAND_RES = 0x03, GET_ATTR_REQ = 0x04, GET_ATTR_RES = 0x05, SET_ATTR_REQ = 0x06, SET_ATTR_RESP_REQ = 0x07, SET_ATTR_RES = 0x08, GET_ATTR_PACK_REQ = 0x09, GET_ATTR_PACK_RES = 0x0A, SET_ATTR_PACK_REQ = 0x0B, SET_ATTR_PACK_RESP_REQ = 0x0C, SET_ATTR_PACK_RES = 0x0D, ATOMIC_SET_ATTR_PACK_REQ = 0x0E, ATOMIC_SET_ATTR_PACK_RESP_REQ = 0x0F, ATOMIC_SET_ATTR_PACK_RES = 0x10 } |
Message types. More... | |
Public Member Functions | |
Message (uint16_t size=0, Type _type=COMMAND_REQ) | |
Constructor. More... | |
Message (const Message &parent, uint16_t size) | |
Create a new message that is a response to the given message in parent . More... | |
uint16_t | size () const |
Number bytes needed to serialize the message. More... | |
uint16_t | pack (Common::ByteArray &array, uint16_t offset=0) const |
Write the object on to a ByteArray so it can be sent over the network. More... | |
uint16_t | unpack (const Common::ByteArray &array, uint16_t offset=0) |
Read a message from a ByteArray. More... | |
bool | isCommand () const |
Check if message type is equal to COMMAND_REQ or to COMMAND_RESP_REQ . More... | |
bool | isCommandResponse () const |
Check if message type is equal to COMMAND_RES . More... | |
Data Fields | |
uint8_t | reference |
Application reference. More... | |
Type | type |
Message type. More... | |
Interface | itf |
Interface Address. More... | |
Common::ByteArray | payload |
Message payload. | |
uint16_t | length |
The payload length value read when unpacking the message. | |
Static Public Attributes | |
static constexpr uint16_t | min_size |
Minimum pack/unpack required data size. | |
Network Message.
Definition at line 60 of file protocol.h.
Message types.
Enumerator | |
---|---|
COMMAND_REQ | Command request. |
COMMAND_RESP_REQ | Command request with response required. |
COMMAND_RES | Command response. |
GET_ATTR_REQ | Get attributes request. |
GET_ATTR_RES | Get attributes response. |
SET_ATTR_REQ | Set attributes request. |
SET_ATTR_RESP_REQ | Set attributes request with response required. |
SET_ATTR_RES | Set attributes response. |
GET_ATTR_PACK_REQ | Get pack attributes request. |
GET_ATTR_PACK_RES | Get pack attributes response. |
SET_ATTR_PACK_REQ | Set pack attributes request. |
SET_ATTR_PACK_RESP_REQ | Set pack attributes request with response required. |
SET_ATTR_PACK_RES | Set pack attributes response. |
ATOMIC_SET_ATTR_PACK_REQ | Atomic set pack attributes request. |
ATOMIC_SET_ATTR_PACK_RESP_REQ | Atomic set pack attributes request with response required. |
ATOMIC_SET_ATTR_PACK_RES | Atomic set pack attributes response. |
Definition at line 65 of file protocol.h.
|
inline |
Constructor.
[in] | size | message payload size. |
[in] | _type | message type. |
Definition at line 145 of file protocol.h.
References HF::Protocol::MAX_PAYLOAD, and size().
HF::Protocol::Message::Message | ( | const Message & | parent, |
uint16_t | size | ||
) |
Create a new message that is a response to the given message in parent
.
parent
is already a response then the new message has the same type.[in] | parent | reference to the message to create a response for. |
[in] | size | size of the payload buffer. |
bool HF::Protocol::Message::isCommand | ( | ) | const |
Check if message type is equal to COMMAND_REQ
or to COMMAND_RESP_REQ
.
true | if message type is equal to COMMAND_REQ or to COMMAND_RESP_REQ . |
false | otherwise. |
bool HF::Protocol::Message::isCommandResponse | ( | ) | const |
Check if message type is equal to COMMAND_RES
.
true | if message type is equal to COMMAND_RES .. |
false | otherwise. |
uint16_t HF::Protocol::Message::pack | ( | Common::ByteArray & | array, |
uint16_t | offset = 0 |
||
) | const |
Write the object on to a ByteArray so it can be sent over the network.
The buffer passed in MUST have enough size to hold the serialized object, e.g.,
[in,out] | array | ByteArray reference to write the object to. |
[in] | offset | offset to start writing to. |
uint16_t HF::Protocol::Message::size | ( | ) | const |
Number bytes needed to serialize the message.
Referenced by Message().
uint16_t HF::Protocol::Message::unpack | ( | const Common::ByteArray & | array, |
uint16_t | offset = 0 |
||
) |
Read a message from a ByteArray.
[in] | array | ByteArray reference to read the message from. |
[in] | offset | offset to start reading from. |
array
into the payload
field in this object. Interface HF::Protocol::Message::itf |
Definition at line 129 of file protocol.h.
Referenced by HF::Core::SessionManagement::AbstractClient::get_entries(), HF::Interfaces::Container< HF::Units::Unit< HF::Profiles::SimpleOnOffSwitch, ITF... >, Proxy< ITF, HF::Units::Unit< HF::Profiles::SimpleOnOffSwitch, ITF... > >... >::handle(), HF::Interfaces::SimpleHumidity::Client::read(), HF::Interfaces::SimpleTemperature::Client::read(), HF::Interfaces::SimpleLightSensor::Client::read(), and HF::Core::SessionManagement::AbstractClient::request().
uint8_t HF::Protocol::Message::reference |
Application reference.
Definition at line 126 of file protocol.h.
Type HF::Protocol::Message::type |
Message type.
Definition at line 127 of file protocol.h.
Referenced by HF::Interfaces::SimpleHumidity::Client::read(), HF::Interfaces::SimpleTemperature::Client::read(), and HF::Interfaces::SimpleLightSensor::Client::read().