17 #ifndef HF_CORE_SUOTA_H 18 #define HF_CORE_SUOTA_H 79 typedef enum _NewVersionResponse
105 const std::string _hw_version =
"",
106 const std::string _url =
""):
111 static constexpr uint16_t
min_size = 2 *
sizeof(uint8_t);
114 uint16_t
size()
const;
149 const std::string _hw_version =
"",
const std::string _url =
""):
150 Protocol::Response(_status),
151 Version(_sw_version, _hw_version, _url) {}
154 Protocol::Response(_status),
Version() {}
170 uint16_t start = offset;
175 return offset - start;
183 uint16_t start = offset;
192 return offset - start;
229 static constexpr uint16_t
min_size =
sizeof(uint8_t);
234 return sizeof(uint8_t) +
244 uint16_t start = offset;
246 offset += array.
write(offset, static_cast<uint8_t>(code));
254 return offset - start;
262 uint16_t start = offset;
265 offset += array.
read(offset, temp);
266 code =
static_cast<Code>(temp);
270 return offset - start;
414 #ifdef HF_CORE_SUOTA_CHECK_VERSION_CMD 443 std::string version =
"");
std::string sw_version
Update status.
New Version Available command UID.
NewVersionResponse
Result codes for a SUOTA::NEW_VERSION_AVAILABLE_CMD.
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 write(uint16_t offset, uint8_t data)
Write a byte into the array at the given offset.
bool response(Message::Type type)
Check if message is a response.
std::string sw_version
Current/Available software version.
This represent the special unit with ID/UID = 0.
virtual void check_version(const Protocol::Address &addr, const CheckVersionResponse &response)
Callback that is called when a response to a SUOTA::CHECK_VERSION_CMD, is received.
void new_version_available(const Version &version)
Send a HAN-FUN message containing a SUOTA::NEW_VERSION_AVAILABLE_CMD, to the broadcast network addres...
virtual void upgrade_complete(const Protocol::Address &addr, const UpgradeStatus &status)
Callback that is called when a SUOTA::UPGRADE_COMPLETE_CMD, is received.
uint16_t size() const
Number bytes needed to serialize the message.
static constexpr uint16_t min_size
Minimum pack/unpack required data size.
uint16_t size() const
Number bytes needed to serialize the message.
This file contains the common defines for the HAN-FUN library.
void upgrade_complete(const Protocol::Address &addr, UpgradeStatus::Code status, std::string version="")
Send a HAN-FUN message containing a SUOTA::UPGRADE_COMPLETE_CMD, to the given network address...
#define HF_ASSERT(_expr, _block)
Helper macro to check for correct assumptions.
This file contains the forward declarations of the core services and interfaces implementing classes...
Common::Result handle_command(Protocol::Packet &packet, Common::ByteArray &payload, uint16_t offset)
Handle incoming messages from the network.
void new_version_available(const Protocol::Address &addr, const Version &version)
Send a HAN-FUN message containing a SUOTA::NEW_VERSION_AVAILABLE_CMD, to the given network address...
Server(HF::Core::Unit0 &unit0)
Constructor.
uint16_t unpack(const ByteArray &array, uint16_t offset=0)
Read a message from a ByteArray.
uint16_t size() const
Number bytes needed to serialize the message.
This file contains the definitions for the HAN-FUN protocol messages.
static constexpr uint16_t min_size
Minimum pack/unpack required data size.
UpgradeStatus(Code _code=FAIL_UNKNOWN, std::string _sw_version="")
Software version after update.
Common::Result handle_command(Protocol::Packet &packet, Common::ByteArray &payload, uint16_t offset)
Handle incoming messages from the network.
SUOTA Interfaces::Interface : Client side implementation.
Base(HF::Core::Unit0 &unit0)
Constructor.
#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...
Version(const std::string _sw_version="", const std::string _hw_version="", const std::string _url="")
Constructor.
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.
Check Version command UID.
Helper class that represents the information of a particular version.
void upgrade_complete(UpgradeStatus::Code status, std::string version="")
Send a HAN-FUN message containing a SUOTA::UPGRADE_COMPLETE_CMD, to the broadcast network address...
uint16_t size() const
Number bytes needed to serialize the message.
std::ostream & operator<<(std::ostream &stream, const HF::Core::SUOTA::CMD command)
Convert the given command into a string and write it to the given stream.
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.
This class represents a byte array.
No newer version available.
virtual ~Server()
Destructor.
uint16_t unpack(const Common::ByteArray &array, uint16_t offset=0)
Read a message from a ByteArray.
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.
uint16_t unpack(const Common::ByteArray &array, uint16_t offset=0)
Read a message from a ByteArray.
Code
Possible status in a.
SUOTA Interfaces::Interface : Parent.
SUOTA Interfaces::Interface : Server side implementation.
uint16_t unpack(const Common::ByteArray &array, uint16_t offset=0)
Read a message from a ByteArray.
CheckVersionResponse(Status _status=FAIL_UNKNOWN, const std::string _sw_version="", const std::string _hw_version="", const std::string _url="")
Constructor.
This class contains the required parameters for a SUOTA::UPGRADE_COMPLETE_CMD command.
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.
Interface/Service Attribute API.
Status
Possible result codes for a SUOTA::CHECK_VERSION_CMD.
uint16_t read(uint16_t offset, uint8_t &data) const
Read the byte at offset into data.
uint16_t size() const
Number bytes needed to serialize the message.
Parent class for the response messages.
HF::Attributes::IAttribute * create_attribute(uint8_t uid)
Create an attribute object that can hold the attribute with the given uid. (HF::Interfaces::SUOTA::Se...
Class template for all interfaces role implementations.
virtual NewVersionResponse new_version_available(const Protocol::Address &addr, const Version &version)
Callback that is called when a SUOTA::NEW_VERSION_AVAILABLE_CMD, is received.
static constexpr uint16_t min_size
Minimum number of bytes required by this message.
Server or Network are down.
This class represents the message for the response of a SUOTA::CHECK_VERSION_CMD. ...
Common interface for all Interfaces.
std::string url
Update URL.
Class template for all core services implementations.
uint16_t unpack(const Common::ByteArray &array, uint16_t offset=0)
Read a message from a ByteArray.
std::string hw_version
Current/Minimum required hardware version.
Result
Commands result codes.
Upgrade Complete command UID.
HF::Attributes::IAttribute * create_attribute(HF::Core::AttributeReporting::IServer *server, uint8_t uid)
Create an attribute object that can hold the attribute with the given uid.
static constexpr uint16_t min_size
Minimum pack/unpack required data size.
virtual CheckVersionResponse check_version(const Protocol::Address &addr, const Version &version)
Callback that is called when a SUOTA::CHECK_VERSION_CMD, is received.
Top-level namespace for the HAN-FUN library.