HAN-FUN API  1.5.3
This project provides the common implementation of ULE Alliance's HAN-FUN application protocol.
HF::Unit0< Base, ITF > Class Template Reference

Helper template class used to define custom Unit 0 for devices. More...

#include <core.h>

+ Inheritance diagram for HF::Unit0< Base, ITF >:
+ Collaboration diagram for HF::Unit0< Base, ITF >:

Public Types

enum  Inferface : uint8_t { DEV_INFO = 0, DEV_MGT, ATTR_RPT, BIND_MGT }
 Core Services indexs. More...
 

Public Member Functions

 Unit0 (HF::IDevice &device)
 Constructor. More...
 
DeviceInfo * device_info () const
 Device Information service. More...
 
DeviceInfo * device_info ()
 Device Information service. More...
 
DeviceMgt * device_management () const
 Device Management service. More...
 
DeviceMgt * device_management ()
 Device Management service. More...
 
AttrReporting * attribute_reporting () const
 Attribute Reporting service. More...
 
AttrReporting * attribute_reporting ()
 Attribute Reporting service. More...
 
Common::Result handle (HF::Protocol::Packet &packet, Common::ByteArray &payload, uint16_t offset)
 Handle incoming messages from the network. More...
 
HF::Attributes::List attributes (Common::Interface itf, uint8_t pack_id, const HF::Attributes::UIDS &uids) const
 Return a list of all the attributes for a given interface, pack id and list of attributes UID's. More...
 
void periodic (uint32_t time)
 Handle periodic processing. More...
 
- Public Member Functions inherited from Base
void receive (HF::Protocol::Packet &packet, HF::Common::ByteArray &payload, uint16_t offset)
 Callback to deliver a packet received from the transport layer. More...
 
bool has_bind (uint16_t dev_addr_1, uint16_t dev_addr_2)
 Check if bind exists. More...
 
uint8_t bind (uint16_t dev_addr_1, uint16_t dev_addr_2)
 Create a new bind entry. More...
 
bool unbind (uint16_t dev_addr_1, uint16_t dev_addr_2)
 Remove the binding entry for the given devices. More...
 
- Public Member Functions inherited from HF::Devices::Concentrator::Abstract< CoreServices >
CoreServices * unit0 () const
 Get the unit 0 used by this concentrator device. More...
 
- Public Member Functions inherited from HF::Devices::Concentrator::AbstractBase
uint16_t address () const
 Return the device address on the HAN-FUN network, when the device is registered, or HF_BROADCAST_ADDR otherwise. More...
 
void connected (HF::Transport::Link *link)
 Callback to report that a new transport link was been created to a remote device. More...
 
void disconnected (HF::Transport::Link *link)
 Callback to the report that the given transport link no longer is valid and MUST not be used to send messages to the corresponding end-point. More...
 
- Public Member Functions inherited from HF::Devices::AbstractDevice
const IUnitsunits () const
 Return the list of units registered in this device. More...
 
void add (Units::IUnit *unit)
 Add unit to devices unit lists. More...
 
void remove (Units::IUnit *unit)
 Remove unit from device's unit list. More...
 
Units::IUnitunit (uint8_t id) const
 Return pointer to the unit with the given id. More...
 
void send (Protocol::Packet &packet)
 Send given packet into the HAN-FUN network. More...
 
void periodic (uint32_t time)
 Handle periodic processing. More...
 
Events
- Public Member Functions inherited from HF::Interfaces::Container< Base, Proxy< ITF, Base >... >
 Container (Base &base)
 Constructor. More...
 
Common::Result handle (Protocol::Packet &packet, Common::ByteArray &payload, uint16_t offset)
 Handle incoming messages from the network. More...
 
void attributes (HF::Attributes::List &attr_list, Common::Interface itf, uint8_t pack_id, const HF::Attributes::UIDS &uids) const
 Return a list of all the attributes for a given interface, pack id and list of attributes UID's. More...
 
std::vector< Common::Interfaceinterfaces () const
 Return the list of interfaces present in the wrapper. More...
 
const std::tuple_element< N, interfaces_t >::type::base * get () const
 Retrieve a pointer to the N optional interface implemented by this unit. More...
 

Additional Inherited Members

- Protected Member Functions inherited from HF::Devices::Concentrator::AbstractBase
HF::Transport::Linklink (uint16_t addr) const
 Return the link that can be used to send a packet to the device with the given address. More...
 
virtual void route_packet (Protocol::Packet &packet, Common::ByteArray &payload, uint16_t offset)
 Route the given packet to the corresponding device. More...
 
