HAN-FUN API  1.5.3
This project provides the common implementation of ULE Alliance's HAN-FUN application protocol.
HF::Interfaces::AbstractInterface Struct Referenceabstract

Top-level parent class for all implemented interfaces. More...

#include <interface.h>

+ Inheritance diagram for HF::Interfaces::AbstractInterface:
+ Collaboration diagram for HF::Interfaces::AbstractInterface:

Public Member Functions

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...
 
virtual 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::Interface
virtual uint16_t uid () const =0
 This method returns the interface UID. More...
 
virtual Interface::Role role () const =0
 Return the Interface::Role this interface implements. More...
 

Protected Member Functions

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...
 
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_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...
 
virtual bool check_uid (uint16_t uid) const =0
 Check if the given UID matches the interface UID. 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.
 

Detailed Description

Top-level parent class for all implemented interfaces.

This class provides the implementation of the common functionality present in all interfaces implementations.

Definition at line 197 of file interface.h.

Member Function Documentation

◆ attribute()

HF::Attributes::IAttribute* HF::Interfaces::AbstractInterface::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.

Reimplemented in HF::Interfaces::ColourControl::IServer, HF::Interfaces::SimplePowerMeter::Server, HF::Interfaces::SimpleThermostat::Server, HF::Interfaces::SimpleButton::Server, HF::Interfaces::LevelControl::Server, HF::Interfaces::Alert::Server, HF::Interfaces::SimpleLightSensor::Server, HF::Interfaces::SimpleAirPressure::Server, HF::Interfaces::SimpleTemperature::Server, HF::Interfaces::OnOff::Server, and HF::Interfaces::SimpleHumidity::Server.

Definition at line 209 of file interface.h.

References HF::Interface::uid(), and UNUSED.

210  {
211  UNUSED(uid);
212  return nullptr;
213  }
#define UNUSED(x)
Helper macro to remove warning about unused function/method argument.
virtual uint16_t uid() const =0
This method returns the interface UID.
+ Here is the call graph for this function:

◆ attributes()

virtual HF::Attributes::UIDS HF::Interfaces::AbstractInterface::attributes ( uint8_t  pack_id = HF::Attributes::Pack::MANDATORY) const
inlinevirtual

◆ check()

Common::Result HF::Interfaces::AbstractInterface::check ( Protocol::Message message,
Common::ByteArray payload,
uint16_t  offset 
)
protected

Check if message has correct attributes to be processed by the interface.

The attributes checked are :

See also
HF::Interface::handle
Parameters
[in]messageincoming message.
[in]payloadmessage payload.
[in]offsetoffset in payload array to start reading.
Return values
Common::Result::OKif message is for this interface;
Common::Result::FAIL_ARGotherwise.

◆ check_payload_size()

Common::Result HF::Interfaces::AbstractInterface::check_payload_size ( Protocol::Message message,
Common::ByteArray payload,
uint16_t  offset 
)
protected

Check if payload data size if sufficient for processing the message.

See also
HF::Interface::handle
Parameters
[in]messageincoming message.
[in]payloadmessage payload.
[in]offsetoffset in payload array to start reading.
Return values
Common::Result::OKif message is for this interface;
Common::Result::FAIL_ARGotherwise.

◆ check_uid()

virtual bool HF::Interfaces::AbstractInterface::check_uid ( uint16_t  uid) const
protectedpure virtual

◆ handle()

Common::Result HF::Interfaces::AbstractInterface::handle ( Protocol::Packet packet,
Common::ByteArray payload,
uint16_t  offset 
)
virtual

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.

Implements HF::Interface.

Reimplemented in HF::Units::Unit< HF::Profiles::SimpleOnOffSwitch >, and HF::Units::Unit< HF::Profiles::SimpleLight >.

◆ handle_attribute()

