HAN-FUN API  1.5.3
This project provides the common implementation of ULE Alliance's HAN-FUN application protocol.
HF::Devices::Node::Abstract< CoreServices > Class Template Reference

Template for declaring HAN-FUN node devices. More...

#include <devices.h>

+ Inheritance diagram for HF::Devices::Node::Abstract< CoreServices >:
+ Collaboration diagram for HF::Devices::Node::Abstract< CoreServices >:

Public Member Functions

void connected (HF::Transport::Link *link) _override
 Callback to report that a new transport link was been created to a remote device. More...
 
void disconnected (HF::Transport::Link *link) _override
 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...
 
void receive (Protocol::Packet &packet, Common::ByteArray &payload, uint16_t offset) _override
 Callback to deliver a packet received from the transport layer. More...
 
uint16_t address () const _override
 Return the device address on the HAN-FUN network, when the device is registered, or HF_BROADCAST_ADDR otherwise. More...
 
CoreServices * unit0 () const _override
 Return pointer to the unit 0 for this device. 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

Protected Member Functions

HF::Transport::Linklink (uint16_t addr) const _override
 Return the link that can be used to send a packet to the device with the given address. More...
 
bool to_local (const Protocol::Packet &packet) const _override
 Check if an incoming packet is for the node. More...
 
- Protected Member Functions inherited from HF::Devices::AbstractDevice
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

HF::Transport::Link_link
 Link to the be used when sending packets to the network.
 
CoreServices _unit0
 Unit 0 implementation this device will use.
 
- 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 CoreServices = DefaultUnit0>
class HF::Devices::Node::Abstract< CoreServices >

Template for declaring HAN-FUN node devices.

Definition at line 425 of file devices.h.

Member Function Documentation

◆ address()

template<typename CoreServices = DefaultUnit0>
uint16_t HF::Devices::Node::Abstract< CoreServices >::address ( ) const
inlinevirtual

Return the device address on the HAN-FUN network, when the device is registered, or HF_BROADCAST_ADDR otherwise.

Returns
the device address on the HAN-FUN network, HF_BROADCAST_ADDR otherwise.

Implements HF::IDevice.

Definition at line 456 of file devices.h.

457  {
458  return unit0()->device_management()->address();
459  }
CoreServices * unit0() const _override
Return pointer to the unit 0 for this device.
Definition: devices.h:461

◆ connected()

template<typename CoreServices = DefaultUnit0>
void HF::Devices::Node::Abstract< CoreServices >::connected ( HF::Transport::Link link)
inlinevirtual

Callback to report that a new transport link was been created to a remote device.

This link can then be used by the local end-point to send messages to the remote end-point.

Parameters
[in]linkpointer to the created link.

Implements HF::Transport::Endpoint.

Definition at line 433 of file devices.h.

434  {
435  _link = link;
436  }
HF::Transport::Link * _link
Link to the be used when sending packets to the network.
Definition: devices.h:469
HF::Transport::Link * link(uint16_t addr) const _override
Return the link that can be used to send a packet to the device with the given address.
Definition: devices.h:479

◆ disconnected()

template<typename CoreServices = DefaultUnit0>
void HF::Devices::Node::Abstract< CoreServices >::disconnected ( HF::Transport::Link link)
inlinevirtual

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.

At the time of this method call the link MUST not be used to send any further messages to the remote end-point.

Parameters
[in]linkpointer to the link disconnected.

Implements HF::Transport::Endpoint.

Definition at line 438 of file devices.h.

439  {
440  if (_link == link)
441  {
442  _link = nullptr;
443  }
444  }
HF::Transport::Link * _link
Link to the be used when sending packets to the network.
Definition: devices.h:469
HF::Transport::Link * link(uint16_t addr) const _override
Return the link that can be used to send a packet to the device with the given address.
Definition: devices.h:479

◆ link()

template<typename CoreServices = DefaultUnit0>
HF::Transport::Link* HF::Devices::Node::Abstract< CoreServices >::link ( uint16_t  addr) const
inlineprotectedvirtual

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;

Implements HF::Devices::AbstractDevice.

Definition at line 479 of file devices.h.

480  {
481  UNUSED(addr);
482  return _link;
483  }
HF::Transport::Link * _link
Link to the be used when sending packets to the network.
Definition: devices.h:469
#define UNUSED(x)
Helper macro to remove warning about unused function/method argument.

◆ receive()

template<typename CoreServices = DefaultUnit0>
void HF::Devices::Node::Abstract< CoreServices >::receive ( Protocol::Packet packet,
Common::ByteArray payload,
uint16_t  offset 
)
inlinevirtual

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.

Reimplemented from HF::Devices::AbstractDevice.

Reimplemented in Node.

Definition at line 446 of file devices.h.

448  {
449  AbstractDevice::receive(packet, payload, offset);
450  }
void receive(Protocol::Packet &packet, Common::ByteArray &payload, uint16_t offset)
Callback to deliver a packet received from the transport layer.

◆ to_local()

template<typename CoreServices = DefaultUnit0>
bool HF::Devices::Node::Abstract< CoreServices >::to_local ( const Protocol::Packet packet) const
inlineprotectedvirtual

Check if an incoming packet is for the node.

Parameters
[in]packetreference to the incoming packet.
Return values
trueif the packet if for the node;
falseotherwise.

Reimplemented from HF::Devices::AbstractDevice.

Definition at line 493 of file devices.h.

494  {
495  return AbstractDevice::to_local(packet) ||
496  // If we are unregistered only allow packets to unit 0.
497  (address() == Protocol::BROADCAST_ADDR && packet.destination.unit == 0);
498  }
constexpr uint16_t BROADCAST_ADDR
HAN-FUN Broadcast - device address.
Definition: protocol.h:45
virtual bool to_local(const Protocol::Packet &packet) const
Check if the given packet is for this device.
Definition: devices.h:139
uint16_t address() const _override
Return the device address on the HAN-FUN network, when the device is registered, or HF_BROADCAST_ADDR...
Definition: devices.h:456

◆ unit0()

template<typename CoreServices = DefaultUnit0>
CoreServices* HF::Devices::Node::Abstract< CoreServices >::unit0 ( ) const
inlinevirtual

Return pointer to the unit 0 for this device.

Returns
pointer to the unit 0 for this device.

Implements HF::IDevice.

Definition at line 461 of file devices.h.

462  {
463  return const_cast<CoreServices *>(&_unit0);
464  }
CoreServices _unit0
Unit 0 implementation this device will use.
Definition: devices.h:472

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