HAN-FUN API  1.5.3
This project provides the common implementation of ULE Alliance's HAN-FUN application protocol.
HF::Interfaces::Alert::Server Class Reference

Alert Interface : Server side implementation. More...

#include <alert.h>

+ Inheritance diagram for HF::Interfaces::Alert::Server:
+ Collaboration diagram for HF::Interfaces::Alert::Server:

Public Member Functions

 Server ()
 Constructor.
 
virtual ~Server ()
 Destructor.
 
uint32_t state ()
 Return the current state for all the alerts as a bitmask. More...
 
void set_state (uint32_t value)
 Set the state bitmask to the given value. More...
 
bool state (uint8_t index, bool value)
 Set the alert given by index to value. More...
 
bool state (uint8_t index)
 Get the state of the alert given by index. More...
 
void clear ()
 Clear all the alerts.
 
void enable (uint8_t index)
 Enable alert at index. More...
 
void enableAll ()
 Enable all alerts.
 
bool enabled (uint8_t index)
 Check if alert at index is enabled. More...
 
uint32_t enabled ()
 Return the bitmask of the enable state of the alerts. More...
 
void set_enabled (uint32_t value)
 Set the bitmask of the enable state of the alerts. More...
 
void disable (uint8_t index)
 Disable the alert at index. More...
 
bool disabled (uint8_t index)
 Check if alert at index is disabled. More...
 
void disableAll ()
 Disable all alerts.
 
HF::Attributes::IAttributeattribute (uint8_t uid)
 Return a pointer to the interface attribute with the given uid. More...
 
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. More...
 
Commands
void status (Protocol::Address &addr, uint16_t unit_type)
 Send a HAN-FUN message containing a Alert::STATUS_CMD, to the given network address. More...
 
void status (uint16_t unit_type)
 Send a HAN-FUN message containing a Alert::STATUS_CMD, to the broadcast network address. More...
 
- Public Member Functions inherited from HF::Interfaces::InterfaceRole< Alert::Base, HF::Interface::SERVER_ROLE >
HF::Interface::Role role () const
 Return the Interface::Role this interface implements. More...
 
- Public Member Functions inherited from HF::Interfaces::Interface< HF::Interface::ALERT >
uint16_t uid () const
 This method returns the interface UID. More...
 
- Public Member Functions inherited from HF::Interfaces::AbstractInterface
Common::Result handle (Protocol::Packet &packet, Common::ByteArray &payload, uint16_t offset)
 Handle incoming messages from the network. More...
 
void periodic (uint32_t time)
 Handle periodic processing. More...
 

Protected Member Functions

Alert::Messagecreate_status (uint16_t unit_type)
 Create a HAN-FUN message containing a Alert::STATUS_CMD, to be sent to the network. More...
 
- Protected Member Functions inherited from HF::Interfaces::Alert::Base
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. More...
 
- Protected Member Functions inherited from HF::Interfaces::Interface< HF::Interface::ALERT >
bool check_uid (uint16_t uid) const
 
- Protected Member Functions inherited from HF::Interfaces::AbstractInterface
virtual void send (const Protocol::Address &addr, Protocol::Message &message)=0
 Send message msg to the network address given by addr. More...
 
virtual void notify (const HF::Attributes::IAttribute &old_value, const HF::Attributes::IAttribute &new_value) const
 Notify that an attribute value as changed. More...
 
Common::Result check (Protocol::Message &message, Common::ByteArray &payload, uint16_t offset)
 Check if message has correct attributes to be processed by the interface. More...
 
Common::Result check_payload_size (Protocol::Message &message, Common::ByteArray &payload, uint16_t offset)
 Check if payload data size if sufficient for processing the message. More...
 
virtual uint16_t payload_size (Protocol::Message &message) const
 Return the minimal payload size that should be present for the given message. More...
 
template<typename _Message >
uint16_t payload_size_helper () const
 Helper function template to retrieve minimum size required for serializing/deserializing the class given. More...
 
virtual Common::Result handle_command (Protocol::Packet &packet, Common::ByteArray &payload, uint16_t offset)
 Handle incoming messages from the network. More...
 
