![]() |
HAN-FUN API
1.5.3
This project provides the common implementation of ULE Alliance's HAN-FUN application protocol.
|
This class represents a byte array. More...
#include <common.h>
Inherits std::vector< T >.
Public Member Functions | |
ByteArray (uint16_t size=0) | |
Create a byte array with the given initial size. More... | |
ByteArray (const uint8_t data[], const uint16_t size) | |
Create a byte array with the given initial data. More... | |
ByteArray (std::initializer_list< uint8_t > raw) | |
Create byte array from the values in the given list. More... | |
virtual | ~ByteArray () |
Destructor. | |
uint16_t | write (uint16_t offset, uint8_t data) |
Write a byte into the array at the given offset . More... | |
uint16_t | write (uint16_t offset, uint16_t data) |
Write a word in the big endian format into the array at the given offset . More... | |
uint16_t | write (uint16_t offset, uint32_t data) |
Write a double-word in big endian format into the array at the given offset . More... | |
uint16_t | write (uint16_t offset, bool data) |
Write a byte into the array at the given offset . (uint16_t, uint8_t) More... | |
template<typename T > | |
uint16_t | write (uint16_t offset, T data) |
Write a byte into the array at the given offset . (uint16_t, uint8_t) More... | |
uint16_t | read (uint16_t offset, uint8_t &data) const |
Read the byte at offset into data . More... | |
uint16_t | read (uint16_t offset, uint16_t &data) const |
Read the word in big-endian format at offset into data . More... | |
uint16_t | read (uint16_t offset, uint32_t &data) const |
Read the double-word in big-endian format at offset into data . More... | |
uint16_t | read (uint16_t offset, bool &data) const |
Read the byte at offset into data . (uint16_t, uint8_t) More... | |
template<typename T > | |
uint16_t | read (uint16_t offset, T &data) const |
Read the byte at offset into data . (uint16_t, uint8_t) More... | |
bool | available (uint16_t offset, uint16_t expected) const |
Check if the array as at least expected bytes available from the given offset . More... | |
uint16_t | available (uint16_t offset) const |
Return the number of data bytes available from the given offset . More... | |
void | extend (uint16_t _size) |
Extend the byte array by the given size. More... | |
void | ensure (uint16_t _offset, uint16_t _size) |
Ensure that the byte array can hold the number of bytes given in _size , from the given offset . More... | |
This class represents a byte array.
The method in this class are used to serialize the messages to be sent over the network, converting between the host's endianness and the big-endian network format.
Definition at line 239 of file inc/hanfun/common.h.
HF::Common::ByteArray::ByteArray | ( | uint16_t | size = 0 | ) |
Create a byte array with the given initial size.
[in] | size | the initial size of the byte array. |
HF::Common::ByteArray::ByteArray | ( | const uint8_t | data[], |
const uint16_t | size | ||
) |
Create a byte array with the given initial data.
[in] | data | data to initialize the byte array with. |
[in] | size | size in bytes of the data. |
|
inline |
Create byte array from the values in the given list.
[in] | raw | values to add to the byte array. |
Definition at line 261 of file inc/hanfun/common.h.
|
inline |
Check if the array as at least expected
bytes available from the given offset
.
[in] | offset | the offset from where to start counting. |
[in] | expected | the number of byte required. |
true | if enough data is available, |
false | otherwise. |
Definition at line 377 of file inc/hanfun/common.h.
Referenced by ensure().
|
inline |
Return the number of data bytes available from the given offset
.
[in] | offset | the offset from where to start counting. |
offset
. Definition at line 389 of file inc/hanfun/common.h.
|
inline |
Ensure that the byte array can hold the number of bytes given in _size
, from the given offset
.
[in] | _offset | offset index to check from. |
[in] | _size | number of bytes to ensure that exist. |
Definition at line 424 of file inc/hanfun/common.h.
References available().
|
inline |
Extend the byte array by the given size.
This is the same as calling : array.reserve(array.size() + _size)
[in] | _size | number of bytes to extent the array by. |
Definition at line 412 of file inc/hanfun/common.h.
uint16_t HF::Common::ByteArray::read | ( | uint16_t | offset, |
uint8_t & | data | ||
) | const |
Read the byte at offset
into data
.
[in] | offset | offset to read the byte from. |
[out] | data | reference to save the read value to. |
Referenced by read(), 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::Interfaces::SimplePowerMeter::Measurement::unpack(), hello_msg_t::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::Attributes::Attribute< bool >::unpack(), HF::UID::URI::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(), and HF::Protocol::SetAttributePack::Response::Result::unpack().
uint16_t HF::Common::ByteArray::read | ( | uint16_t | offset, |
uint16_t & | data | ||
) | const |
Read the word in big-endian format at offset
into data
.
[in] | offset | offset to read the word from. |
[out] | data | reference to save the read value to. |
uint16_t HF::Common::ByteArray::read | ( | uint16_t | offset, |
uint32_t & | data | ||
) | const |
Read the double-word in big-endian format at offset
into data
.
[in] | offset | offset to read the double-word from. |
[out] | data | reference to save the read value to. |
|
inline |
Read the byte at offset
into data
. (uint16_t, uint8_t)
[in] | offset | offset to read the byte from. |
[out] | data | reference to save the read value to. |
Definition at line 344 of file inc/hanfun/common.h.
References read().
|
inline |
Read the byte at offset
into data
. (uint16_t, uint8_t)
[in] | offset | offset to read the byte from. |
[out] | data | reference to save the read value to. |
Definition at line 356 of file inc/hanfun/common.h.
References read().
uint16_t HF::Common::ByteArray::write | ( | uint16_t | offset, |
uint8_t | data | ||
) |
Write a byte into the array at the given offset
.
[in] | offset | offset to write the byte to. |
[in] | data | byte value to write to the array. |
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::Interfaces::SimplePowerMeter::Measurement::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::Attributes::Attribute< bool >::pack(), HF::UID::URI::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::Protocol::SetAttributePack::Response::Result::pack(), and write().
uint16_t HF::Common::ByteArray::write | ( | uint16_t | offset, |
uint16_t | data | ||
) |
Write a word in the big endian format into the array at the given offset
.
[in] | offset | offset to write the word to. |
[in] | data | word value to write to the array. |
uint16_t HF::Common::ByteArray::write | ( | uint16_t | offset, |
uint32_t | data | ||
) |
Write a double-word in big endian format into the array at the given offset
.
[in] | offset | offset to write the double-word to. |
[in] | data | double-word value to write to the array. |
|
inline |
Write a byte into the array at the given offset
. (uint16_t, uint8_t)
[in] | offset | offset to write the byte to. |
[in] | data | byte value to write to the array. |
Definition at line 300 of file inc/hanfun/common.h.
References write().
|
inline |
Write a byte into the array at the given offset
. (uint16_t, uint8_t)
[in] | offset | offset to write the byte to. |
[in] | data | byte value to write to the array. |
Definition at line 307 of file inc/hanfun/common.h.
References write().