- Protected Member Functions inherited from HF::Devices::AbstractDevice
virtual bool to_local (const Protocol::Packet &packet) const
 Check if the given packet is for this device. More...
 
bool from_local (const Protocol::Packet &packet) const
 Check if the given packet is from the local device. More...
 
bool from_remote (const Protocol::Packet &packet)
 Check if the given packet is from the a remote device. More...
 
bool is_registered ()
 Check if the device has a valid, i.e. More...
 
- Protected Member Functions inherited from HF::Interfaces::Container< Base, Proxy< ITF, Base >... >
void for_each (std::function< void(HF::Interface &)> func) const
 Call the given function for all the interfaces. More...
 
void for_each (std::function< void(HF::Interface &)> func)
 Call the given function for all the interfaces. More...
 
void for_each (std::function< void(HF::Interface &)> func) const
 Helper template function to implement the HF::Units::Unit::for_each functionality. More...
 
void for_each (std::function< void(HF::Interface &)> func) const
 Helper template function to implement the HF::Units::Unit::for_each functionality. More...
 
HF::Interfacefind (uint16_t itf_uid) const
 Find the interface with the given UID. More...
 
HF::Interfacefind (uint16_t itf_uid) const
 Final template instantiation that finds the wrapped interface with the given UID. More...
 
void attributes_itf (HF::Attributes::List &attrs, Common::Interface itf, uint8_t pack_id, const HF::Attributes::UIDS &uids) const
 Helper function used to provide HF::Units::Unit::attributes functionality. More...
 
void attributes_itf (HF::Attributes::List &attrs, Common::Interface itf, uint8_t pack_id, const HF::Attributes::UIDS &uids) const
 Helper function used to provide HF::Units::Unit::attributes functionality. More...
 
- Protected Attributes inherited from HF::Devices::Concentrator::AbstractBase
Common::SimpleList< Transport::Link * > _links
 List of links present in this concentrator.
 
- Protected Attributes inherited from HF::Devices::AbstractDevice
uint8_t next_reference
 Last reference number used to send a packet.
 
IUnits _units
 List containing pointers to the units present in the device.
 
Protocol::Filters::ResponseRequired response_filter
 Support for generating missing responses for messages.
 

Detailed Description

template<typename Base, typename... ITF>
class HF::Unit0< Base, ITF >

Helper template class used to define custom Unit 0 for devices.

Template Parameters
Baseparent class.
ITFcustom classes implementing the required services.

Definition at line 264 of file core.h.

Member Enumeration Documentation

◆ Inferface

template<typename Base, typename... ITF>
enum HF::Unit0::Inferface : uint8_t

Core Services indexs.

Enumerator
DEV_INFO 

Device Information service index.

DEV_MGT 

Device Management service index.

ATTR_RPT 

Attribute Reporting service index.

BIND_MGT 

Bind Management service index.

Definition at line 275 of file core.h.

275  : uint8_t
276  {
277  DEV_INFO = 0,
278  DEV_MGT,
279  ATTR_RPT,
280 #if HF_TIME_SUPPORT
281  TIME,
282 #endif
283 #if HF_BATCH_PROGRAM_SUPPORT
284  BATCH_PROGRAM,
285 #endif
286 #if HF_EVENT_SCHEDULING_SUPPORT
287  EVENT_SCH,
288 #endif
289 #if HF_WEEKLY_SCHEDULING_SUPPORT
290  WEEKLY_SCH,
291 #endif
292 #if HF_GROUP_SUPPORT
293  GROUP_TABLE,
294  GROUP_MGT,
295 #endif
296  BIND_MGT,
297  };
Attribute Reporting service index.
Definition: core.h:279
Device Information service index.
Definition: core.h:277
Device Management service index.
Definition: core.h:278
Bind Management service index.
Definition: core.h:296

Constructor & Destructor Documentation

◆ Unit0()

template<typename Base, typename... ITF>
HF::Unit0< Base, ITF >::Unit0 ( HF::IDevice device)
inline

Constructor.

Parameters
[in]devicereference to the device that this unit belongs to.

Definition at line 351 of file core.h.

351  :
352  Base(device), InterfacesWrapper(*(static_cast<Base *>(this)))
353  {}
This class represents a HAN-FUN Concentrator.
Definition: base.h:302

Member Function Documentation

◆ attribute_reporting() [1/2]

template<typename Base, typename... ITF>
AttrReporting* HF::Unit0< Base, ITF >::attribute_reporting ( ) const
inline

Attribute Reporting service.

Returns
pointer to the Attribute Reporting service

