HAN-FUN API  1.5.3
This project provides the common implementation of ULE Alliance's HAN-FUN application protocol.
group_management.h
Go to the documentation of this file.
1 // =============================================================================
15 // =============================================================================
16 
17 #ifndef HF_CORE_GROUP_MANAGEMENT_H
18 #define HF_CORE_GROUP_MANAGEMENT_H
19 
20 #include "hanfun/protocol.h"
21 #include "hanfun/core.h"
22 
24 
25 #include <string>
26 #include <map>
27 #include <forward_list>
28 
29 namespace HF
30 {
31  // Forward declaration.
32  namespace Devices
33  {
34  namespace Concentrator
35  {
36  struct IUnit0;
37  } // namespace Concentrator
38  } // namespace Devices
39 
40  namespace Core
41  {
42  // Forward declaration.
43  namespace GroupManagement
44  {
45  class IServer;
46  }
47 
63 
67  namespace GroupManagement
68  {
78  typedef enum _CMD
80  {
81  CREATE_CMD = 0x01,
82  DELETE_CMD = 0x02,
83  ADD_CMD = 0x03,
84  REMOVE_CMD = 0x04,
85  GET_INFO_CMD = 0x05,
86  __LAST_CMD__ = GET_INFO_CMD
87  } CMD;
88 
90  typedef enum _Attributes
91  {
93  __LAST_ATTR__ = NUMBER_OF_GROUPS_ATTR
94  } Attributes;
95 
99  struct GroupAddress
100  {
101  uint16_t address;
102 
103  constexpr static uint16_t NO_ADDR = 0x0000;
104  constexpr static uint16_t START_ADDR = 0x0001;
105  constexpr static uint16_t END_ADDR = 0x7FFF;
106 
112  GroupAddress(uint16_t address = 0)
113  {
114  this->address = address;
115  }
116 
118  static constexpr uint16_t min_size = sizeof(uint16_t); // %Group Address
119 
121  uint16_t size() const;
122 
124  uint16_t pack(Common::ByteArray &array, uint16_t offset = 0) const;
125 
127  uint16_t unpack(const Common::ByteArray &array, uint16_t offset = 0);
128  };
129 
130 
131  // =============================================================================
132  // %Group Member Entry Data structure
133  // =============================================================================
134 
137 
138  // =============================================================================
139  // %Group Entry Data structure
140  // =============================================================================
141 
145  struct Group: public GroupAddress
146  {
147  typedef std::vector<Member> Container;
148 
149  std::string name;
150 
151  protected:
152 
153  Container _members;
154 
155  public:
156 
157  constexpr static uint16_t MAX_MEMBERS = GroupAddress::END_ADDR -
159 
166  Group(uint16_t address = 0, std::string name = ""):
168  {}
169 
170  // =============================================================================
171  // API
172  // =============================================================================
173 
179  const Container &members() const
180  {
181  return _members;
182  }
183 
192  Container::iterator find_member(const Member &member);
193 
203  Container::iterator find_member(uint16_t device, uint8_t unit)
204  {
205  const Member member(device, unit);
206 
207  return find_member(member);
208  }
209 
219  bool exists(const Member &member)
220  {
221  return !(find_member(member) == members().end());
222  }
223 
233  bool exists(uint16_t device, uint8_t unit)
234  {
235  const Member member(device, unit);
236 
237  return !(find_member(member) == members().end());
238  }
239 
248  bool add(const Member &member);
249 
259  bool add(uint16_t device, uint8_t unit)
260  {
261  const Member member(device, unit);
262 
263  return add(member);
264  }
265 
272  bool reserve()
273  {
274  HF_ASSERT(members().size() < MAX_MEMBERS, {return false;});
275  _members.push_back(Member());
276  return true;
277  }
278 
287  bool update(const Member &member);
288 
298  bool update(uint16_t device, uint8_t unit)
299  {
300  const Member member(device, unit);
301 
302  return update(member);
303  }
304 
313  bool remove(const Member &member);
314 
324  bool remove(uint16_t device, uint8_t unit)
325  {
326  const Member member(device, unit);
327 
328  return remove(member);
329  }
330 
331  // =============================================================================
332  // Operators
333  // =============================================================================
334 
336  bool operator==(const Group &other) const
337  {
338  if (this->address == other.address)
339  {
340  return true;
341  }
342  else
343  {
344  return false;
345  }
346  }
347 
349  bool operator!=(const Group &other) const
350  {
351  return !(*this == other);
352  }
353  };
354 
355  typedef Common::Pointer<Group> GroupPtr;
356 
361  {
362  std::string name;
363 
369  CreateMessage(std::string name = ""):
370  name(name)
371  {}
372 
373  // virtual ~CreateMessage();
374 
375  // =============================================================================
376  // Serializable API
377  // =============================================================================
378 
380  static constexpr uint16_t min_size = sizeof(uint8_t); // %Group Name (length)
381 
383  uint16_t size() const;
384 
386  uint16_t pack(Common::ByteArray &array, uint16_t offset = 0) const;
387 
389  uint16_t unpack(const Common::ByteArray &array, uint16_t offset = 0);
390 
391  };
392 
397  {
404  Protocol::Response(), GroupAddress(address)
405  {}
406 
414  uint16_t address = GroupAddress::NO_ADDR):
415  Protocol::Response(code), GroupAddress(address)
416  {}
417 
418  // =============================================================================
419  // Serializable API
420  // =============================================================================
421 
423  static constexpr uint16_t min_size = Protocol::Response::min_size; // Response Code
424 
425 
427  uint16_t size() const;
428 
430  uint16_t pack(Common::ByteArray &array, uint16_t offset = 0) const;
431 
433  uint16_t unpack(const Common::ByteArray &array, uint16_t offset = 0);
434 
435  };
436 
439 
442 
448  {
456  Message(uint16_t group, uint16_t device, uint8_t unit):
457  GroupAddress(group), Protocol::Address(device, unit)
458  {}
459 
466  {}
467 
468  // =============================================================================
469  // Serializable API
470  // =============================================================================
471 
473  static constexpr uint16_t min_size = GroupAddress::min_size
475 
477  uint16_t size() const;
478 
480  uint16_t pack(Common::ByteArray &array, uint16_t offset = 0) const;
481 
483  uint16_t unpack(const Common::ByteArray &array, uint16_t offset = 0);
484  };
485 
488 
491 
494 
497 
500 
503  {
504  std::string name;
505  std::vector<Member> members;
506 
513  InfoResponse(const std::string &name, std::vector<Member> &members):
514  Protocol::Response(), name(name), members(members)
515  {}
516 
524  InfoResponse(Common::Result code, const std::string &name,
525  std::vector<Member> &members):
526  Protocol::Response(code), name(name), members(members)
527  {}
528 
535  {}
536 
538  static constexpr uint16_t min_size = Protocol::Response::min_size;
539 
541  uint16_t size() const;
542 
544  uint16_t pack(Common::ByteArray &array, uint16_t offset = 0) const;
545 
547  uint16_t unpack(const Common::ByteArray &array, uint16_t offset = 0);
548  };
549 
550  // =============================================================================
551  // Attribute Helper classes
552  // =============================================================================
553 
558  {
559  static constexpr uint8_t ID = NUMBER_OF_GROUPS_ATTR;
560  static constexpr bool WRITABLE = false;
561 
562  NumberOfGroups(uint8_t value = 0, const HF::Interface *owner = nullptr):
563  Attribute<uint8_t>(HF::Interface::GROUP_MANAGEMENT, ID, owner, value, WRITABLE)
564  {}
565  };
566 
578 
582  struct IEntries: public Common::IEntries<Group>
583  {
585 
595  virtual Common::Result save(uint16_t address, const std::string &name) = 0;
596 
598 
607  virtual Common::Result destroy(const uint16_t address) = 0;
608 
617  virtual GroupPtr find(const uint16_t address) const = 0;
618 
627  virtual GroupPtr find(const std::string &name) const = 0;
628 
635  virtual uint16_t next_address() const = 0;
636  };
637 
641  struct Entries: public IEntries
642  {
643  typedef std::map<uint16_t, Group> Container;
644  typedef Container::iterator iterator;
645  typedef Container::const_iterator const_iterator;
646  typedef Container::value_type value_type;
647 
648  virtual ~Entries() {}
649 
650  uint16_t size() const;
651 
652  Common::Result save(const Group &entry);
653 
654  Common::Result save(uint16_t address, const std::string &name);
655 
656  Common::Result destroy(const uint16_t address);
657 
669  Common::Result destroy(const Group &entry);
670 
671  GroupPtr find(uint16_t address) const;
672 
673  GroupPtr find(const std::string &name) const;
674 
675  uint16_t next_address() const;
676 
682  iterator begin()
683  {
684  return db.begin();
685  }
686 
692  iterator end()
693  {
694  return db.end();
695  }
696 
702  const_iterator begin() const
703  {
704  return db.cbegin();
705  }
706 
712  const_iterator end() const
713  {
714  return db.cend();
715  }
716 
717  protected:
718 
720  Container db;
721  };
722 
728  struct Base: public Service<HF::Interface::GROUP_MANAGEMENT>
729  {
730  protected:
731 
734  };
735 
736  // Forward declaration.
737  struct IGroupTable;
738 
744  class IServer: public ServiceRole<GroupManagement::Base, HF::Interface::SERVER_ROLE>
745  {
747 
748  public:
749 
752 
754  virtual ~IServer() {}
755 
756  // ======================================================================
757  // Events
758  // ======================================================================
761 
771  virtual Common::Result create(Protocol::Packet &packet, CreateMessage &msg);
772 
779  virtual void created(const GroupPtr &group)
780  {
781  UNUSED(group);
782  }
783 
793  virtual Common::Result remove(Protocol::Packet &packet, DeleteMessage &msg);
794 
800  virtual void deleted(const Group &group)
801  {
802  UNUSED(group);
803  }
804 
814  virtual Common::Result add(Protocol::Packet &packet, const AddMessage &msg);
815 
824  virtual void added(const GroupPtr &group, const Member &member)
825  {
826  UNUSED(group);
827  UNUSED(member);
828  }
829 
839  virtual Common::Result remove(Protocol::Packet &packet, const RemoveMessage &msg);
840 
847  virtual void removed(const GroupPtr &group, const Member &member)
848  {
849  UNUSED(group);
850  UNUSED(member);
851  }
852 
853 #ifdef HF_CORE_GROUP_MANAGEMENT_GET_INFO_CMD
854 
863  virtual Common::Result get_info(Protocol::Packet &packet, const InfoMessage &msg);
864 #endif
865 
867  // ======================================================================
868 
869  // =============================================================================
870  // API
871  // =============================================================================
872 
882 
889  virtual IEntries &entries() const = 0;
890 
899  GroupPtr entry(const uint16_t address) const
900  {
901  return entries().find(address);
902  }
903 
912  GroupPtr entry(const std::string &name) const
913  {
914  return entries().find(name);
915  }
916 
920  uint16_t next_address() const
921  {
922  return entries().next_address();
923  }
924 
925  // =============================================================================
926  // Get/Set API.
927  // =============================================================================
928 
934  uint8_t number_of_groups() const
935  {
936  return (uint8_t) entries().size();
937  }
938 
939  // =============================================================================
940  // Attribute API.
941  // =============================================================================
942 
944 
947  {
948  UNUSED(pack_id);
950  }
951 
953  uint16_t offset);
954 
955  protected:
956 
969  virtual bool authorized(CMD member, const Protocol::Address &source,
970  const Protocol::Address &destination)
971  {
972  UNUSED(member);
973  UNUSED(source);
974  UNUSED(destination);
975  return true;
976  }
977 
985  void number_of_groups_update(int8_t diff) const
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  }
994 
995  uint16_t payload_size(Protocol::Message::Interface &itf) const;
996 
998  uint16_t offset);
999 
1009  void added(const Protocol::Address &addr, Common::Result result,
1010  const AddMessage &request, uint8_t reference);
1011 
1017  virtual IGroupTable &group_table() const = 0;
1018 
1019  friend struct IGroupTable;
1020  };
1021 
1031  {
1037  IGroupTable(IServer &_server): GroupTable::Client(_server.unit()),
1038  server(_server)
1039  {}
1040 
1044 
1052  virtual void add(const Protocol::Address &source, const Message &request,
1053  uint8_t reference);
1054 
1055  protected:
1056 
1057  IServer &server;
1058 
1060 
1061  void added(const Protocol::Address &dest, Common::Result result,
1062  const AddMessage &request, uint8_t reference)
1063  {
1064  server.added(dest, result, request, reference);
1065  }
1066  };
1067 
1072  {
1073  typedef std::tuple<Protocol::Address, Message, uint8_t> Entry;
1074 
1075  enum Fields
1076  {
1077  ADDRESS,
1078  MESSAGE,
1079  REFERENCE,
1080  };
1081 
1082  GroupTableClient(IServer &_server): IGroupTable(_server)
1083  {}
1084 
1086  void add(const Protocol::Address &source, const AddMessage &request,
1087  uint8_t reference);
1088 
1089  protected:
1090 
1091  std::forward_list<Entry> requests;
1092 
1093  using IGroupTable::added;
1094 
1096  void added(const Protocol::Address &addr, const GroupTable::Response &response);
1097  };
1098 
1103  template<typename _Entries = Entries, typename _GroupTable = GroupTableClient>
1104  class Server: public IServer
1105  {
1106  protected:
1107 
1108  _Entries _entries;
1109  _GroupTable _group_table;
1110 
1111  public:
1112 
1118  Server(Unit0 &unit): IServer(unit), _group_table(*this)
1119  {}
1120 
1126  Server(const Server &other):
1127  IServer(other._unit), _group_table(*this)
1128  {}
1129 
1130  virtual ~Server()
1131  {}
1132 
1133  _Entries &entries() const
1134  {
1135  return const_cast<_Entries &>(_entries);
1136  }
1137 
1138  protected:
1139 
1140  _GroupTable &group_table() const
1141  {
1142  return const_cast<_GroupTable &>(_group_table);
1143  }
1144  };
1145 
1146  typedef Server<> DefaultServer;
1147 
1153  struct Client: public ServiceRole<GroupManagement::Base, HF::Interface::CLIENT_ROLE>
1154  {
1157 
1158  virtual ~Client() {}
1159 
1160  // ======================================================================
1161  // Commands
1162  // ======================================================================
1165 
1172  void create(std::string name);
1173 
1180  void remove(uint16_t group);
1181 
1191  void add(uint16_t group, uint16_t device, uint8_t unit);
1192 
1202  void remove(uint16_t group, uint16_t device, uint8_t unit);
1203 
1204 #ifdef HF_CORE_GROUP_MANAGEMENT_GET_INFO_CMD
1205 
1211  void get_info(uint16_t group);
1212 #endif
1213 
1215  // ======================================================================
1216 
1217  // ======================================================================
1218  // Events
1219  // ======================================================================
1222 
1229  virtual void created(CreateResponse &response) = 0;
1230 
1237  virtual void deleted(DeleteResponse &response) = 0;
1238 
1245  virtual void added(AddResponse &response) = 0;
1246 
1253  virtual void removed(RemoveResponse &response) = 0;
1254 
1261  virtual void got_info(InfoResponse &response) = 0;
1262 
1264  // ======================================================================
1265 
1266  protected:
1267 
1268  using ServiceRole::payload_size;
1269 
1270  uint16_t payload_size(Protocol::Message::Interface &itf) const;
1271 
1273  uint16_t offset);
1274 
1275  };
1276 
1279  } // namespace GroupManagement
1280 
1281  } // namespace Core
1282 
1283 } // namespace HF
1284 
1290 // =============================================================================
1291 // Stream Helpers
1292 // =============================================================================
1293 
1302 std::ostream &operator<<(std::ostream &stream, const HF::Core::GroupManagement::CMD command);
1303 
1312 std::ostream &operator<<(std::ostream &stream,
1313  const HF::Core::GroupManagement::Attributes attribute);
1316 #endif /* HF_CORE_GROUP_MANAGEMENT_H */
virtual uint16_t next_address() const =0
Return next available address for device group.
Message payload for a HF::GroupManagement::GET_INFO_CMD response.
static constexpr uint16_t min_size
Minimum pack/unpack required data size.
uint8_t unit
Source Unit.
Definition: protocol.h:206
Parent class for the message payload for a HF::GroupManagement::ADD_CMD and HF::GroupManagement::REMO...
_GroupTable & group_table() const
Get the Group Table client associated with this Group Management server.
bool request(Message::Type type, bool response=false)
Check if message type is a request.
Group Management interface UID.
Definition: interface.h:62
IServer(Unit0 &unit)
Constructor.
bool update(uint16_t device, uint8_t unit)
Update a reserved entry with the given member.
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...
bool response(Message::Type type)
Check if message is a response.
Default implementation of the persistence API.
bool reserve()
Reserve a member in group members entries.
Default implementation of the IGroupTable interface.
This represent the special unit with ID/UID = 0.
Definition: core.h:67
uint16_t pack(Common::ByteArray &array, uint16_t offset=0) const
Write the object on to a ByteArray so it can be sent over the network.
GroupAddress DeleteMessage
Message payload for a HF::GroupManagement::DELETE_CMD request.
static constexpr uint16_t min_size
Minimum pack/unpack required data size.
bool operator==(const Group &other) const
Equals operator.
void number_of_groups_update(int8_t diff) const
Get the Number Of Groups for the Group Management server.
Server(const Server &other)
Copy-Constructor.
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
uint16_t size() const
Number bytes needed to serialize the message.
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 af...
CreateResponse(Common::Result code=Common::Result::OK, uint16_t address=GroupAddress::NO_ADDR)
Constructor.
InfoResponse(const std::string &name, std::vector< Member > &members)
Constructor.
_Entries & entries() const
Get a reference to the current object implementing the persistence API, for the device information...
This class represents a group of devices.
List of attributes UIDs.
Definition: attributes.h:176
Return all mandatory attributes for the interface.
Definition: attributes.h:842
#define HF_ASSERT(_expr, _block)
Helper macro to check for correct assumptions.
This file contains the forward declarations of the core services and interfaces implementing classes...
Common::Result handle(Protocol::Packet &packet, Common::ByteArray &payload, uint16_t offset)
Handle incoming messages from the network.
static constexpr uint16_t min_size
Minimum pack/unpack required data size.
Definition: protocol.h:230
virtual void added(AddResponse &response)=0
This method is called when a response to a add message is received.
bool add(const Member &member)
Add the given member to the group.
uint16_t pack(Common::ByteArray &array, uint16_t offset=0) const
Write the object on to a ByteArray so it can be sent over the network.
bool exists(uint16_t device, uint8_t unit)
Check if a member equal to the given member already exists in the group.
virtual Common::Result add(Protocol::Packet &packet, const AddMessage &msg)
Callback that is called when a GroupManagement::ADD_CMD, is received.
Container::iterator find_member(uint16_t device, uint8_t unit)
Find a group member equal to the given member.
Protocol::Response RemoveResponse
Message payload for a HF::GroupManagement::REMOVE_CMD response.
bool exists(const Member &member)
Check if a member equal to the given member already exists in the group.
virtual void removed(RemoveResponse &response)=0
This method is called when a response to a remove message is received.
Address(uint16_t _dev=BROADCAST_ADDR, uint8_t _unit=BROADCAST_UNIT, Type _mod=DEVICE)
Create a new message address.
Definition: protocol.h:224
static constexpr uint16_t END_ADDR
Last HAN-FUN Group Address.
Group Management Service : Parent.
Group(uint16_t address=0, std::string name="")
Constructor.
CreateMessage(std::string name="")
Constructor.
This file contains the definitions for the HAN-FUN protocol messages.
This class represents a group address.
void remove(const Protocol::Address &addr, const Entry &entry)
Send a HAN-FUN message containing a GroupTable::REMOVE_CMD, to the given network address.
Group Table Service : Client side implementation.
Definition: group_table.h:610
const_iterator end() const
Get a constant iterator to the start of the entries in this container.
Message(uint16_t group, uint16_t device, uint8_t unit)
Constructor.
std::ostream & operator<<(std::ostream &stream, const HF::Core::GroupManagement::CMD command)
Convert the given command into a string and write it to the given stream.
IGroupTable(IServer &_server)
Constructor.
iterator end()
Get an iterator to the end of the entries in this container.
virtual uint16_t size() const =0
Return the number of entries in the container.
Container::iterator find_member(const Member &member)
Find a group member equal to the given member.
Message payload for a HF::GroupManagement::CREATE_CMD request.
InfoResponse(Common::Result code, const std::string &name, std::vector< Member > &members)
Constructor.
virtual void add(const Protocol::Address &source, const Message &request, uint8_t reference)
Send a GroupTable::ADD_CMD to the device given by the AddMessage request.
Helper class to handle the Number Of Groups attribute for the Group Management service.
static constexpr bool WRITABLE
Attribute Read/Write.
HF::Devices::Concentrator::IUnit0 * unit0() const
Return a reference to the unit that this service belongs to.
Common::Result handle_command(Protocol::Packet &packet, Common::ByteArray &payload, uint16_t offset)
Handle incoming messages from the network.
uint16_t size() const
Number bytes needed to serialize the message.
uint16_t pack(Common::ByteArray &array, uint16_t offset=0) const
Write the object on to a ByteArray so it can be sent over the network.
const Container & members() const
Return a reference to the members of the group.
GroupPtr entry(const uint16_t address) const
Get the group entry given by address.
const_iterator begin() const
Get a constant iterator to the start of the entries in this container.
virtual void created(CreateResponse &response)=0
This method is called when a response to a create message is received.
uint16_t unpack(const Common::ByteArray &array, uint16_t offset=0)
Read a message from a ByteArray.
GroupAddress InfoMessage
Message payload for a HF::GroupManagement::GET_INFO_CMD request.
uint16_t size() const
Number bytes needed to serialize the message.
Message AddMessage
Message payload for a HF::GroupManagement::ADD_CMD request.
Unit 0 interface API for HAN-FUN Concentrators.
Definition: devices.h:607
uint16_t uid() const
This method returns the interface UID.
Definition: core.h:191
HF::Interface const * owner() const
Definition: attributes.h:414
static constexpr uint16_t START_ADDR
First HAN-FUN Group Address.
Container _members
Group Members
bool update(const Member &member)
Update a reserved entry with the given member.
uint16_t pack(Common::ByteArray &array, uint16_t offset=0) const
Write the object on to a ByteArray so it can be sent over the network.
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
virtual IGroupTable & group_table() const =0
Get the Group Table client associated with this Group Management server.
bool operator!=(const Group &other) const
Not equals operator.
This class represents a byte array.
virtual void deleted(DeleteResponse &response)=0
This method is called when a response to a delete message is received.
Common::Result destroy(const uint16_t address)
Destroy the entry given by address in the persistent storage.
void add(uint16_t group, uint16_t device, uint8_t unit)
Send a HAN-FUN message containing a GroupManagement::ADD_CMD, to the D:0/U:0 network address...
Network Address.
Definition: protocol.h:201
Protocol::Address Member
This class represents a member of a group.
Interface Address.
Definition: protocol.h:93
Server(Unit0 &unit)
Constructor.
Protocol::Response DeleteResponse
Message payload for a HF::GroupManagement::DELETE_CMD response.
uint16_t size() const
Number bytes needed to serialize the message.
CreateResponse(uint16_t address)
Constructor.
Base class for responses.
Definition: group_table.h:156
uint8_t number_of_groups() const
Get the Number Of Groups for the Group Management server.
static constexpr uint16_t min_size
Minimum pack/unpack required data size.
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...
static constexpr uint8_t ID
Attribute UID.
GroupPtr entry(const std::string &name) const
Get the group entry given by name.
bool add(uint16_t device, uint8_t unit)
Add the given member to the group.
virtual void deleted(const Group &group)
Indicate that a group was deleted.
HAN-FUN Protocol Packet.
Definition: protocol.h:298
virtual void added(const Protocol::Address &addr, const GroupTable::Response &response)
Callback for processing the response of a GroupTable::ADD_CMD.
virtual GroupPtr find(const uint16_t address) const =0
Find the group with the given group address.
uint16_t next_address() const
Return next available address for device group.
void add(const Protocol::Address &source, const AddMessage &request, uint8_t reference)
Send a GroupTable::ADD_CMD to the device given by the AddMessage request.
GroupPtr find(uint16_t address) const
Find the group with the given group address.
virtual Common::Result create(Protocol::Packet &packet, CreateMessage &msg)
Callback that is called when a GroupManagement::CREATE_CMD, is received.
Interface/Service Attribute API.
Definition: attributes.h:44
Device Management - Persistent Storage API.
virtual Common::Result save(uint16_t address, const std::string &name)=0
Store the given entry to persistent storage.
virtual void got_info(InfoResponse &response)=0
This method is called when a response to a get info message is received.
uint16_t unpack(const Common::ByteArray &array, uint16_t offset=0)
Read a message from a ByteArray.
Message RemoveMessage
Message payload for a HF::GroupManagement::REMOVE_CMD request.
HF::Attributes::IAttribute * attribute(uint8_t uid)
Return a pointer to the interface attribute with the given uid.
static constexpr uint16_t min_size
Minimum pack/unpack required data size.
Parent class for the response messages.
Definition: protocol.h:368
uint16_t device
Device Address.
Definition: protocol.h:204
Class template for all interfaces role implementations.
Definition: core.h:225
uint16_t unpack(const Common::ByteArray &array, uint16_t offset=0)
Read a message from a ByteArray.
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.
Simple raw pointer wrapper.
Group Management Service : Client side implementation.
#define UNUSED(x)
Helper macro to remove warning about unused function/method argument.
Protocol::Response AddResponse
Message payload for a HF::GroupManagement::ADD_CMD response.
Helper template class to declare an attribute with the given T type.
Definition: attributes.h:349
virtual void removed(const GroupPtr &group, const Member &member)
Indicate that a device/unit was removed from an existing group.
virtual Common::Result destroy(const uint16_t address)=0
Destroy the entry given by address in the persistent storage.
Attribute(const uint16_t interface, const uint8_t uid, const HF::Interface *__owner, uint8_t data, bool writable=false)
Attribute template constructor.
Definition: attributes.h:360
static constexpr uint16_t min_size
Minimum number of bytes required by this message.
Definition: protocol.h:375
HF::Attributes::IAttribute * create_attribute(uint8_t uid)
Create an attribute object that can hold the attribute with the given uid.
This file contains the definitions for the Group Table service.
virtual void added(const GroupPtr &group, const Member &member)
Indicate that a new device/unit was added to an existing group.
Common interface for all Interfaces.
Definition: interface.h:43
static constexpr uint16_t min_size
Minimum pack/unpack required data size.
void create(std::string name)
Send a HAN-FUN message containing a GroupManagement::CREATE_CMD, to the D:0/U:0 network address...
iterator begin()
Get an iterator to the start of the entries in this container.
Common::Result handle(Protocol::Packet &packet, Common::ByteArray &payload, uint16_t offset)
Handle incoming messages from the network.
Helper class used to implement custom functionality to the group management server side...
virtual void created(const GroupPtr &group)
Indicate that a new group was created.
virtual IEntries & entries() const =0
Get a reference to the current object implementing the persistence API, for the device information...
uint16_t unpack(const Common::ByteArray &array, uint16_t offset=0)
Read a message from a ByteArray.
Message payload for a HF::GroupManagement::CREATE_CMD response.
Group Management Service : Server side implementation.
uint16_t size() const
Number bytes needed to serialize the message.
Class template for all core services implementations.
Definition: core.h:188
Base(Unit0 &unit)
Constructor.
uint16_t unpack(const Common::ByteArray &array, uint16_t offset=0)
Read a message from a ByteArray.
Result
Commands result codes.
uint16_t pack(Common::ByteArray &array, uint16_t offset=0) const
Write the object on to a ByteArray so it can be sent over the network.
void added(const Protocol::Address &addr, const GroupTable::Response &response)
Callback for processing the response of a GroupTable::ADD_CMD.
Container db
Actual container for the entries.
GroupAddress(uint16_t address=0)
Constructor.
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.
Common::Result handle_command(Protocol::Packet &packet, Common::ByteArray &payload, uint16_t offset)
Handle incoming messages from the network.
uint16_t next_address() const
Return next available address for device group.
Interface to the HF::GroupTable API used to update the device&#39;s group tables entries on add/remove ev...
static constexpr uint16_t NO_ADDR
Empty Group Address.
uint16_t size() const
Return the number of entries in the container.
Basic API for persistent storage implementations.
Top-level namespace for the HAN-FUN library.
Definition: attributes.h:22