HAN-FUN API  1.5.3
This project provides the common implementation of ULE Alliance's HAN-FUN application protocol.
hello_msg_t Struct Reference

Hello message payload. More...

+ Collaboration diagram for hello_msg_t:

Public Member Functions

uint16_t size () const
 Number bytes needed to serialize the message. More...
 
uint16_t pack (HF::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 (HF::Common::ByteArray &array, uint16_t offset=0)
 Read a message from a ByteArray. More...
 

Data Fields

uint8_t core
 HAN-FUN Core Services & Interfaces version. More...
 
uint8_t profiles
 HAN-FUN Profiles version. More...
 
uint8_t interfaces
 HAN-FUN Interfaces version. More...
 
HF::UID::UID uid
 Remote device UID. More...
 

Static Public Attributes

static constexpr uint16_t min_size = 3 * sizeof(uint8_t)
 Minimum pack/unpack required data size.
 

Detailed Description

Hello message payload.

Definition at line 142 of file transport.cpp.

Member Function Documentation

◆ pack()

uint16_t hello_msg_t::pack ( HF::Common::ByteArray array,
uint16_t  offset = 0 
) const
inline

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.,

Serializable obj;
ByteArray payload(obj.size());
obj.pack(payload);
Parameters
[in,out]arrayByteArray reference to write the object to.
[in]offsetoffset to start writing to.
Returns
the number of bytes written.

Definition at line 164 of file transport.cpp.

References core, HF_SERIALIZABLE_CHECK, interfaces, HF::UID::UID::pack(), profiles, size(), uid, and HF::Common::ByteArray::write().

165  {
166  HF_SERIALIZABLE_CHECK(array, offset, size());
167 
168  uint16_t start = offset;
169 
170  offset += array.write(offset, core);
171  offset += array.write(offset, profiles);
172  offset += array.write(offset, interfaces);
173 
174  offset += uid.pack(array, offset);
175 
176  return offset - start;
177  }
uint16_t write(uint16_t offset, uint8_t data)
Write a byte into the array at the given offset.
uint8_t core
HAN-FUN Core Services & Interfaces version.
Definition: transport.cpp:144
uint16_t size() const
Number bytes needed to serialize the message.
Definition: transport.cpp:158
uint16_t pack(Common::ByteArray &array, uint16_t offset) const
Write the object on to a ByteArray so it can be sent over the network.
Definition: uids.h:609
#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 t...
uint8_t profiles
HAN-FUN Profiles version.
Definition: transport.cpp:145
uint8_t interfaces
HAN-FUN Interfaces version.
Definition: transport.cpp:146
HF::UID::UID uid
Remote device UID.
Definition: transport.cpp:148
+ Here is the call graph for this function:

◆ size()

uint16_t hello_msg_t::size ( ) const
inline

Number bytes needed to serialize the message.

Returns
number of bytes the message requires to be serialized.

Definition at line 158 of file transport.cpp.

References min_size, HF::UID::UID::size(), and uid.

Referenced by pack().

159  {
160  return min_size + uid.size();
161  }
uint16_t size() const
Number bytes needed to serialize the message.
Definition: uids.h:604
static constexpr uint16_t min_size
Minimum pack/unpack required data size.
Definition: transport.cpp:155
HF::UID::UID uid
Remote device UID.
Definition: transport.cpp:148
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ unpack()

uint16_t hello_msg_t::unpack ( HF::Common::ByteArray array,
uint16_t  offset = 0 
)
inline

Read a message from a ByteArray.

Parameters
[in]arrayByteArray reference to read the message from.
[in]offsetoffset to start reading from.
Returns
the number of bytes read.

Definition at line 180 of file transport.cpp.

References core, HF_SERIALIZABLE_CHECK, interfaces, min_size, profiles, HF::Common::ByteArray::read(), uid, and HF::UID::UID::unpack().

181  {
182  HF_SERIALIZABLE_CHECK(array, offset, min_size);
183 
184  uint16_t start = offset;
185 
186  offset += array.read(offset, core);
187  offset += array.read(offset, profiles);
188  offset += array.read(offset, interfaces);
189 
190  uid.unpack(array, offset);
191 
192  return offset - start;
193  }
uint8_t core
HAN-FUN Core Services & Interfaces version.
Definition: transport.cpp:144
#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 t...
uint8_t profiles
HAN-FUN Profiles version.
Definition: transport.cpp:145
uint8_t interfaces
HAN-FUN Interfaces version.
Definition: transport.cpp:146
uint16_t read(uint16_t offset, uint8_t &data) const
Read the byte at offset into data.
static constexpr uint16_t min_size
Minimum pack/unpack required data size.
Definition: transport.cpp:155
HF::UID::UID uid
Remote device UID.
Definition: transport.cpp:148
uint16_t unpack(const Common::ByteArray &array, uint16_t offset)
Read a message from a ByteArray.
+ Here is the call graph for this function:

Field Documentation

◆ core

uint8_t hello_msg_t::core

HAN-FUN Core Services & Interfaces version.

Definition at line 144 of file transport.cpp.

Referenced by pack(), and unpack().

◆ interfaces

uint8_t hello_msg_t::interfaces

HAN-FUN Interfaces version.

Definition at line 146 of file transport.cpp.

Referenced by pack(), and unpack().

◆ profiles

uint8_t hello_msg_t::profiles

HAN-FUN Profiles version.

Definition at line 145 of file transport.cpp.

Referenced by pack(), and unpack().

◆ uid

HF::UID::UID hello_msg_t::uid

Remote device UID.

Definition at line 148 of file transport.cpp.

Referenced by pack(), size(), and unpack().


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