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

Create component instances. More...

#include <DaemonController.h>

Inheritance diagram for DaemonController:
IDaemon

Public Types

enum  Mode { Mode::Operational, Mode::Service, Mode::Forwarding }
 operational mode More...
 

Public Member Functions

 DaemonController (const DaemonController &)=delete
 
void run (const std::string &cfgFileName)
 main loop More...
 
void executeDpaTransaction (DpaTransaction &dpaTransaction) override
 Execute DPA transaction. More...
 
void registerAsyncMessageHandler (const std::string &serviceId, AsyncMessageHandlerFunc fun) override
 Register Asynchronous DPA message handler. More...
 
void unregisterAsyncMessageHandler (const std::string &serviceId) override
 Unregister Asynchronous DPA message handler. More...
 
ISchedulergetScheduler () override
 Get IScheduler implementation. More...
 
std::string doCommand (const std::string &cmd) override
 Perform mode switch command. More...
 
const std::string & getModuleId () override
 Get IQRF coordination identification. More...
 
const std::string & getOsVersion () override
 Get IQRF coordination OS version. More...
 
const std::string & getTrType () override
 Get IQRF coordination TR type. More...
 
const std::string & getMcuType () override
 Get IQRF coordination MCU type. More...
 
const std::string & getOsBuild () override
 Get IQRF coordination OS build. More...
 
const std::string & getDaemonVersion () override
 Get iqrf-daemon Version. More...
 
const std::string & getDaemonVersionBuild () override
 Get iqrf-daemon build Timestamp. More...
 
void exit ()
 Invoke exit of this process. More...
 
void setMode (Mode mode)
 switch operational mode More...
 
- Public Member Functions inherited from IDaemon
virtual ~IDaemon ()
 

Static Public Member Functions

static DaemonControllergetController ()
 

Detailed Description

Create component instances.

Based on configuration file passed from cmdl it instantiate and bind all component instances. The instances together implements configured daemon functions. As this version of daemon is statically linked, the components must be linked with iqrf_startup executable. It starts watch dog to monitor comunication threads and invoke exit in case of something got stucked

It accepts configuration JSON file:

{
"Configuration": "v0.0", #configuration version
"ConfigurationDir" : "configuration", #configuration directory
"WatchDogTimeoutMilis" : 10000, #watch dog timeout
"Mode" : "operational", #operational mode: operational | forwarding | service
"Components" : [ #components to be instantiated
{
"ComponentName": "BaseService", #component name
"Enabled" : true #if true component is instantiated else ignored
},
...
]
}

Member Enumeration Documentation

◆ Mode

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

◆ DaemonController()

DaemonController::DaemonController ( const DaemonController )
delete

Member Function Documentation

◆ doCommand()

std::string DaemonController::doCommand ( const std::string &  cmd)
overridevirtual

Perform mode switch command.

Parameters
[in]cmdcommand to switch mode
Returns
result of the command

Switches communication mode to oparational, forwarding or service according the command Supported command strings are: "operational" | "service" | "forwarding"

Implements IDaemon.

◆ executeDpaTransaction()

void DaemonController::executeDpaTransaction ( DpaTransaction &  dpaTransaction)
overridevirtual

Execute DPA transaction.

Parameters
[in]dpaTransactionTransaction to be executed

The transaction consists from DPA requeste sent to coordinator. It is finished by DPA response or timeout

Implements IDaemon.

◆ exit()

void DaemonController::exit ( )

Invoke exit of this process.

◆ getController()

DaemonController & DaemonController::getController ( )
static

◆ getDaemonVersion()

const std::string& DaemonController::getDaemonVersion ( )
inlineoverridevirtual

Get iqrf-daemon Version.

Returns
Version

Version is hardcoded during build, e.g. "v1.0.0"

Implements IDaemon.

◆ getDaemonVersionBuild()

const std::string& DaemonController::getDaemonVersionBuild ( )
inlineoverridevirtual

Get iqrf-daemon build Timestamp.

Returns
Timestamp

Timestamp is hardcoded during build, e.g. "Fri 06/23/2017 9:53:37.74"

Implements IDaemon.

◆ getMcuType()

const std::string& DaemonController::getMcuType ( )
inlineoverridevirtual

Get IQRF coordination MCU type.

Returns
MCU type

MCU type is taken from the coordinator at the initialization phase, e.g. "PIC16F1938"

Implements IDaemon.

◆ getModuleId()

const std::string& DaemonController::getModuleId ( )
inlineoverridevirtual

Get IQRF coordination identification.

Returns
Module ID Module ID is taken from the coordinator at the initialization phase, e.g. "8100528a"

Implements IDaemon.

◆ getOsBuild()

const std::string& DaemonController::getOsBuild ( )
inlineoverridevirtual

Get IQRF coordination OS build.

Returns
OS build

OS build is taken from the coordinator at the initialization phase, e.g. "0879"

Implements IDaemon.

◆ getOsVersion()

const std::string& DaemonController::getOsVersion ( )
inlineoverridevirtual

Get IQRF coordination OS version.

Returns
OS version

OS version is taken from the coordinator at the initialization phase, e.g. "3.08D"

Implements IDaemon.

◆ getScheduler()

IScheduler* DaemonController::getScheduler ( )
inlineoverridevirtual

Get IScheduler implementation.

Returns
IScheduler implementation

Provides an instance of IScheduler implementation.

Implements IDaemon.

◆ getTrType()

const std::string& DaemonController::getTrType ( )
inlineoverridevirtual

Get IQRF coordination TR type.

Returns
TR type

TR type is taken from the coordinator at the initialization phase, e.g. "DCTR-72D"

Implements IDaemon.

◆ registerAsyncMessageHandler()

void DaemonController::registerAsyncMessageHandler ( const std::string &  clientId,
AsyncMessageHandlerFunc  fun 
)
overridevirtual

Register Asynchronous DPA message handler.

Parameters
[in]clientIdclient identification registering handler function
[in]funhandler function

Whenever an asynchronous DPA message is received its passed to the handler function. It is possible to register more handlers for different clients distinguished via client identifications. All registered handlers are invoked to handle the message, however the order is not quaranteed. Repeated registration with the same client identification replaces previously registered handler

Implements IDaemon.

◆ run()

void DaemonController::run ( const std::string &  cfgFileName)

main loop

◆ setMode()

void DaemonController::setMode ( Mode  mode)

switch operational mode

Parameters
[in]modeoperational mode to switch

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

◆ unregisterAsyncMessageHandler()

void DaemonController::unregisterAsyncMessageHandler ( const std::string &  clientId)
overridevirtual

Unregister Asynchronous DPA message handler.

Parameters
[in]clientIdclient identification

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

Implements IDaemon.


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