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

This class contains the required parameters for a SUOTA::UPGRADE_COMPLETE_CMD command. More...

#include <suota.h>

+ Collaboration diagram for HF::Core::SUOTA::UpgradeStatus:

Public Types

enum  Code {
  UPGRADE_SUCCESSFUL = 0x00, UPGRADE_ABORTED = 0x11, GMEP_SESSION_ERROR = 0x12, INVALID_IMAGE = 0x13,
  MEMORY_ACCESS_ERROR = 0x14, BATTERY_TOO_LOW = 0x15, FAIL_UNKNOWN = Common::FAIL_UNKNOWN
}
 Possible status in a. More...
 

Public Member Functions

 UpgradeStatus (Code _code=FAIL_UNKNOWN, std::string _sw_version="")
 Software version after update. 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...
 

Data Fields

std::string sw_version
 Update status.
 

Static Public Attributes

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

Detailed Description

This class contains the required parameters for a SUOTA::UPGRADE_COMPLETE_CMD command.

Definition at line 200 of file suota.h.

Member Enumeration Documentation

◆ Code

Possible status in a.

Enumerator
UPGRADE_SUCCESSFUL 

Upgrade successful.

UPGRADE_ABORTED 

Upgrade aborted.

GMEP_SESSION_ERROR 

GMEP session error.

INVALID_IMAGE 

Invalid image.

MEMORY_ACCESS_ERROR 

Memory access error.

BATTERY_TOO_LOW 

Battery too low.

FAIL_UNKNOWN 

Fail: Unknown Error.

Definition at line 205 of file suota.h.

Constructor & Destructor Documentation

◆ UpgradeStatus()

HF::Core::SUOTA::UpgradeStatus::UpgradeStatus ( Code  _code = FAIL_UNKNOWN,
std::string  _sw_version = "" 
)
inline

Software version after update.

Constructor.

Parameters
[in]_codeupdate status to send in the command.
[in]_sw_versionnew software version of the update.

Definition at line 225 of file suota.h.

225  :
226  code(_code), sw_version(_sw_version) {}
std::string sw_version
Update status.
Definition: suota.h:217

Member Function Documentation

◆ pack()

uint16_t HF::Core::SUOTA::UpgradeStatus::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 240 of file suota.h.

References HF_SERIALIZABLE_CHECK, HF::Common::SerializableHelper< T, typename >::pack(), size(), sw_version, and HF::Common::ByteArray::write().

241  {
242  HF_SERIALIZABLE_CHECK(array, offset, size());
243 
244  uint16_t start = offset;
245 
246  offset += array.write(offset, static_cast<uint8_t>(code));
247 
248  if (!sw_version.empty())
249  {
250  offset +=
252  }
253 
254  return offset - start;
255  }
std::string sw_version
Update status.
Definition: suota.h:217
uint16_t size() const
Number bytes needed to serialize the message.
Definition: suota.h:232
#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(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::UpgradeStatus::size ( ) const
inline

Number bytes needed to serialize the message.

Returns
number of bytes the message requires to be serialized.

Definition at line 232 of file suota.h.

References HF::Common::SerializableHelper< T, typename >::size(), and sw_version.

Referenced by pack().

233  {
234  return sizeof(uint8_t) +
235  (sw_version.empty() ? 0 :
237  }
std::string sw_version
Update status.
Definition: suota.h:217
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::UpgradeStatus::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 258 of file suota.h.

References HF_SERIALIZABLE_CHECK, min_size, HF::Common::ByteArray::read(), sw_version, and HF::Common::SerializableHelper< T, typename >::unpack().

259  {
260  HF_SERIALIZABLE_CHECK(array, offset, min_size);
261 
262  uint16_t start = offset;
263 
264  uint8_t temp;
265  offset += array.read(offset, temp);
266  code = static_cast<Code>(temp);
267 
269 
270  return offset - start;
271  }
std::string sw_version
Update status.
Definition: suota.h:217
static constexpr uint16_t min_size
Minimum pack/unpack required data size.
Definition: suota.h:229
uint16_t unpack(const ByteArray &array, uint16_t offset=0)
Read a message from a ByteArray.
#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...
Code
Possible status in a.
Definition: suota.h:205
+ Here is the call graph for this function:

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