virtual Common::Result handle_attribute (Protocol::Packet &packet, Common::ByteArray &payload, uint16_t offset)
 Handle incoming messages from the network. More...
 

Protected Attributes

uint32_t _state
 Alert's state.
 
uint32_t _enabled
 Alert's enable state.
 

Additional Inherited Members

- Public Types inherited from HF::Interface
enum  Role { CLIENT_ROLE = 0, SERVER_ROLE = 1 }
 Interface roles. More...
 
enum  UID {
  DEVICE_MANAGEMENT = 0x0001, BIND_MANAGEMENT = 0x0002, GROUP_MANAGEMENT = 0x0003, IDENTIFY = 0x0004,
  DEVICE_INFORMATION = 0x0005, ATTRIBUTE_REPORTING = 0x0006, BATCH_PROGRAM_MANAGEMENT = 0x0007, EVENT_SCHEDULING = 0x0008,
  WEEKLY_SCHEDULING = 0x0009, GROUP_TABLE = 0x000A, TAMPER_ALERT = 0x0101, TIME = 0x0102,
  POWER = 0x0110, KEEP_ALIVE = 0x0115, RSSI = 0x0111, SUOTA = 0x0400,
  ALERT = 0x0100, ON_OFF = 0x0200, LEVEL_CONTROL = 0x0201, COLOUR_CONTROL = 0x0202,
  SIMPLE_KEYPAD = 0x0203, SIMPLE_POWER_METER = 0x0300, SIMPLE_TEMPERATURE = 0x0301, SIMPLE_HUMIDITY = 0x0302,
  SIMPLE_THERMOSTAT = 0x0303, SIMPLE_BUTTON = 0x0304, SIMPLE_VISUAL_EFFECTS = 0x0305, SIMPLE_AIR_PRESSURE = 0x0306,
  SIMPLE_LIGHT_SENSOR = 0x0307, RESERVED = 0x7F00, MAX_UID = 0x7FFE, ANY_UID = 0x7FFF
}
 Interfaces Unique Identifiers (UID). More...
 
- Static Public Attributes inherited from HF::Interface
static constexpr uint8_t MAX_CMD_ID = 0xFF
 Maximum value for command IDs in interfaces.
 

Detailed Description

Alert Interface : Server side implementation.

This class provides the server side of the Alert interface.

Definition at line 176 of file alert.h.

Member Function Documentation

◆ attribute()

HF::Attributes::IAttribute* HF::Interfaces::Alert::Server::attribute ( uint8_t  uid)
inlinevirtual

Return a pointer to the interface attribute with the given uid.

Parameters
[in]uididentifier of the attribute in the interface.
Returns
a pointer to the attribute if it exists, nullptr otherwise.

Reimplemented from HF::Interfaces::AbstractInterface.

Definition at line 303 of file alert.h.

References HF::Interfaces::create_attribute(), and HF::Interfaces::Interface< HF::Interface::ALERT >::uid().

304  {
305  return Interfaces::create_attribute(this, uid);
306  }
uint16_t uid() const
This method returns the interface UID.
Definition: interface.h:374
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.
+ Here is the call graph for this function:

◆ attributes()

HF::Attributes::UIDS HF::Interfaces::Alert::Server::attributes ( uint8_t  pack_id = HF::Attributes::Pack::MANDATORY) const
inlinevirtual

Return a vector containing the attribute UIDs, for the given pack ID.

Parameters
[in]pack_idthe Attribute pack ID to get the attributes UIDs for.
Returns
vector containing the attributes UIDs.

Reimplemented from HF::Interfaces::AbstractInterface.

Definition at line 338 of file alert.h.

References HF::Interfaces::Alert::ENABLE_ATTR, HF::Interfaces::Alert::STATE_ATTR, and UNUSED.

340  {
341  UNUSED(pack_id);
342  /* *INDENT-OFF* */
344  /* *INDENT-ON* */
345  }
List of attributes UIDs.
Definition: attributes.h:176
State attribute UID.
Definition: alert.h:78
#define UNUSED(x)
Helper macro to remove warning about unused function/method argument.
Enable attribute UID.
Definition: alert.h:79

