HAN-FUN API  1.5.3
This project provides the common implementation of ULE Alliance's HAN-FUN application protocol.
HF::Core::GroupManagement::IServer Class Referenceabstract

Group Management Service : Server side implementation. More...

#include <group_management.h>

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

Public Member Functions

 IServer (Unit0 &unit)
 Constructor.
 
virtual ~IServer ()
 Destructor.
 
HF::Devices::Concentrator::IUnit0unit0 () const
 Return a reference to the unit that this service belongs to. More...
 
virtual IEntriesentries () const =0
 Get a reference to the current object implementing the persistence API, for the device information. More...
 
GroupPtr entry (const uint16_t address) const
 Get the group entry given by address. More...
 
GroupPtr entry (const std::string &name) const
 Get the group entry given by name. More...
 
uint16_t next_address () const
 Return next available address for device group. More...
 
uint8_t number_of_groups () const
 Get the Number Of Groups for the Group Management server. 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...
 
Common::Result handle (Protocol::Packet &packet, Common::ByteArray &payload, uint16_t offset)
 Handle incoming messages from the network. More...
 
Events
virtual Common::Result create (Protocol::Packet &packet, CreateMessage &msg)
 Callback that is called when a GroupManagement::CREATE_CMD, is received. More...
 
virtual void created (const GroupPtr &group)
 Indicate that a new group was created. More...
 
virtual Common::Result remove (Protocol::Packet &packet, DeleteMessage &msg)
 Callback that is called when a GroupManagement::DELETE_CMD, is received. More...
 
virtual void deleted (const Group &group)
 Indicate that a group was deleted. More...
 
virtual Common::Result add (Protocol::Packet &packet, const AddMessage &msg)
 Callback that is called when a GroupManagement::ADD_CMD, is received. More...
 
virtual void added (const GroupPtr &group, const Member &member)
 Indicate that a new device/unit was added to an existing group. More...
 
virtual Common::Result remove (Protocol::Packet &packet, const RemoveMessage &msg)
 Callback that is called when a GroupManagement::REMOVE_CMD, is received. More...
 
virtual void removed (const GroupPtr &group, const Member &member)
 Indicate that a device/unit was removed from an existing group. More...
 
- Public Member Functions inherited from HF::Core::ServiceRole< GroupManagement::Base, HF::Interface::SERVER_ROLE >
Interface::Role role () const
 Return the Interface::Role this interface implements. More...
 
- Public Member Functions inherited from HF::Core::Service< HF::Interface::GROUP_MANAGEMENT >
uint16_t uid () const
 This method returns the interface UID. 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

virtual bool authorized (CMD member, const Protocol::Address &source, const Protocol::Address &destination)
 This method serves to indicate if a given member of the interface can be used by the source device affecting the destination device configuration on the system. More...
 
void number_of_groups_update (int8_t diff) const
 Get the Number Of Groups for the Group Management server. More...
 
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...
 
Common::Result handle_command (Protocol::Packet &packet, Common::ByteArray &payload, uint16_t offset)
 Handle incoming messages from the network. More...
 
void added (const Protocol::Address &addr, Common::Result result, const AddMessage &request, uint8_t reference)
 Process the result of adding a device to a group. More...
 
virtual IGroupTablegroup_table () const =0
 Get the Group Table client associated with this Group Management server. More...
 
- Protected Member Functions inherited from HF::Core::ServiceRole< GroupManagement::Base, HF::Interface::SERVER_ROLE >
 ServiceRole (Unit0 &unit)
 Constructor. More...
 
- Protected Member Functions inherited from HF::Core::GroupManagement::Base
 Base (Unit0 &unit)
 Constructor.
 
- Protected Member Functions inherited from HF::Core::Service< HF::Interface::GROUP_MANAGEMENT >
 Service (Unit0 &unit)
 Constructor. More...
 
bool check_uid (uint16_t uid) const
 Check if the given uid value matches the service's UID value. 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...
 
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

Group Management Service : Server side implementation.

This class provides the server side of the Group Management interface.

Definition at line 744 of file group_management.h.

Member Function Documentation

◆ add()

virtual Common::Result HF::Core::GroupManagement::IServer::add ( Protocol::Packet packet,
const AddMessage msg 
)
virtual

Callback that is called when a GroupManagement::ADD_CMD, is received.

Parameters
[in]packetthe message Packet.
[in]msgthe CreateMessage received.
Returns
the response code sent in the response.

◆ added() [1/2]

virtual void HF::Core::GroupManagement::IServer::added ( const GroupPtr group,
const Member member 
)
inlinevirtual

Indicate that a new device/unit was added to an existing group.

