HAN-FUN API  1.5.3
This project provides the common implementation of ULE Alliance's HAN-FUN application protocol.
HF::Devices::AbstractDevice Struct Referenceabstract

This class provides the basic implementation for the Device's interface. More...

#include <devices.h>

+ Inheritance diagram for HF::Devices::AbstractDevice:
+ Collaboration diagram for HF::Devices::AbstractDevice:

Public Member Functions

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 receive (Protocol::Packet &packet, Common::ByteArray &payload, uint16_t offset)
 Callback to deliver a packet received from the transport layer. More...
 
void periodic (uint32_t time)
 Handle periodic processing. More...
 
- Public Member Functions inherited from HF::IDevice
virtual uint16_t address () const =0
 Return the device address on the HAN-FUN network, when the device is registered, or HF_BROADCAST_ADDR otherwise. More...
 
virtual IUnit0unit0 () const =0
 Return pointer to the unit 0 for this device. More...
 
- Public Member Functions inherited from HF::Transport::Endpoint
virtual void connected (Link *link)=0
 Callback to report that a new transport link was been created to a remote device. More...
 
virtual void disconnected (Link *link)=0
 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...
 

Protected Member Functions

virtual Transport::Linklink (uint16_t addr) const =0
 Return the link that can be used to send a packet to the device with the given address. More...
 
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 Attributes

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

This class provides the basic implementation for the Device's interface.

Definition at line 74 of file devices.h.

Member Function Documentation

◆ add()

void HF::Devices::AbstractDevice::add ( Units::IUnit unit)
inlinevirtual

Add unit to devices unit lists.

Parameters
unitpointer to the unit to add to the list.

Implements HF::IDevice.

Definition at line 85 of file devices.h.

References _units, and unit().

86  {
87  _units.push_front(unit);
88  }
Units::IUnit * unit(uint8_t id) const
Return pointer to the unit with the given id.
IUnits _units
List containing pointers to the units present in the device.
Definition: devices.h:109
+ Here is the call graph for this function:

◆ from_local()

bool HF::Devices::AbstractDevice::from_local ( const Protocol::Packet packet) const
inlineprotected

Check if the given packet is from the local device.

Parameters
[in]packetreference to the incoming packet.
Return values
trueif the source is the local device;
falseotherwise.

Definition at line 152 of file devices.h.

References HF::IDevice::address(), HF::Protocol::Address::device, and HF::Protocol::Packet::source.

Referenced by from_remote().

153  {
154  return packet.source.device == address();
155  }
virtual uint16_t address() const =0
Return the device address on the HAN-FUN network, when the device is registered, or HF_BROADCAST_ADDR...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ from_remote()

bool HF::Devices::AbstractDevice::from_remote ( const Protocol::Packet packet)
inlineprotected

Check if the given packet is from the a remote device.

Parameters
[in]packetreference to the incoming packet.
Return values
trueif the source is a remote device;
falseotherwise.

Definition at line 165 of file devices.h.

References from_local().

166  {
167  return !from_local(packet);
168  }
bool from_local(const Protocol::Packet &packet) const
Check if the given packet is from the local device.
Definition: devices.h:152
+ Here is the call graph for this function:

◆ is_registered()

bool HF::Devices::AbstractDevice::is_registered ( )
inlineprotected

Check if the device has a valid, i.e.

not HF::Protocol::BROADCAST_ADDR.

Returns
if the device address is different from HF::Protocol::BROADCAST_ADDR.

Definition at line 175 of file devices.h.

References HF::IDevice::address(), and HF::Protocol::BROADCAST_ADDR.

176  {
177  return this->address() != Protocol::BROADCAST_ADDR;
178  }
constexpr uint16_t BROADCAST_ADDR
HAN-FUN Broadcast - device address.
Definition: protocol.h:45
virtual uint16_t address() const =0
Return the device address on the HAN-FUN network, when the device is registered, or HF_BROADCAST_ADDR...
+ Here is the call graph for this function:

◆ link()

virtual Transport::Link* HF::Devices::AbstractDevice::link ( uint16_t  addr) const
protectedpure virtual

Return the link that can be used to send a packet to the device with the given address.

