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

This is the parent class for all services implementations. More...

#include <core.h>

+ Inheritance diagram for HF::Core::AbstractService:
+ Collaboration diagram for HF::Core::AbstractService:

Public Member Functions

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::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...
 
- 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

 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_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...
 

Protected Attributes

Unit0_unit
 Reference to the unit the service belongs to.
 

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

This is the parent class for all services implementations.

Definition at line 137 of file core.h.

Constructor & Destructor Documentation

◆ AbstractService()

HF::Core::AbstractService::AbstractService ( Unit0 unit)
inlineprotected

Constructor.

Parameters
[in]unitreference to the unit that holds this service.

Definition at line 167 of file core.h.

167  : _unit(unit)
168  {}
Unit0 & unit() const
The device this unit is associated with.
Definition: core.h:142
Unit0 & _unit
Reference to the unit the service belongs to.
Definition: core.h:160

Member Function Documentation

◆ attribute()

HF::Attributes::IAttribute* HF::Core::AbstractService::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 147 of file core.h.

References HF::Interface::uid().

148  {
149  return AbstractInterface::attribute(uid);
150  }
virtual uint16_t uid() const =0
This method returns the interface UID.
+ Here is the call graph for this function:

◆ attributes()

HF::Attributes::UIDS HF::Core::AbstractService::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 152 of file core.h.

153  {
154  return AbstractInterface::attributes(pack_id);
155  }

◆ send() [1/2]

void HF::Core::AbstractService::send ( const Protocol::Address addr,
Protocol::Message message 
)
inlineprotectedvirtual

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.

Implements HF::Interfaces::AbstractInterface.

Definition at line 171 of file core.h.

References HF::Units::AbstractUnit::send(), and unit().

172  {
173  unit().send(addr, message, nullptr);
174  }
Unit0 & unit() const
The device this unit is associated with.
Definition: core.h:142
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.
+ Here is the call graph for this function:

◆ send() [2/2]

void HF::Core::AbstractService::send ( const Protocol::Address addr,
Protocol::Message message,
Transport::Link link 
)
inlineprotected

Create and send a new packet with the given message to the given address.

Parameters
[in]addraddress to send the message to.
[in]messagemessage to send.
[in]linkpreferred link to send the message on.

Definition at line 177 of file core.h.

References HF::Units::AbstractUnit::send(), and unit().

179  {
180  unit().send(addr, message, link);
181  }
Unit0 & unit() const
The device this unit is associated with.
Definition: core.h:142
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.
+ Here is the call graph for this function:

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