IQRF Gateway Daemon
Public Types | Public Member Functions | List of all members
UdpMessaging Class Reference

UDP messaging. More...

#include <UdpMessaging.h>

Inheritance diagram for UdpMessaging:
IMessaging IDpaMessageForwarding IDpaExclusiveAccess

Public Types

enum  Mode { Mode::Operational, Mode::Service, Mode::Forwarding }
 operational mode More...
 
- Public Types inherited from IMessaging
typedef std::basic_string< unsigned char > ustring
 
typedef std::function< void(const ustring &)> MessageHandlerFunc
 Incoming message handler functional type. More...
 

Public Member Functions

 UdpMessaging ()=delete
 
 UdpMessaging (const std::string &name)
 
virtual ~UdpMessaging ()
 
void start () override
 IMessaging overriden methods. More...
 
void stop () override
 Stop Messaging instance. More...
 
void update (const rapidjson::Value &cfg) override
 Update configuration. More...
 
const std::string & getName () const override
 Get name of the instance. More...
 
void registerMessageHandler (MessageHandlerFunc hndl) override
 Register message handler. More...
 
void unregisterMessageHandler () override
 Unregister message handler. More...
 
void sendMessage (const ustring &msg) override
 send message More...
 
std::unique_ptr< DpaTransaction > getDpaTransactionForward (DpaTransaction *forwarded) override
 Get DPA transaction forwarding object. More...
 
void setExclusive (IChannel *chan) override
 Set exclusive access. More...
 
void resetExclusive () override
 Reset exclusive access. More...
 
void sendDpaMessageToUdp (const DpaMessage &dpaMessage)
 Send DpaMessage to UDP. More...
 
void setDaemon (IDaemon *d)
 set daemon instance More...
 
- Public Member Functions inherited from IMessaging
virtual ~IMessaging ()
 
- Public Member Functions inherited from IDpaMessageForwarding
virtual ~IDpaMessageForwarding ()
 
- Public Member Functions inherited from IDpaExclusiveAccess
virtual ~IDpaExclusiveAccess ()
 

Detailed Description

UDP messaging.

Implements IMessaging interface for UDP communication UdpMessaging works now as any IMessaging, but it is not used by any IService. It behaves as IService, ISerializer and IMessaging together because of legacy reason. It shall be changed in next version to keep architecture consistency with other components

Configurable via its update() method accepting JSON properties:

"Properties": {
"RemotePort": 55000, #set remote port to send messages
"LocalPort" : 55300 #set local port to receive messages
}

Member Enumeration Documentation

◆ Mode

enum UdpMessaging::Mode
strong

operational mode

Operational is used for normal work Service the only UDP Messaging is used to communicate with IQRF IDE Forwarding normal work but all DPA messages are forwarded to IQRF IDE to me monitored there

Enumerator
Operational 
Service 
Forwarding 

Constructor & Destructor Documentation

◆ UdpMessaging() [1/2]

UdpMessaging::UdpMessaging ( )
delete

◆ UdpMessaging() [2/2]

UdpMessaging::UdpMessaging ( const std::string &  name)

◆ ~UdpMessaging()

UdpMessaging::~UdpMessaging ( )
virtual

Member Function Documentation

◆ getDpaTransactionForward()

std::unique_ptr< DpaTransaction > UdpMessaging::getDpaTransactionForward ( DpaTransaction *  forwarded)
overridevirtual

Get DPA transaction forwarding object.

Parameters
[in]forwardedDPA transaction to be forwarded
Returns
Another DPA transaction wrapper

The transaction to be forwarded is wrapped to another transaction object implementing forwrding of flowing message

Implements IDpaMessageForwarding.

◆ getName()

const std::string& UdpMessaging::getName ( ) const
inlineoverridevirtual

Get name of the instance.

Returns
The instance name

Returns unique name of the instance

Implements IMessaging.

◆ registerMessageHandler()

void UdpMessaging::registerMessageHandler ( MessageHandlerFunc  hndl)
overridevirtual

Register message handler.

Parameters
[in]hndlregistering handler function

Whenever a message is received it is passed to the handler function. It is possible to register just one handler

Implements IMessaging.

◆ resetExclusive()

void UdpMessaging::resetExclusive ( )
overridevirtual

Reset exclusive access.

Implements IDpaExclusiveAccess.

◆ sendDpaMessageToUdp()

void UdpMessaging::sendDpaMessageToUdp ( const DpaMessage &  dpaMessage)

Send DpaMessage to UDP.

Parameters
[in]dpaMessageto send

Copyright 2016-2017 MICRORISC s.r.o.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

◆ sendMessage()

void UdpMessaging::sendMessage ( const ustring msg)
overridevirtual

send message

Parameters
[in]msgmessage to be sent

The message is send outside

Implements IMessaging.

◆ setDaemon()

void UdpMessaging::setDaemon ( IDaemon d)
inline

set daemon instance

◆ setExclusive()

void UdpMessaging::setExclusive ( IChannel *  chan)
overridevirtual

Set exclusive access.

Implements IDpaExclusiveAccess.

◆ start()

void UdpMessaging::start ( )
overridevirtual

IMessaging overriden methods.

Implements IMessaging.

◆ stop()

void UdpMessaging::stop ( )
overridevirtual

Stop Messaging instance.

Messaging implementation stops its job

Implements IMessaging.

◆ unregisterMessageHandler()

void UdpMessaging::unregisterMessageHandler ( )
overridevirtual

Unregister message handler.

If the handler is not required anymore, it is possible to unregister via this method.

Implements IMessaging.

◆ update()

void UdpMessaging::update ( const rapidjson::Value &  cfg)
overridevirtual

Update configuration.

Parameters
[in]cfgconfiguration data

Configuration data are taken from passed cfg and the instance is configured accordingly

Implements IMessaging.


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