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

Attribute Reporting - Server Role. More...

#include <attribute_reporting.h>

+ Inheritance diagram for HF::Core::AttributeReporting::IServer:
+ Collaboration diagram for HF::Core::AttributeReporting::IServer:

Public Member Functions

 IServer (Unit0 &unit)
 Constructor. More...
 
uint16_t uid () const
 This method returns the interface UID. More...
 
Interface::Role role () const
 Return the Interface::Role this interface implements. More...
 
virtual void notify (uint8_t unit, const HF::Attributes::IAttribute &old_value, const HF::Attributes::IAttribute &new_value)
 Process an attribute change from old_value to new_value for the given unit. More...
 
virtual uint16_t count (Type type) const
 Get the number of rules for the given type. More...
 
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...
 
- Public Member Functions inherited from HF::Core::AbstractService
Unit0unit () const
 The device this unit is associated with.
 
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...
 
- 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...
 
HF::Attributes::IAttributeattribute (uint8_t uid)
 Return a pointer to the interface attribute with the given uid. More...
 

Protected Member Functions

Common::Result handle_command (Protocol::Packet &packet, Common::ByteArray &payload, uint16_t offset)
 Handle incoming messages from the network. More...
 
void response (Protocol::Packet &packet, Reference &report, Common::Result result)
 Send the response to a command with the given result. More...
 
virtual bool authorized (uint8_t member, Protocol::Address &source)
 Check if the given command is authorized for the device with the given address. More...
 
bool check_uid (uint16_t uid) const
 Check if the given UID matches the interface UID. More...
 
- Protected Member Functions inherited from HF::Core::AbstractService
 AbstractService (Unit0 &unit)
 Constructor. More...
 
void send (const Protocol::Address &addr, Protocol::Message &message)
 Send message msg to the network address given by addr. More...
 
void send (const Protocol::Address &addr, Protocol::Message &message, Transport::Link *link)
 Create and send a new packet with the given message to the given address. More...
 
- Protected Member Functions inherited from HF::Interfaces::AbstractInterface
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...
 
virtual 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...
 
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_attribute (Protocol::Packet &packet, Common::ByteArray &payload, uint16_t offset)
 Handle incoming messages from the network. More...
 

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.
 
- Protected Attributes inherited from HF::Core::AbstractService
Unit0_unit
 Reference to the unit the service belongs to.
 

Detailed Description

Attribute Reporting - Server Role.

This class provides the minimal implementation for the Attribute reporting server role functionality.

All requests will get a HF::Common::Result::FAIL_RESOURCES response.

Definition at line 1572 of file attribute_reporting.h.

Constructor & Destructor Documentation

◆ IServer()

HF::Core::AttributeReporting::IServer::IServer ( Unit0 unit)
inline

Constructor.

Parameters
[in]unitreference to the unit containing this service.

Definition at line 1579 of file attribute_reporting.h.

1579  :
1581  {}
AbstractService(Unit0 &unit)
Constructor.
Definition: core.h:167
Unit0 & unit() const
The device this unit is associated with.
Definition: core.h:142

Member Function Documentation

◆ attribute()

HF::Attributes::IAttribute* HF::Core::AttributeReporting::IServer::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.

Implements HF::Interface.

Definition at line 1635 of file attribute_reporting.h.

References HF::Core::create_attribute(), and uid().

1636  {
1637  return Core::create_attribute(this, uid);
1638  }
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.
uint16_t uid() const
This method returns the interface UID.
+ Here is the call graph for this function:

◆ attributes()

HF::Attributes::UIDS HF::Core::AttributeReporting::IServer::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 1640 of file attribute_reporting.h.

References HF::Core::AttributeReporting::EVENT_REPORT_COUNT_ATTR, HF::Core::AttributeReporting::PERIODIC_REPORT_COUNT_ATTR, HF::Core::AttributeReporting::REPORT_COUNT_ATTR, and UNUSED.

1642  {
1643  UNUSED(pack_id);
1646  }
Number of event report entries attribute.
List of attributes UIDs.
Definition: attributes.h:176
Number of periodic report entries attribute.
Number of report entries attribute.
#define UNUSED(x)
Helper macro to remove warning about unused function/method argument.

◆ authorized()

virtual bool HF::Core::AttributeReporting::IServer::authorized ( uint8_t  member,
Protocol::Address source 
)
inlineprotectedvirtual

Check if the given command is authorized for the device with the given address.

Parameters
[in]memberinterface member to check.
[in]sourcedevice address of the incoming command.
Return values
truethe command if authorized.
falseotherwise.

