16 #ifndef HF_ITF_ALERT_H 17 #define HF_ITF_ALERT_H 76 typedef enum _Attributes
89 static constexpr uint16_t
min_size =
sizeof(uint16_t)
104 uint16_t
size()
const;
167 return payload_size_helper<Message>();
219 bool state(uint8_t index,
bool value);
230 bool state(uint8_t index);
246 void enable(uint8_t index);
Message(uint16_t type=0, uint32_t state=0)
Constructor.
void set_enabled(uint32_t value)
Set the bitmask of the enable state of the alerts.
uint32_t enabled()
Return the bitmask of the enable state of the alerts.
static constexpr bool WRITABBLE
Attribute Read/Write.
void status(uint16_t unit_type)
Send a HAN-FUN message containing a Alert::STATUS_CMD, to the broadcast network address.
std::ostream & operator<<(std::ostream &stream, const HF::Interfaces::Alert::CMD command)
Convert the given command into a string and write it to the given stream.
Helper class to handle the Enabled attribute for the Alert interface.
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 size() const
Number bytes needed to serialize the message.
Alert Interface : Parent.
uint32_t _enabled
Alert's enable state.
Return all mandatory attributes for the interface.
This file contains the common defines for the HAN-FUN library.
uint16_t unpack(const Common::ByteArray &array, uint16_t offset=0)
Read a message from a ByteArray.
Helper class template for parent class implementation of the interfaces.
static constexpr uint8_t ID
Attribute UID.
uint16_t type
Unit Type that generated the message.
virtual void status(Protocol::Address &source, Message &message)
Callback function called when a status update message is received from an Alert server.
This file contains the definitions for the HAN-FUN protocol messages.
uint16_t payload_size(Protocol::Message::Interface &itf) const
Return the minimal payload size that a message should hold when addressed at the given interface...
Payload for the Status command.
uint32_t state
Current state of the server.
Alert Interface : Client side implementation.
Helper class to handle the State attribute for the Alert interface.
This file contains the definitions common to all interfaces.
virtual ~Server()
Destructor.
uint32_t state()
Return the current state for all the alerts as a bitmask.
Common::Result handle_command(Protocol::Packet &packet, Common::ByteArray &payload, uint16_t offset)
Handle incoming messages from the network.
HF::Interface const * owner() const
void set_state(uint32_t value)
Set the state bitmask to the given value.
void enable(uint8_t index)
Enable alert at index.
static constexpr uint16_t min_size
Minimum pack/unpack required data size.
This class represents a byte array.
void disable(uint8_t index)
Disable the alert at index.
uint32_t _state
Alert's state.
void disableAll()
Disable all alerts.
uint16_t uid() const
This method returns the interface UID.
static constexpr uint8_t ID
Attribute UID.
HF::Attributes::IAttribute * attribute(uint8_t uid)
Return a pointer to the interface attribute with the given uid.
Alert Interface : Server side implementation.
Alert::Message * create_status(uint16_t unit_type)
Create a HAN-FUN message containing a Alert::STATUS_CMD, to be sent to the network.
bool disabled(uint8_t index)
Check if alert at index is disabled.
HF::Attributes::IAttribute * create_attribute(HF::Interfaces::Alert::Server *server, uint8_t uid)
Create an attribute object that can hold the attribute with the given uid.
HF::Attributes::IAttribute * create_attribute(uint8_t uid)
Create an attribute object that can hold the attribute with the given uid. (HF::Interfaces::Alert::Se...
Interface/Service Attribute API.
void status(Protocol::Address &addr, uint16_t unit_type)
Send a HAN-FUN message containing a Alert::STATUS_CMD, to the given network address.
Helper class template for implementing a given interface role.
#define UNUSED(x)
Helper macro to remove warning about unused function/method argument.
Helper template class to declare an attribute with the given T type.
void enableAll()
Enable all alerts.
void clear()
Clear all the alerts.
Attribute(const uint16_t interface, const uint8_t uid, const HF::Interface *__owner, uint32_t data, bool writable=false)
Attribute template constructor.
Common interface for all Interfaces.
HF::Attributes::UIDS attributes(uint8_t pack_id=HF::Attributes::Pack::MANDATORY) const
Return a vector containing the attribute UIDs, for the given pack ID.
Result
Commands result codes.
static constexpr bool WRITABBLE
Attribute Read/Write.
Top-level namespace for the HAN-FUN library.