virtual Common::Result HF::Interfaces::AbstractInterface::handle_attribute ( 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 attributes request/response messages, i.e. :

  • Protocol::Message:Type::GET_ATTR_REQ;
  • Protocol::Message:Type::SET_ATTR_REQ;
  • Protocol::Message:Type::SET_ATTR_RESP_REQ;
  • Protocol::Message:Type::GET_ATTR_PACK_REQ;
  • Protocol::Message:Type::SET_ATTR_PACK_REQ;
  • Protocol::Message:Type::SET_ATTR_PACK_RESP_REQ;

Reimplemented in HF::Interfaces::LevelControl::Server, HF::Interfaces::SimpleLightSensor::Client, HF::Interfaces::SimpleTemperature::Client, and HF::Interfaces::SimpleHumidity::Client.

◆ handle_command()

virtual Common::Result HF::Interfaces::AbstractInterface::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 in HF::Core::AttributeReporting::Server, HF::Core::AttributeReporting::IServer, HF::Interfaces::ColourControl::IServer, HF::Core::AttributeReporting::Client, HF::Core::GroupManagement::Client, HF::Core::GroupManagement::IServer, HF::Core::Scheduling::IServer, HF::Core::BatchProgramManagement::Client, HF::Core::GroupTable::Client, HF::Core::BatchProgramManagement::IServer, HF::Interfaces::SimplePowerMeter::Client, HF::Core::GroupTable::IServer, HF::Core::SUOTA::Client, HF::Interfaces::SimpleButton::Client, HF::Interfaces::SimpleVisualEffects::Server, HF::Interfaces::Alert::Client, HF::Core::SUOTA::Server, HF::Interfaces::LevelControl::Server, HF::Interfaces::OnOff::Server, and HF::Interfaces::SimpleKeypad::Server.

◆ notify()

virtual void HF::Interfaces::AbstractInterface::notify ( const HF::Attributes::IAttribute old_value,
const HF::Attributes::IAttribute new_value 
) const
inlineprotectedvirtual

Notify that an attribute value as changed.

Parameters
[in]old_valueattribute's old value.
[in]new_valueattribute's new value.

Reimplemented in HF::Units::Unit< HF::Profiles::SimpleOnOffSwitch >, and HF::Units::Unit< HF::Profiles::SimpleLight >.

Definition at line 248 of file interface.h.

References UNUSED.

Referenced by HF::Core::GroupManagement::IServer::number_of_groups_update().

250  {
251  UNUSED(old_value);
252  UNUSED(new_value);
253  }
#define UNUSED(x)
Helper macro to remove warning about unused function/method argument.
+ Here is the caller graph for this function:

◆ payload_size() [1/2]

virtual uint16_t HF::Interfaces::AbstractInterface::payload_size ( Protocol::Message message) const
protectedvirtual

Return the minimal payload size that should be present for the given message.

Parameters
[in]messagemessage that was received.
Returns
the minimum size in bytes that the packet payload should hold.

Reimplemented in HF::Core::AttributeReporting::Client.

◆ payload_size() [2/2]

virtual uint16_t HF::Interfaces::AbstractInterface::payload_size ( Protocol::Message::Interface itf) const
inlineprotectedvirtual

Return the minimal payload size that a message should hold when addressed at the given interface.

Parameters
[in]itfthe interface being address.
Returns
the minimum number of bytes for the message for the interface.

Reimplemented in HF::Core::AttributeReporting::Server, HF::Core::AttributeReporting::Client, HF::Core::GroupManagement::Client, HF::Core::GroupManagement::IServer, HF::Core::BatchProgramManagement::Client, HF::Core::GroupTable::Client, HF::Core::GroupTable::IServer, HF::Interfaces::SimplePowerMeter::Base, HF::Interfaces::Alert::Base, and HF::Interfaces::LevelControl::Base.

Definition at line 307 of file interface.h.

References UNUSED.

308  {
309  UNUSED(itf);
310  return 0;
311  }
#define UNUSED(x)
Helper macro to remove warning about unused function/method argument.

◆ payload_size_helper()

template<typename _Message >
uint16_t HF::Interfaces::AbstractInterface::payload_size_helper ( ) const
inlineprotected

Helper function template to retrieve minimum size required for serializing/deserializing the class given.

Template Parameters
_Messagemessage class to get the minimum size to of.
Returns
the minimum size required to serializing/deserializing given class.

Definition at line 322 of file interface.h.

323  {
324  _Message message;
325 
326  return message.size();
327  }

◆ periodic()

void HF::Interfaces::AbstractInterface::periodic ( uint32_t  time)
inlinevirtual

Handle periodic processing.

Parameters
[in]timecurrent system clock value in seconds.

Implements HF::Interface.

Reimplemented in HF::Interfaces::SimplePowerMeter::Server, HF::Units::Unit< HF::Profiles::SimpleOnOffSwitch >, and HF::Units::Unit< HF::Profiles::SimpleLight >.

Definition at line 204 of file interface.h.

References UNUSED.

205  {
206  UNUSED(time);
207  }
#define UNUSED(x)
Helper macro to remove warning about unused function/method argument.

◆ send()

virtual void HF::Interfaces::AbstractInterface::send ( const Protocol::Address addr,
Protocol::Message message 
)
protectedpure virtual

Send message msg to the network address given by addr.

Parameters
[in]addrHF network address.
[in]messagepointer to the message to be sent to the network.

Implemented in HF::Core::Scheduling::IClient, HF::Units::Unit< HF::Profiles::SimpleOnOffSwitch >, HF::Units::Unit< HF::Profiles::SimpleLight >, and HF::Core::AbstractService.

Referenced by HF::Interfaces::SimpleHumidity::Client::read(), HF::Interfaces::SimpleTemperature::Client::read(), and HF::Interfaces::SimpleLightSensor::Client::read().

+ Here is the caller graph for this function:

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