HAN-FUN API  1.5.3
This project provides the common implementation of ULE Alliance's HAN-FUN application protocol.
HF::Core::SUOTA::CheckVersionResponse Struct Reference

This class represents the message for the response of a SUOTA::CHECK_VERSION_CMD. More...

#include <suota.h>

+ Inheritance diagram for HF::Core::SUOTA::CheckVersionResponse:
+ Collaboration diagram for HF::Core::SUOTA::CheckVersionResponse:

Public Types

enum  Status { VERSION_AVAILABLE = 0x00, NO_VERSION_AVAILABLE = 0x11, FAIL_INFRASTUCTURE = 0x12, FAIL_UNKNOWN = Common::FAIL_UNKNOWN }
 Possible result codes for a SUOTA::CHECK_VERSION_CMD. More...
 

Public Member Functions

 CheckVersionResponse (Status _status=FAIL_UNKNOWN, const std::string _sw_version="", const std::string _hw_version="", const std::string _url="")
 Constructor. 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...
 
- Public Member Functions inherited from HF::Protocol::Response
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...
 
- Public Member Functions inherited from HF::Core::SUOTA::Version
 Version (const std::string _sw_version="", const std::string _hw_version="", const std::string _url="")
 Constructor. 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...
 

Static Public Attributes

static constexpr uint16_t min_size = Protocol::Response::min_size + Version::min_size
 Minimum pack/unpack required data size.
 
- Static Public Attributes inherited from HF::Protocol::Response
static constexpr uint16_t min_size = sizeof(uint8_t)
 Minimum number of bytes required by this message.
 
- Static Public Attributes inherited from HF::Core::SUOTA::Version
static constexpr uint16_t min_size = 2 * sizeof(uint8_t)
 Minimum pack/unpack required data size.
 

Additional Inherited Members

- Data Fields inherited from HF::Core::SUOTA::Version
std::string sw_version
 Current/Available software version. More...
 
std::string hw_version
 Current/Minimum required hardware version. More...
 
std::string url
 Update URL. More...
 

Detailed Description

This class represents the message for the response of a SUOTA::CHECK_VERSION_CMD.

Definition at line 127 of file suota.h.

Member Enumeration Documentation

◆ Status

Possible result codes for a SUOTA::CHECK_VERSION_CMD.

Enumerator
VERSION_AVAILABLE 

New version available.

NO_VERSION_AVAILABLE 

No newer version available.

FAIL_INFRASTUCTURE 

Server or Network are down.

FAIL_UNKNOWN 

Fail: Unknown Error.

Definition at line 132 of file suota.h.

133  {
134  VERSION_AVAILABLE = 0x00,
135  NO_VERSION_AVAILABLE = 0x11,
136  FAIL_INFRASTUCTURE = 0x12,
138  } Status;
Fail - Unknown reason.
Status
Possible result codes for a SUOTA::CHECK_VERSION_CMD.
Definition: suota.h:132

Constructor & Destructor Documentation

◆ CheckVersionResponse()

HF::Core::SUOTA::CheckVersionResponse::CheckVersionResponse ( Status  _status = FAIL_UNKNOWN,
const std::string  _sw_version = "",
const std::string  _hw_version = "",
const std::string  _url = "" 
)
inline

Constructor.

Parameters
[in]_statusresponse status to send (M)
[in]_sw_versionsoftware version to send (M)
[in]_hw_versionhardware version to send (M)
[in]_urlupdate URL (O)

Definition at line 148 of file suota.h.

149  :
150  Protocol::Response(_status),
151  Version(_sw_version, _hw_version, _url) {}
Version(const std::string _sw_version="", const std::string _hw_version="", const std::string _url="")
Constructor.
Definition: suota.h:104

Member Function Documentation

◆ pack()

uint16_t HF::Core::SUOTA::CheckVersionResponse::pack ( 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 166 of file suota.h.

References HF_SERIALIZABLE_CHECK, HF::Core::SUOTA::Version::pack(), HF::Protocol::Response::pack(), and size().

167  {
168  HF_SERIALIZABLE_CHECK(array, offset, size());
169 
170  uint16_t start = offset;
171 
172  offset += Protocol::Response::pack(array, offset);
173  offset += Version::pack(array, offset);
174 
175  return offset - start;
176  }
uint16_t size() const
Number bytes needed to serialize the message.
Definition: suota.h:160
#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...
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.
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.
+ Here is the call graph for this function:

◆ size()

uint16_t HF::Core::SUOTA::CheckVersionResponse::size ( ) const
inline

Number bytes needed to serialize the message.

Returns
number of bytes the message requires to be serialized.

Definition at line 160 of file suota.h.

References HF::Core::SUOTA::Version::size(), and HF::Protocol::Response::size().

Referenced by pack(), and unpack().

161  {
163  }
uint16_t size() const
Number bytes needed to serialize the message.
uint16_t size() const
Number bytes needed to serialize the message.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ unpack()

uint16_t HF::Core::SUOTA::CheckVersionResponse::unpack ( const 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 179 of file suota.h.

References HF_ASSERT, HF_SERIALIZABLE_CHECK, min_size, size(), HF::Core::SUOTA::Version::unpack(), and HF::Protocol::Response::unpack().

180  {
181  HF_SERIALIZABLE_CHECK(array, offset, min_size);
182 
183  uint16_t start = offset;
184 
185  uint16_t size = Protocol::Response::unpack(array, offset);
186  HF_ASSERT(size != 0, {return 0;});
187  offset += size;
188  size = Version::unpack(array, offset);
189  HF_ASSERT(size != 0, {return 0;});
190  offset += size;
191 
192  return offset - start;
193  }
uint16_t size() const
Number bytes needed to serialize the message.
Definition: suota.h:160
#define HF_ASSERT(_expr, _block)
Helper macro to check for correct assumptions.
#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...
uint16_t unpack(const Common::ByteArray &array, uint16_t offset=0)
Read a message from a ByteArray.
uint16_t unpack(const Common::ByteArray &array, uint16_t offset=0)
Read a message from a ByteArray.
static constexpr uint16_t min_size
Minimum pack/unpack required data size.
Definition: suota.h:157
+ Here is the call graph for this function:

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