Definition at line 402 of file core.h.

403  {
404  return get<AttrReporting, ATTR_RPT>();
405  }

◆ attribute_reporting() [2/2]

template<typename Base, typename... ITF>
AttrReporting* HF::Unit0< Base, ITF >::attribute_reporting ( )
inline

Attribute Reporting service.

Returns
pointer to the Attribute Reporting service

Definition at line 412 of file core.h.

413  {
414  return get<AttrReporting, ATTR_RPT>();
415  }

◆ attributes()

template<typename Base, typename... ITF>
HF::Attributes::List HF::Unit0< Base, ITF >::attributes ( Common::Interface  itf,
uint8_t  pack_id,
const HF::Attributes::UIDS uids 
) const
inline

Return a list of all the attributes for a given interface, pack id and list of attributes UID's.

Parameters
[in]itfinterface UID.
[in]pack_idattribute pack id.
[in]uidslist of attributes UID's.
Returns
attribute list.

Definition at line 554 of file core.h.

556  {
557  HF::Attributes::List result;
558  InterfacesWrapper::attributes(result, itf, pack_id, uids);
559  return result;
560  }
This class has the same behavior has a list, however the list element access methods where overwritte...
Definition: attributes.h:752
void attributes(HF::Attributes::List &attr_list, Common::Interface itf, uint8_t pack_id, const HF::Attributes::UIDS &uids) const
Return a list of all the attributes for a given interface, pack id and list of attributes UID&#39;s...
Definition: interface.h:483

◆ device_info() [1/2]

template<typename Base, typename... ITF>
DeviceInfo* HF::Unit0< Base, ITF >::device_info ( ) const
inline

Device Information service.

Returns
pointer to the Device Information service

Definition at line 362 of file core.h.

363  {
364  return get<DeviceInfo, DEV_INFO>();
365  }

◆ device_info() [2/2]

template<typename Base, typename... ITF>
DeviceInfo* HF::Unit0< Base, ITF >::device_info ( )
inline

Device Information service.

Returns
pointer to the Device Information service

Definition at line 372 of file core.h.

373  {
374  return get<DeviceInfo, DEV_INFO>();
375  }

◆ device_management() [1/2]

template<typename Base, typename... ITF>
DeviceMgt* HF::Unit0< Base, ITF >::device_management ( ) const
inline

Device Management service.

Returns
pointer to the Device Management service

Definition at line 382 of file core.h.

383  {
384  return get<DeviceMgt, DEV_MGT>();
385  }

◆ device_management() [2/2]

template<typename Base, typename... ITF>
DeviceMgt* HF::Unit0< Base, ITF >::device_management ( )
inline

Device Management service.

Returns
pointer to the Device Management service

Definition at line 392 of file core.h.

393  {
394  return get<DeviceMgt, DEV_MGT>();
395  }

◆ handle()

template<typename Base, typename... ITF>
Common::Result HF::Unit0< Base, ITF >::handle ( HF::Protocol::Packet packet,
Common::ByteArray payload,
uint16_t  offset 
)
inline

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.

Definition at line 532 of file core.h.

534  {
535 #if HF_GROUP_SUPPORT
537  InterfacesWrapper::for_each([&result, &packet, &payload, offset](HF::Interface &itf)
538  {
539  if (result != Common::Result::OK) // Message already handled, skip.
540  {
541  result = itf.handle(packet, payload, offset);
542  }
543  });
544 
545  return result;
546 
547 #else
548  return InterfacesWrapper::handle(packet, payload, offset);
549 
550 #endif
551  }
void for_each(std::function< void(HF::Interface &)> func) const
Call the given function for all the interfaces.
Definition: interface.h:540
Fail - Unknown reason.
Common::Result handle(Protocol::Packet &packet, Common::ByteArray &payload, uint16_t offset)
Handle incoming messages from the network.
Definition: interface.h:463
virtual Common::Result handle(Protocol::Packet &packet, Common::ByteArray &payload, uint16_t offset)=0
Handle incoming messages from the network.
Common interface for all Interfaces.
Definition: interface.h:43
Result
Commands result codes.

◆ periodic()

template<typename Base, typename... ITF>
void HF::Unit0< Base, ITF >::periodic ( uint32_t  time)
inlinevirtual

Handle periodic processing.

Parameters
[in]timecurrent system clock value in seconds.

Implements HF::IDevice.

Definition at line 562 of file core.h.

563  {
564  Base::periodic(time);
565  InterfacesWrapper::periodic(time);
566  }
void periodic(uint32_t time)
Handle periodic processing.

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