◆ create_status()

Alert::Message* HF::Interfaces::Alert::Server::create_status ( uint16_t  unit_type)
protected

Create a HAN-FUN message containing a Alert::STATUS_CMD, to be sent to the network.

Parameters
unit_typeunit type (i.e. profile) source for the alert status message.
Returns
a pointer to a Alert::Message, or nullptr if the message can't be allocated.

◆ disable()

void HF::Interfaces::Alert::Server::disable ( uint8_t  index)

Disable the alert at index.

Parameters
[in]indexindex of the alert to disable : [0,31].

◆ disabled()

bool HF::Interfaces::Alert::Server::disabled ( uint8_t  index)

Check if alert at index is disabled.

Parameters
[in]indexindex of the alert to get the enable state : [0,31].
Return values
<tt>true</tt>if the alert at index is disabled
<tt>false</tt>otherwise

◆ enable()

void HF::Interfaces::Alert::Server::enable ( uint8_t  index)

Enable alert at index.

Parameters
[in]indexindex to enable the alert : [0,31].

◆ enabled() [1/2]

bool HF::Interfaces::Alert::Server::enabled ( uint8_t  index)

Check if alert at index is enabled.

Parameters
[in]indexindex of the alert to get the enabled state : [0,31].
Return values
<tt>true</tt>if the alert at index is enabled,
<tt>false</tt>otherwise.

◆ enabled() [2/2]

uint32_t HF::Interfaces::Alert::Server::enabled ( )

Return the bitmask of the enable state of the alerts.

Returns
the bitmask of the enable state of the alerts.

◆ set_enabled()

void HF::Interfaces::Alert::Server::set_enabled ( uint32_t  value)

Set the bitmask of the enable state of the alerts.

Parameters
[in]valuethe bitmask of the enable state of the alerts to set.

◆ set_state()

void HF::Interfaces::Alert::Server::set_state ( uint32_t  value)

Set the state bitmask to the given value.

Parameters
[in]valuebitmask value to set the alert states.

◆ state() [1/3]

uint32_t HF::Interfaces::Alert::Server::state ( )

Return the current state for all the alerts as a bitmask.

Returns
the bitmask of the alert states.

Referenced by HF::Profiles::Detector< FLOOD_DETECTOR >::alert().

+ Here is the caller graph for this function:

◆ state() [2/3]

bool HF::Interfaces::Alert::Server::state ( uint8_t  index,
bool  value 
)

Set the alert given by index to value.

The alert entry MUST be enabled in order for the state to be set.

Parameters
[in]indexindex of the alert to set : [0,31].
[in]valuestate to set the index to.
Returns
true if the alert state was set or false otherwise.

◆ state() [3/3]

bool HF::Interfaces::Alert::Server::state ( uint8_t  index)

Get the state of the alert given by index.

Note
This will return false if index is greater than 31.
Parameters
[in]indexindex of the alert to get the state from : [0,31].
Returns
true if the alert is active, false otherwise.

◆ status() [1/2]

void HF::Interfaces::Alert::Server::status ( Protocol::Address addr,
uint16_t  unit_type 
)

Send a HAN-FUN message containing a Alert::STATUS_CMD, to the given network address.

Parameters
[in]addrthe network address to send the message to.
[in]unit_typethe unit type (
See also
hf_profile_uid_t ) sending the message.

Referenced by HF::Profiles::Detector< FLOOD_DETECTOR >::alert(), and status().

+ Here is the caller graph for this function:

◆ status() [2/2]

void HF::Interfaces::Alert::Server::status ( uint16_t  unit_type)
inline

Send a HAN-FUN message containing a Alert::STATUS_CMD, to the broadcast network address.

Parameters
[in]unit_typethe unit type (
See also
HF::Profile::UID ) sending the message.

Definition at line 329 of file alert.h.

References status().

330  {
331  Protocol::Address addr;
332  status(addr, unit_type);
333  }
void status(Protocol::Address &addr, uint16_t unit_type)
Send a HAN-FUN message containing a Alert::STATUS_CMD, to the given network address.
+ Here is the call graph for this function:

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