Parameters
[in]groupreference to a pointer to the group entry corresponding to the group where a member was added.
[in]memberreference to the member added.

Definition at line 824 of file group_management.h.

References UNUSED.

825  {
826  UNUSED(group);
827  UNUSED(member);
828  }
#define UNUSED(x)
Helper macro to remove warning about unused function/method argument.

◆ added() [2/2]

void HF::Core::GroupManagement::IServer::added ( const Protocol::Address addr,
Common::Result  result,
const AddMessage request,
uint8_t  reference 
)
protected

Process the result of adding a device to a group.

Parameters
[in]addrHF address of the device that requested the HF::GroupManagement::ADD_CMD command.
[in]resultthe result of the operation.
[in]requestthe payload for the HF::GroupManagement::ADD_CMD command.
[in]referenceApplication reference for the initial request.

◆ attribute()

HF::Attributes::IAttribute* HF::Core::GroupManagement::IServer::attribute ( uint8_t  uid)
virtual

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.

◆ attributes()

HF::Attributes::UIDS HF::Core::GroupManagement::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 945 of file group_management.h.

References HF::Core::GroupManagement::NUMBER_OF_GROUPS_ATTR, and UNUSED.

947  {
948  UNUSED(pack_id);
950  }
List of attributes UIDs.
Definition: attributes.h:176
#define UNUSED(x)
Helper macro to remove warning about unused function/method argument.

◆ authorized()

virtual bool HF::Core::GroupManagement::IServer::authorized ( CMD  member,
const Protocol::Address source,
const Protocol::Address destination 
)
inlineprotectedvirtual

This method serves to indicate if a given member of the interface can be used by the source device affecting the destination device configuration on the system.

Parameters
[in]memberinterface member UID.
[in]sourceHF address for the requesting device.
[in]destinationHF address for the affected device.
Return values
truethe operation is allowed,
falseotherwise.

Definition at line 969 of file group_management.h.

References UNUSED.

971  {
972  UNUSED(member);
973  UNUSED(source);
974  UNUSED(destination);
975  return true;
976  }
#define UNUSED(x)
Helper macro to remove warning about unused function/method argument.

◆ create()

virtual Common::Result HF::Core::GroupManagement::IServer::create ( Protocol::Packet packet,
CreateMessage msg 
)
virtual

Callback that is called when a GroupManagement::CREATE_CMD, is received.

Parameters
[in]packetthe message Packet.
[in]msgthe CreateMessage received.
Returns
the response code sent in the response.

◆ created()

virtual void HF::Core::GroupManagement::IServer::created ( const GroupPtr group)
inlinevirtual

Indicate that a new group was created.

Parameters
[in]grouppointer to the group entry corresponding to the created group.

Definition at line 779 of file group_management.h.

References UNUSED.

780  {
781  UNUSED(group);
782  }
#define UNUSED(x)
Helper macro to remove warning about unused function/method argument.

◆ deleted()

virtual void HF::Core::GroupManagement::IServer::deleted ( const Group group)
inlinevirtual

Indicate that a group was deleted.

Parameters
[in]groupreference to a copy of the group entry that was deleted.

Definition at line 800 of file group_management.h.

References UNUSED.

801  {
802  UNUSED(group);
803  }
#define UNUSED(x)
Helper macro to remove warning about unused function/method argument.

◆ entries()

virtual IEntries& HF::Core::GroupManagement::IServer::entries ( ) const
pure virtual

Get a reference to the current object implementing the persistence API, for the device information.

Returns
reference to the current object for the persistence API.

Implemented in HF::Core::GroupManagement::Server< _Entries, _GroupTable >.

Referenced by entry(), next_address(), and number_of_groups().

+ Here is the caller graph for this function:

◆ entry() [1/2]

GroupPtr HF::Core::GroupManagement::IServer::entry ( const uint16_t  address) const
inline

Get the group entry given by address.

Parameters
[in]addressgroup address of the group to retrieve.
Returns
a pointer to the group if it exists, nullptr otherwise.

Definition at line 899 of file group_management.h.

References entries(), and HF::Core::GroupManagement::IEntries::find().

900  {
901  return entries().find(address);
902  }
virtual GroupPtr find(const uint16_t address) const =0
Find the group with the given group address.
virtual IEntries & entries() const =0
Get a reference to the current object implementing the persistence API, for the device information...
+ Here is the call graph for this function:

◆ entry() [2/2]

GroupPtr HF::Core::GroupManagement::IServer::entry ( const std::string &  name) const
inline

Get the group entry given by name.

Parameters
[in]namegroup name of the group to retrieve.
Returns
a pointer to the group if it exists, nullptr otherwise.

Definition at line 912 of file group_management.h.