Parameters
[in]addrthe address of the device to send the packet to.
Returns
a pointer to the link that can be used to send the packet, nullptr otherwise;

Implemented in HF::Devices::Concentrator::AbstractBase, HF::Devices::Node::Abstract< CoreServices >, HF::Devices::Node::Abstract< NodeUnit0 >, and HF::Devices::Node::Abstract< HF::Devices::Node::DefaultUnit0 >.

◆ periodic()

void HF::Devices::AbstractDevice::periodic ( uint32_t  time)
virtual

Handle periodic processing.

Parameters
[in]timecurrent system clock value in seconds.

Implements HF::IDevice.

Referenced by HF::Unit0< IUnit0, ITF... >::periodic().

+ Here is the caller graph for this function:

◆ receive()

void HF::Devices::AbstractDevice::receive ( Protocol::Packet packet,
Common::ByteArray payload,
uint16_t  offset 
)
virtual

Callback to deliver a packet received from the transport layer.

Parameters
[in]packetreference to the received packet.
[in]payloadreference a ByteArray containing the received data.
[in]offsetoffset from where the received data starts on the payload byte array buffer.

Implements HF::Transport::Endpoint.

Reimplemented in HF::Devices::Concentrator::AbstractBase, HF::Devices::Node::Abstract< CoreServices >, HF::Devices::Node::Abstract< NodeUnit0 >, HF::Devices::Node::Abstract< HF::Devices::Node::DefaultUnit0 >, Base, and Node.

◆ remove()

void HF::Devices::AbstractDevice::remove ( Units::IUnit unit)
inlinevirtual

Remove unit from device's unit list.

Parameters
unitpointer to the unit to remove from the list.

Implements HF::IDevice.

Definition at line 90 of file devices.h.

References _units, and unit().

91  {
92  _units.remove(unit);
93  }
Units::IUnit * unit(uint8_t id) const
Return pointer to the unit with the given id.
IUnits _units
List containing pointers to the units present in the device.
Definition: devices.h:109
+ Here is the call graph for this function:

◆ send()

void HF::Devices::AbstractDevice::send ( Protocol::Packet packet)
virtual

Send given packet into the HAN-FUN network.

Parameters
packetreference to the packet to send to the network.

Implements HF::IDevice.

Referenced by HF::Core::BindManagement::Client::send(), HF::Core::DeviceManagement::Client::send(), HF::Core::BindManagement::Server< Entries >::send(), and HF::Core::DeviceManagement::Server< Entries >::send().

+ Here is the caller graph for this function:

◆ to_local()

virtual bool HF::Devices::AbstractDevice::to_local ( const Protocol::Packet packet) const
inlineprotectedvirtual

Check if the given packet is for this device.

Parameters
[in]packetreference to the incoming packet.
Return values
trueif the destination is the local device;
falseotherwise.

Reimplemented in HF::Devices::Node::Abstract< CoreServices >, HF::Devices::Node::Abstract< NodeUnit0 >, and HF::Devices::Node::Abstract< HF::Devices::Node::DefaultUnit0 >.

Definition at line 139 of file devices.h.

References HF::IDevice::address(), HF::Protocol::Packet::destination, and HF::Protocol::Address::device.

140  {
141  return packet.destination.device == address();
142  }
virtual uint16_t address() const =0
Return the device address on the HAN-FUN network, when the device is registered, or HF_BROADCAST_ADDR...
+ Here is the call graph for this function:

◆ unit()

Units::IUnit* HF::Devices::AbstractDevice::unit ( uint8_t  id) const
virtual

Return pointer to the unit with the given id.

Parameters
[in]idunit identifier.
Returns
pointer to the unit with the given id, nullptr otherwise.

Implements HF::IDevice.

Referenced by add(), and remove().

+ Here is the caller graph for this function:

◆ units()

const IUnits& HF::Devices::AbstractDevice::units ( ) const
inlinevirtual

Return the list of units registered in this device.

Returns
list containing the device's registered units.

Implements HF::IDevice.

Definition at line 80 of file devices.h.

References _units.

81  {
82  return _units;
83  }
IUnits _units
List containing pointers to the units present in the device.
Definition: devices.h:109

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