Definition at line 1674 of file attribute_reporting.h.

References UNUSED.

1675  {
1676  UNUSED(member);
1677  UNUSED(source);
1678 
1679  return true;
1680  }
#define UNUSED(x)
Helper macro to remove warning about unused function/method argument.

◆ check_uid()

bool HF::Core::AttributeReporting::IServer::check_uid ( uint16_t  uid) const
inlineprotectedvirtual

Check if the given UID matches the interface UID.

Parameters
[in]uidthe UID value to check against the interface UID.
Return values
truethe UIDs match,
falseotherwise.

Implements HF::Interfaces::AbstractInterface.

Definition at line 1682 of file attribute_reporting.h.

References uid().

1683  {
1684  return IServer::uid() == uid;
1685  }
uint16_t uid() const
This method returns the interface UID.
+ Here is the call graph for this function:

◆ count()

virtual uint16_t HF::Core::AttributeReporting::IServer::count ( Type  type) const
inlinevirtual

Get the number of rules for the given type.

Parameters
[in]typeattribute reporting type to get the number of rules for.
Returns
number of rules for the given type.

Reimplemented in HF::Core::AttributeReporting::Server.

Definition at line 1625 of file attribute_reporting.h.

References UNUSED.

1626  {
1627  UNUSED(type);
1628  return 0;
1629  }
#define UNUSED(x)
Helper macro to remove warning about unused function/method argument.

◆ handle_command()

Common::Result HF::Core::AttributeReporting::IServer::handle_command ( Protocol::Packet packet,
Common::ByteArray payload,
uint16_t  offset 
)
protectedvirtual

Handle incoming messages from the network.

Parameters
[in]packetthe packet receive from the network.
[in]payloadthe byte array containing the data received from the network.
[in]offsetthe offset the payload start at in the byte array.
Returns
the result of the message processing.

Handle command request/response messages, i.e. :

  • Protocol::Message:Type::COMMAND_REQ;
  • Protocol::Message:Type::COMMAND_RESP_REQ;
  • Protocol::Message:Type::COMMAND_RES;

Reimplemented from HF::Interfaces::AbstractInterface.

Reimplemented in HF::Core::AttributeReporting::Server.

◆ notify()

virtual void HF::Core::AttributeReporting::IServer::notify ( uint8_t  unit,
const HF::Attributes::IAttribute old_value,
const HF::Attributes::IAttribute new_value 
)
inlinevirtual

Process an attribute change from old_value to new_value for the given unit.

This method checks if the change in the given attribute matches the conditions present in any of the attribute reporting rules.

Parameters
[in]unitunit ID where the attribute is present.
[in]old_valueold value for the attribute.
[in]new_valuenew value for the attribute.

Reimplemented in HF::Core::AttributeReporting::Server.

Definition at line 1610 of file attribute_reporting.h.

References HF::Core::AbstractService::unit(), and UNUSED.

1612  {
1613  UNUSED(unit);
1614  UNUSED(old_value);
1615  UNUSED(new_value);
1616  }
Unit0 & unit() const
The device this unit is associated with.
Definition: core.h:142
#define UNUSED(x)
Helper macro to remove warning about unused function/method argument.
+ Here is the call graph for this function:

◆ response()

void HF::Core::AttributeReporting::IServer::response ( Protocol::Packet packet,
Reference report,
Common::Result  result 
)
protected

Send the response to a command with the given result.

Parameters
[in]packetincoming packet to generate the response for.
[in]reportreport identification.
[in]resultoperation result.

◆ role()

Interface::Role HF::Core::AttributeReporting::IServer::role ( ) const
inlinevirtual

Return the Interface::Role this interface implements.

Returns
the Interface::Role implemented by the interface.

Implements HF::Interface.

Definition at line 1594 of file attribute_reporting.h.

References HF::Interface::SERVER_ROLE.

1595  {
1597  }

◆ uid()

uint16_t HF::Core::AttributeReporting::IServer::uid ( ) const
inlinevirtual

This method returns the interface UID.

Subclasses MUST override this method to provide a valid value for the interface being implemented.

This method returns a uint16_t and not a Interface::UID, to provide support for proprietary interfaces.

Returns
the UID for the interface.

Implements HF::Interface.

Definition at line 1589 of file attribute_reporting.h.

References HF::Interface::ATTRIBUTE_REPORTING.

Referenced by attribute(), and check_uid().

1590  {
1592  }
Attribute Reporting interface UID.
Definition: interface.h:65
+ Here is the caller graph for this function:

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