17 #ifndef HF_DEVICE_MANGEMENT_H 18 #define HF_DEVICE_MANGEMENT_H 37 namespace Concentrator
94 typedef enum _Attributes
100 constexpr
static uint16_t START_ADDR = 0x0001;
101 constexpr
static uint16_t END_ADDR = 0x7FFE;
136 static constexpr uint16_t
min_size =
sizeof(uint8_t)
141 uint16_t
size()
const;
190 static constexpr uint16_t
min_size =
sizeof(uint16_t)
194 uint16_t
size()
const;
209 if (this->address != other.
address || this->uid != other.
uid)
222 return !(*
this == other);
229 UnitPtr unit(uint16_t
id)
const 231 auto it = std::find_if(
units.begin(),
units.end(), [id](
const Unit &unit)
233 return unit.id == id;
236 if (it ==
units.end())
242 return UnitPtr(*(it.base()));
247 typedef Common::Pointer<const Device> DevicePtr;
280 uint16_t
size()
const;
301 uint16_t size()
const;
329 static constexpr uint16_t
min_size =
sizeof(uint16_t);
332 uint16_t
size()
const;
547 using ServiceRole::payload_size;
772 typedef std::vector<Device> Container;
773 typedef Container::iterator iterator;
774 typedef Container::const_iterator const_iterator;
775 typedef Container::value_type value_type;
834 const_iterator
end()
const 849 template<
typename _Entries = DeviceManagement::Entries>
922 return AbstractServer::handle_command(packet, payload, offset);
939 inline bool operator==(
const Unit &lhs,
const Unit &rhs)
941 if (lhs.id != rhs.id)
946 if (lhs.profile != rhs.profile)
951 if (lhs.interfaces.size() != rhs.interfaces.size())
956 for (uint8_t i = 0; i < lhs.interfaces.size(); i++)
958 if (lhs.interfaces[i] != rhs.interfaces[i])
967 inline bool operator!=(
const Unit &lhs,
const Unit &rhs)
969 return !(lhs == rhs);
972 inline bool operator==(
const Device &lhs,
const Device &rhs)
974 if (lhs.address != rhs.address)
979 if (lhs.units.size() != rhs.units.size())
984 for (uint8_t i = 0; i < lhs.units.size(); i++)
986 if (lhs.units[i] != rhs.units[i])
995 inline bool operator!=(
const Device &lhs,
const Device &rhs)
997 return !(lhs == rhs);
1035 std::ostream &
operator<<(std::ostream &stream,
Register command message.
uint16_t address
Address of the device to de-register.
DevicePtr find(uint16_t address) const
Return the Device entry for the given address.
HF::Devices::Concentrator::IUnit0 & unit0() const
Return a reference to the unit that this service belongs to.
iterator begin()
Get an iterator to the start of the entries in this container.
static constexpr uint16_t min_size
Minimum pack/unpack required data size.
bool operator!=(Device &other)
Not equals operator.
uint16_t size() const
Number bytes needed to serialize the message.
void send(const Protocol::Address &addr, Protocol::Message &message)
Send message msg to the network address given by addr.
bool response(Message::Type type)
Check if message is a response.
Server DefaultServer
Helper typedef.
This represent the special unit with ID/UID = 0.
Helper template to inject session management functionality into services requiring it - Server side...
SessionManagement::Client< Device > SessionMgr
Device HAN-FUN Address.
De-register device command.
Default implementation of the persistence API.
Message message
Packet message payload;.
const_iterator end() const
Get a constant iterator to the start of the entries in this container.
static constexpr uint16_t min_size
Minimum pack/unpack required data size.
uint16_t size() const
Number bytes needed to serialize the message.
Helper template to inject session management functionality into services requiring it - Client side...
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 end_session() const
End read entries session.
std::ostream & operator<<(std::ostream &stream, const HF::Core::DeviceManagement::CMD command)
Convert the given command into a string and write it to the given stream.
DevicePtr entry(const HF::UID::UID &uid) const
Return the Device entry for the given UID.
Device Management interface : Server side default implementation.
Return all mandatory attributes for the interface.
This file contains the common defines for the HAN-FUN library.
Unit(const HF::Units::IUnit &unit)
Constructor.
Units::IUnit * unit(uint8_t id) const
Return pointer to the unit with the given id.
This file contains the forward declarations of the core services and interfaces implementing classes...
iterator end()
Get an iterator to the end of the entries in this container.
void deregister()
Send a de-register message for current address.
virtual void registered(DevicePtr &device)
Indicate that a device has been registered.
uint16_t unpack(const Common::ByteArray &array, uint16_t offset=0)
Read a message from a ByteArray.
uint16_t profile
Unit UID.
bool operator==(Device &other)
Equals operator.
virtual uint16_t next_address()
Return next available address for registering a device.
virtual SessionManagement::IServer & sessions()=0
Reference to the session management API.
uint16_t unpack(const Common::ByteArray &array, uint16_t offset=0)
Read a message from a ByteArray.
constexpr uint16_t BROADCAST_ADDR
HAN-FUN Broadcast - device address.
Container & entries() const
Return the container for the service entries.
Device Management interface : Client side.
DeregisterMessage(uint16_t address=0)
Constructor.
void send(Protocol::Packet &packet)
Send given packet into the HAN-FUN network.
This file contains the definitions for the HAN-FUN protocol messages.
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.
Client(Unit0 &unit)
Constructor.
void get_entries(uint16_t offset, uint8_t count=0) const
Read entries.
virtual Common::Result register_device(Protocol::Packet &packet, Common::ByteArray &payload, uint16_t offset)
This method is called when a registration message is received.
uint16_t address
Device Address.
const_iterator begin() const
Get a constant iterator to the start of the entries in this container.
void start_session() const
Start read entries session.
Helper class used to implement custom functionality to the device management server side...
Parent class for bind management - server role.
bool has_interface(uint16_t itf_uid, HF::Interface::Role role) const
This method checks if the remote device unit implements the given interface.
HF::Attributes::IAttribute * create_attribute(uint8_t uid)
Create an attribute object that can hold the attribute with the given uid. (HF::Core::DeviceManagemen...
static constexpr uint16_t min_size
Minimum pack/unpack required data size.
virtual void deregistered(DevicePtr &device)
Indicate that a device has been de-registered.
Container db
Actual container for the entries.
End the session for device.
virtual void registered(RegisterResponse &response)
This method is called when a response to a registration message is received.
HF::UID::UID uid
Device UID.
void send(const Protocol::Address &addr, Protocol::Message &message)
Send message msg to the network address given by addr.
Device Management interface UID.
virtual void deregistered(Protocol::Response &response)
This method is called when a response to a de-registration message is received.
Unit 0 interface API for HAN-FUN Concentrators.
uint16_t address() const
Return the device address on the HAN-FUN network, when the device is registered, or HF_BROADCAST_ADDR...
HF::UID::UID uid
Device units listing.
Unit0 & unit() const
The device this unit is associated with.
virtual uint16_t next_address() const =0
Return next available address for registering a device.
virtual Common::Result deregister_device(Protocol::Packet &packet, Common::ByteArray &payload, uint16_t offset)
This method is called when a de-registration message is received.
uint16_t emc
Device EMC if applicable, 0 otherwise.
Wrapper around UID_T pointer's.
This class represents a byte array.
This file contains the definitions for the session management functionality.
RegisterMessage(uint16_t emc=0x0000, HF::UID::UID _uid=HF::UID::UID())
Device UID.
uint16_t size() const
Number bytes needed to serialize the message.
uint8_t member
Interface destination member.
virtual uint16_t payload_size(Protocol::Message &message) const
Return the minimal payload size that should be present for the given message.
This file contains the definitions for the HAN-FUN unit implementation.
Session Management API : Server side.
This file contains the declaration of the classes that implement the HAN-FUN UIDs.
uint16_t emc
HAN-FUN Concentrator EMC if applicable.
static constexpr uint16_t min_size
Minimum pack/unpack required data size.
Unit(uint8_t id=0, uint16_t profile=0)
Constructor.
IServer(Unit0 &unit)
Constructor.
Base(Unit0 &unit)
Constructor.
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.
SessionMgr & session()
Reference to the session management API.
virtual Common::Result deregister(DevicePtr &device)
De-register the device that corresponds to the given Device entry.
Interface itf
Interface Address.
Number of entries attribute.
SessionMgr & sessions()
Reference to the session management API.
uint16_t unpack(const Common::ByteArray &array, uint16_t offset=0)
Read a message from a ByteArray.
Interface/Service Attribute API.
AbstractServer(Unit0 &unit)
Constructor.
void register_device()
Send a register message.
uint16_t size() const
Number bytes needed to serialize the message.
This class represents the interface implemented by all HAN-FUN units.
Server(Unit0 &unit)
Constructor.
Parent class for the response messages.
Common::Result handle_command(CMD cmd, Protocol::Packet &packet, Common::ByteArray &payload, uint16_t offset=0)
Handle command request/response messages.
Class template for all interfaces role implementations.
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.
Simple raw pointer wrapper.
std::vector< Unit > units
Device EMC if applicable, 0 otherwise.
#define UNUSED(x)
Helper macro to remove warning about unused function/method argument.
virtual uint16_t address() const
Return the address given by the HF Concentrator to the Device.
DevicePtr entry(uint16_t address) const
Return the Device entry for the given address.
Device Management - Persistent Storage API.
This file contains the declaration of the API for a HAN-FUN device.
End Session Read Registration Info.
uint16_t next_address() const
Return next available address for registering a device.
void request() const
Helper method to create a session management request.
De-register command message.
static constexpr uint16_t min_size
Minimum pack/unpack required data size.
Container & entries() const
Get a reference to the current object implementing the persistence API, for the device information...
Common::Result destroy(const Device &entry)
Destroy the given entry in the persistent storage.
virtual bool authorized(uint8_t member, DevicePtr &source, DevicePtr &destination)
This method serves to indicate if a given member of the interface can be used by the source device af...
std::vector< Unit > units
Unit list of the interface.
std::vector< Common::Interface > interfaces
Optional interfaces.
Class template for all core services implementations.
virtual IEntries & entries() const =0
Get a reference to the current object implementing the persistence API, for the device information...
uint16_t payload_size(CMD cmd) const
Get the minimum number of bytes necessary to pack/unpack a message of the given command.
virtual DevicePtr find(uint16_t address) const =0
Return the Device entry for the given address.
Device Management interface : Server side API.
Result
Commands result codes.
uint16_t size() const
Return the number of entries in the container.
Parent class for the Device Management interface implementation.
Start Session Read Registration Info.
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 address
Address for the device to use.
Register command response.
Start a new session for a device.
Basic API for persistent storage implementations.
Top-level namespace for the HAN-FUN library.