References entries(), and HF::Core::GroupManagement::IEntries::find().

913  {
914  return entries().find(name);
915  }
virtual GroupPtr find(const uint16_t address) const =0
Find the group with the given group address.
virtual IEntries & entries() const =0
Get a reference to the current object implementing the persistence API, for the device information...
+ Here is the call graph for this function:

◆ group_table()

virtual IGroupTable& HF::Core::GroupManagement::IServer::group_table ( ) const
protectedpure virtual

Get the Group Table client associated with this Group Management server.

Returns
reference to the Group Table client used by this Group Management server.

Implemented in HF::Core::GroupManagement::Server< _Entries, _GroupTable >.

◆ handle()

Common::Result HF::Core::GroupManagement::IServer::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.

◆ handle_command()

Common::Result HF::Core::GroupManagement::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.

◆ next_address()

uint16_t HF::Core::GroupManagement::IServer::next_address ( ) const
inline

Return next available address for device group.

Returns
the address to use in the next group, or GroupAddress::NO_ADDR if no address is available.

Definition at line 920 of file group_management.h.

References entries(), and HF::Core::GroupManagement::IEntries::next_address().

921  {
922  return entries().next_address();
923  }
virtual uint16_t next_address() const =0
Return next available address for device group.
virtual IEntries & entries() const =0
Get a reference to the current object implementing the persistence API, for the device information...
+ Here is the call graph for this function:

◆ number_of_groups()

uint8_t HF::Core::GroupManagement::IServer::number_of_groups ( ) const
inline

Get the Number Of Groups for the Group Management server.

Returns
the current Number Of Groups.

Definition at line 934 of file group_management.h.

References entries(), and HF::Common::IEntries< T >::size().

Referenced by number_of_groups_update().

935  {
936  return (uint8_t) entries().size();
937  }
virtual uint16_t size() const =0
Return the number of entries in the container.
virtual IEntries & entries() const =0
Get a reference to the current object implementing the persistence API, for the device information...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ number_of_groups_update()

void HF::Core::GroupManagement::IServer::number_of_groups_update ( int8_t  diff) const
inlineprotected

Get the Number Of Groups for the Group Management server.

Parameters
[in]diffnumber of groups added/removed.
Returns
the current Number Of Groups.

Definition at line 985 of file group_management.h.

References HF::Interfaces::AbstractInterface::notify(), and number_of_groups().

986  {
987  uint8_t value = number_of_groups();
988 
989  NumberOfGroups old_attr(value - diff, this);
990  NumberOfGroups new_attr(value, this);
991 
992  notify(old_attr, new_attr);
993  }
virtual void notify(const HF::Attributes::IAttribute &old_value, const HF::Attributes::IAttribute &new_value) const
Notify that an attribute value as changed.
Definition: interface.h:248
uint8_t number_of_groups() const
Get the Number Of Groups for the Group Management server.
+ Here is the call graph for this function:

◆ payload_size()

uint16_t HF::Core::GroupManagement::IServer::payload_size ( Protocol::Message::Interface itf) const
protectedvirtual

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 from HF::Interfaces::AbstractInterface.

◆ remove() [1/2]

virtual Common::Result HF::Core::GroupManagement::IServer::remove ( Protocol::Packet packet,
DeleteMessage msg 
)
virtual

Callback that is called when a GroupManagement::DELETE_CMD, is received.

Parameters
[in]packetthe message Packet.
[in]msgthe DeleteMessage received.
Returns
the response code sent in the response.

◆ remove() [2/2]

virtual Common::Result HF::Core::GroupManagement::IServer::remove ( Protocol::Packet packet,
const RemoveMessage msg 
)
virtual

Callback that is called when a GroupManagement::REMOVE_CMD, is received.

Parameters
[in]packetthe message Packet.
[in]msgthe RemoveMessage received.
Returns
the response code sent in the response.

◆ removed()

virtual void HF::Core::GroupManagement::IServer::removed ( const GroupPtr group,
const Member member 
)
inlinevirtual

Indicate that a device/unit was removed from an existing group.

Parameters
[in]grouppointer to the group entry corresponding to the affected group.
[in]memberreference to the member entry removed.

Definition at line 847 of file group_management.h.

References UNUSED.

848  {
849  UNUSED(group);
850  UNUSED(member);
851  }
#define UNUSED(x)
Helper macro to remove warning about unused function/method argument.

◆ unit0()

HF::Devices::Concentrator::IUnit0* HF::Core::GroupManagement::IServer::unit0 ( ) const

Return a reference to the unit that this service belongs to.

This is the same reference as AbstractService::unit, but static casted to allow access to the other interfaces.

Returns
a reference to the unit that holds this interface.

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