17 #ifndef HF_CORE_ATTRIBUTE_REPORTING_H 18 #define HF_CORE_ATTRIBUTE_REPORTING_H 30 namespace AttributeReporting
58 namespace AttributeReporting
90 typedef enum _Attributes
124 static constexpr uint16_t
min_size =
sizeof(uint8_t);
127 uint16_t
size()
const;
147 static constexpr uint16_t
min_size =
sizeof(uint8_t)
152 uint16_t
size()
const;
181 uint16_t
size()
const;
225 uint16_t size()
const;
237 typedef Common::SimpleList<Entry> Container;
239 typedef Container::iterator iterator;
241 typedef Container::const_iterator const_iterator;
264 uint16_t size()
const;
399 static constexpr uint16_t
min_size =
sizeof(uint8_t)
408 uint16_t
size(
bool with_uid)
const;
436 uint16_t size()
const;
448 typedef Common::SimpleList<Entry> Container;
450 typedef Container::iterator iterator;
452 typedef Container::const_iterator const_iterator;
461 uint16_t size()
const;
563 typedef std::shared_ptr<HF::Attributes::IAttribute> Attribute;
586 static constexpr uint16_t min_size =
sizeof(uint8_t)
608 uint16_t
size()
const;
669 uint16_t
size()
const;
690 uint16_t
size()
const;
715 uint16_t
size()
const;
791 uint16_t
size()
const;
814 std::vector<Report::Attribute> attributes;
827 uint16_t size()
const;
847 return attributes.size();
862 uint16_t size()
const;
889 uint16_t size()
const;
901 typedef Common::SimpleList<AttributeReporting::Periodic::Entry> Container;
903 typedef Container::iterator iterator;
905 typedef Container::const_iterator const_iterator;
912 uint16_t size()
const;
999 static constexpr uint16_t min_size =
sizeof(uint8_t)
1009 uint16_t
size()
const;
1016 uint16_t offset = 0);
1025 Attribute temp(attr);
1050 uint16_t size()
const;
1061 fields.push_back(std::move(field));
1089 uint16_t
size()
const;
1103 entries.push_front(std::move(entry));
1121 typedef Common::SimpleList<AttributeReporting::Event::Entry> Container;
1123 typedef Container::iterator iterator;
1125 typedef Container::const_iterator const_iterator;
1132 uint16_t size()
const;
1236 uint16_t size()
const;
1248 static constexpr uint8_t START_ADDR = 0x01;
1251 static constexpr uint8_t MAX_ADDR = 0x7E;
1254 static constexpr uint8_t ALL_ADDR = 0x7F;
1256 typedef std::vector<Periodic::Entry>::iterator periodic_iterator;
1257 typedef std::vector<Event::Entry>::iterator event_iterator;
1526 periodic_iterator begin, periodic_iterator end);
1539 event_iterator begin, event_iterator end);
1828 std::ostream &
operator<<(std::ostream &stream,
This message is used to delete a reporting rule.
uint32_t interval
Attribute indicating the time interval rule needs to be activated.
uint16_t unpack(HF::Attributes::FactoryGetter get_factory, const Common::ByteArray &array, uint16_t offset=0)
Read a message from a ByteArray.
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.
uint16_t unpack(const Common::ByteArray &array, uint16_t offset=0)
Read a message from a ByteArray.
uint16_t size() const
Number bytes needed to serialize the message.
iterator end()
Get an iterator to the end of the entries in this rule.
void update_interval(Protocol::Address &destination, Reference report, uint32_t interval)
Update the interval of an existent report.
virtual uint8_t count() const
Get the number of entries is this rule entry.
virtual uint16_t unpack(HF::Attributes::Factory factory, const Common::ByteArray &array, uint16_t offset=0)
Unpack an incoming attribute.
Parent class for all report rules.
This message is used to create a reporting rule.
Event notification entry.
Container entries
Entries container.
uint16_t entries_count()
Number of entries present in this rule.
Type
Types of reports send from the server to the client.
uint16_t size() const
Number bytes needed to serialize the message.
Reference report
Identification of the rule to add the entries to.
virtual HF::Units::IUnit & unit() const =0
Get the unit that contains this interface.
uint8_t count() const
Get the number of entries is this rule entry.
bool response(Message::Type type)
Check if message is a response.
const_iterator cbegin() const
Get a constant iterator to the start of the entries in this message.
This message is used to update the report interval.
Rule(Type type)
Constructor.
This represent the special unit with ID/UID = 0.
static constexpr uint16_t min_size
Minimum pack/unpack required data size.
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.
GroupAddress DeleteMessage
Message payload for a HF::GroupManagement::DELETE_CMD request.
uint8_t count() const
Get number of entries in this message.
virtual void notify(const HF::Attributes::IAttribute &old_value, const HF::Attributes::IAttribute &new_value) const
Notify that an attribute value as changed.
void add(const Entry &entry)
Add the given entry to rule.
Parent class for all notification entries.
void periodic(uint32_t time)
Handle periodic processing.
Common::Result handle_command(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.
uint16_t unpack(const Common::ByteArray &array, uint16_t offset=0)
Read a message from a ByteArray.
Number of event report entries attribute.
HF::Attributes::IAttribute * attribute(uint8_t uid)
Return a pointer to the interface attribute with the given uid.
virtual void updated(const Protocol::Address &address, const Response &response)
Event indicating the result of a UPDATE_INTERVAL_CMD.
Parent class for all report rule entries.
Attribute Reporting interface UID.
iterator end()
Get a iterator to the end of the entries in this rule.
This file contains the definitions for the attribute handling API in HAN-FUN.
Reference(uint8_t _type=0, uint8_t _id=0)
Constructor.
void add(Protocol::Address &destination, Reference report, periodic_iterator begin, periodic_iterator end)
Add the periodic entries from start to end into the rule with the given report reference, on the device with the given destination address.
Container entries
Container for the entries of this rule.
uint8_t count() const
Get the number of entries is this rule entry.
uint8_t pack_id
Attribute's Pack ID.
Return all mandatory attributes for the interface.
This file contains the common defines for the HAN-FUN library.
uint16_t unpack(const Common::ByteArray &array, uint16_t offset, bool with_uid)
Read a message from a ByteArray.
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.
iterator end()
Get a iterator to the end of the entries in this message.
static constexpr uint16_t min_size
Minimum pack/unpack required data size.
Helper class for using the Attribute Reporting service.
void response(Protocol::Packet &packet, Reference &report, Common::Result result)
Send the response to a command with the given result.
Helper class template for parent class implementation of the interfaces.
uint8_t attr_uid
Attribute UID.
uint16_t unpack_entry(const Common::ByteArray &array, uint16_t offset=0)
Read a message from a ByteArray.
Periodic notification entry.
virtual uint16_t entry_size() const
Get the minimum number of bytes required for unpacking an entry.
Number of periodic report entries attribute.
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.
Factory get_factory(Common::Interface itf)
Return the attribute factory associated with the given interface identifier.
uint16_t unpack(const Common::ByteArray &array, uint16_t offset=0)
Read a message from a ByteArray.
uint16_t unpack(HF::Attributes::FactoryGetter get_factory, const Common::ByteArray &array, uint16_t offset=0)
Read a message from a ByteArray.
const_iterator cbegin() const
Get a constant iterator to the start of the entries in this rule.
void set_attribute(HF::Attributes::IAttribute *attr)
Set the field's attribute to the given attribute in attr.
This is the parent class for all services implementations.
uint16_t size() const
Number bytes needed to serialize the message.
Attribute attribute
Attribute value.
Attribute Reporting - Server Role.
uint16_t size() const
Number bytes needed to serialize the message.
uint16_t unpack(HF::Attributes::Factory factory, const Common::ByteArray &array, uint16_t offset=0)
Unpack an incoming attribute.
High Threshold reached event.
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.
UpdateIntervalMessage(void)
Empty constructor.
virtual uint16_t unpack_entry(const Common::ByteArray &array, uint16_t offset=0)
Read a message from a ByteArray.
Reference report
Report reference this rule generates.
Protocol::Message * add(Reference report, periodic_iterator begin, periodic_iterator end)
Add the periodic entries from start to end into the rule with the given report reference.
Create a Periodic rule message.
Add entries into a event rule message.
Periodic report notification.
Attribute Reporting - Client Role.
Common::SimpleList< Periodic::Rule > periodic_rules
Periodic rules.
HF::Attributes::IAttribute * create_attribute(uint8_t uid)
Create an attribute object that can hold the attribute with the given uid. (HF::Core::AttributeReport...
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...
virtual void deleted(const Protocol::Address &address, const Response &response)
Event indicating the result of a DELETE_REPORT_CMD.
virtual void report(Type type, const Protocol::Address &address, const Common::ByteArray &payload, uint16_t offset)
Event indicating a PERIODIC_REPORT_CMD or a EVENT_REPORT_CMD.
Container entries
Container for the entries of the periodic rule.
uint8_t unit
Unit ID this entry to.
Container entries
Container that holds the entries present in the message.
Protocol::Message * destroy(Type type, uint8_t report_id)
Remove the rule with the given type and the given report_id.
static constexpr uint16_t min_size
Minimum pack/unpack required data size.
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.
uint16_t unpack(const Common::ByteArray &array, uint16_t offset=0)
Read a message from a ByteArray.
iterator begin()
Get a iterator to the start of the entries in this rule.
virtual Common::Result handle(const Report::Periodic::CreateMessage &message)
Handle a create periodic rule command.
static constexpr uint16_t min_size
Minimum pack/unpack required data size.
uint16_t unpack(HF::Attributes::Factory factory, const Common::ByteArray &array, uint16_t offset=0)
Unpack an incoming attribute.
Entry field for a given attribute.
Field for the entries in event notification.
uint8_t count() const
Get number of entries in this message.
Rule(uint32_t _interval=0)
Constructor.
uint16_t count(Type type) const
Get the number of rules for the given type.
Parent class for the messages to create reporting rule entries.
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.
std::vector< Field > fields
Vector containing the fields for the event entry.
uint16_t unpack(HF::Attributes::FactoryGetter get_factory, const Common::ByteArray &array, uint16_t offset=0)
Read a message from a ByteArray.
virtual void added(const Protocol::Address &address, const Response &response)
Event indicating the result of a ADD_PERIODIC_ENTRY_CMD or ADD_EVENT_ENTRY_CMD.
static constexpr uint16_t min_size
Minimum pack/unpack required data size.
Common::Interface itf
Interface UID this notification relates to.
uint16_t size() const
Number bytes needed to serialize the message.
Parent call for all reports.
Unit0 & unit() const
The device this unit is associated with.
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.
UpdateIntervalMessage(Type report_type, uint8_t ID, uint32_t interval)
Constructor.
virtual bool authorized(uint8_t member, Protocol::Address &source)
Check if the given command is authorized for the device with the given address.
Add entries into a periodic rule message.
uint16_t size() const
Number bytes needed to serialize the message.
uint16_t unpack(const Common::ByteArray &array, uint16_t offset=0)
Read a message from a ByteArray.
IServer(Unit0 &unit)
Constructor.
void destroy(Protocol::Address &destination, Type type, uint8_t report_id)
Remove the rule with the given type and the given report_id, on the device with the given destination...
This class represents a byte array.
iterator end()
Get a iterator to the end of the entries in this message.
Interface::Role role() const
Return the Interface::Role this interface implements.
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.
Update the interval of an existent report.
std::vector< Field > fields
Vector containing the fields for this entry.
uint16_t pack(Common::ByteArray &array, uint16_t offset, bool with_uid) const
Write the object on to a ByteArray so it can be sent over the network.
Number of report entries attribute.
static constexpr uint16_t min_size
Minimum pack/unpack required data size.
uint16_t size() const
Number bytes needed to serialize the message.
Entry(uint8_t _unit, Common::Interface _itf)
Constructor.
Common::Result handle_command(Protocol::Packet &packet, Common::ByteArray &payload, uint16_t offset)
Handle incoming messages from the network.
const_iterator cend() const
Get constant iterator to the end of the entries in this message.
uint32_t interval
The new interval.
Protocol::Address destination
Device address to create the report rule for.
static constexpr uint16_t min_size
Minimum pack/unpack required data size.
IAttribute *(* Factory)(uint8_t)
Attribute factory function type.
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.
Field(Type _type=COV, uint8_t _attr_uid=0)
Constructor.
iterator begin()
Get a iterator to the start of the entries in this rule.
Entry(uint8_t unit, Common::Interface itf)
Constructor.
const_iterator cend() const
Get constant iterator to the end of the entries in this 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.
void add(HF::Attributes::IAttribute *&attr)
Add attribute to this periodic report entry.
uint16_t entry_size() const
Get the minimum number of bytes required for unpacking an entry.
Common::SimpleList< Entry > entries
Entries for the event notification.
std::ostream & operator<<(std::ostream &stream, const HF::Core::AttributeReporting::CMD command)
Convert the given command into a string and write it to the given stream.
uint16_t unpack(const Common::ByteArray &array, uint16_t offset=0)
Read a message from a ByteArray.
uint8_t type
Report type : PERIODIC or EVENT.
bool check_uid(uint16_t uid) const
Check if the given UID matches the interface UID.
static constexpr uint16_t min_size
Minimum pack/unpack required data size.
This class represents a periodic rule for attribute reporting.
Reference report
Identification of the rule to delete.
Event(uint8_t id=0)
Constructor.
uint16_t size() const
Number bytes needed to serialize the message.
Interface::Role role() const
Return the Interface::Role this interface implements.
uint16_t size() const
Number bytes needed to serialize the message.
Common::ByteArray value
Field value.
Common::Interface itf
Interface UID.
uint16_t entry_size() const
Get the minimum number of bytes required for unpacking an entry.
Interface/Service Attribute API.
uint8_t unit
Unit id that originated this notification.
const_iterator cbegin() const
Get a constant iterator to the start of the entries in this message.
Add periodic report entry.
uint32_t last_time
Attribute indicating the last time rule was activated.
Reference report
Identification of the rule to delete.
const_iterator cbegin() const
Get a constant iterator to the start of the entries in this rule.
uint16_t unpack_entry(const Common::ByteArray &array, uint16_t offset=0)
Read a message from a ByteArray.
void clear()
Remove all entries in this rule.
static constexpr uint16_t min_size
Minimum pack/unpack required data size.
Common::SimpleList< Event::Rule > event_rules
Event rules.
const_iterator cend() const
Get constant iterator to the end of the entries in this rule.
This class represents the interface implemented by all HAN-FUN units.
Attributes::Factory(* FactoryGetter)(Common::Interface)
Function pointer to a function that returns the attribute factory associated with a given interface...
Parent class for the response messages.
void add(Field &field)
Add the given field into this entry.
void add(const AttributeReporting::Periodic::Entry &entry)
Add a periodic entry into this message.
uint16_t size() const
Number bytes needed to serialize the message.
const_iterator cend() const
Get constant iterator to the end of the entries in this rule.
virtual void created(const Protocol::Address &address, const Response &response)
Event indicating the result of a CREATE_PERIODIC_CMD or CREATE_EVENT_CMD.
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.
Create a Event rule message.
Server(Unit0 &unit)
Constructor.
static Report::Event::Entry * process(const AttributeReporting::Event::Entry &entry, const HF::Attributes::IAttribute &old_value, const HF::Attributes::IAttribute &new_value)
This function checks if any fields in the given event rule entry match the change for the attribute g...
#define UNUSED(x)
Helper macro to remove warning about unused function/method argument.
void clear()
Remove all entries in this rule.
iterator begin()
Get an iterator to the start of the entries in this rule.
uint16_t payload_size(Protocol::Message &message) const
Return the minimal payload size that should be present for the given message.
uint16_t unpack(HF::Attributes::Factory factory, const Common::ByteArray &array, uint16_t offset=0)
Unpack an incoming attribute.
Common::SimpleList< Entry > entries
Entries associated with this notification.
Abstract(uint8_t type=0, uint8_t id=0)
Constructor.
uint16_t size(bool with_uid) const
Number bytes needed to serialize the message.
Protocol::Message * update(Reference report, uint32_t new_interval)
Change the Update Interval for the specified report.
virtual uint16_t count(Type type) const
Get the number of rules for the given type.
iterator begin()
Get a iterator to the start of the entries in this rule.
This class represents an entry in a periodic rule.
Low Threshold reached event.
Attribute Reporting - Server Role.
static constexpr uint16_t min_size
Minimum pack/unpack required data size.
Protocol::Message * create(Protocol::Address &destination)
Create a new attribute reporting event rule for the device with the given address.
Entry(uint8_t unit, Common::Interface itf)
Constructor.
uint32_t last_time
Last time the periodic function was called.
Protocol::Address destination
Device/unit that will receive the report.
virtual uint8_t count() const
Get number of entries in this message.
void add(const Entry &entry)
Add the given entry to rule.
AttributeReporting::Event::Type type
Event type.
uint16_t entries_count()
Number of entries present in this rule.
Common::Result handle_command(Protocol::Packet &packet, Common::ByteArray &payload, uint16_t offset)
Handle incoming messages from the network.
Result
Commands result codes.
void add(const AttributeReporting::Event::Entry &entry)
Add a event entry into this 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.
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.
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.
void add(Entry &entry)
Add event entry into this event report.
Periodic(uint8_t id=0)
Constructor.
uint16_t unpack(const Common::ByteArray &array, uint16_t offset=0)
Read a message from a ByteArray.
uint32_t interval
Time interval to send the periodic report.
static constexpr uint16_t min_size
Minimum pack/unpack required data size.
void add(Entry &entry)
Add entry into this periodic report.
Top-level namespace for the HAN-FUN library.
void create(Protocol::Address &destination)
Create a new attribute reporting event rule on the device with the given destination address...