24 #include <forward_list> 46 static SimpleLight *simple_light =
nullptr;
49 static SimpleSwitch *simple_switch =
nullptr;
58 COMMAND(Register,
"r",
"r:register device")
61 LOG(TRACE) << __PRETTY_FUNCTION__ <<
NL;
63 node.unit0()->device_management()->register_device();
72 LOG(TRACE) << __PRETTY_FUNCTION__ <<
NL;
74 LOG(APP) <<
"Device Address : " << node.address() <<
NL;
80 COMMAND(SimpleLight,
"sl",
"sl:set device as a simple light")
83 LOG(TRACE) << __PRETTY_FUNCTION__ <<
NL;
85 if (simple_switch !=
nullptr)
90 if (simple_light ==
nullptr)
92 simple_light =
new SimpleLight(1, node);
95 LOG(APP) <<
"Device is now a Simple Light !" <<
NL;
101 COMMAND(SimpleSwitch,
"ss",
"ss:set device as a simple switch")
104 LOG(TRACE) << __PRETTY_FUNCTION__ <<
NL;
106 if (simple_light !=
nullptr)
111 if (simple_switch ==
nullptr)
113 simple_switch =
new SimpleSwitch(1, node);
116 LOG(APP) <<
"Device is now a Simple Switch !" <<
NL;
125 LOG(TRACE) << __PRETTY_FUNCTION__ <<
NL;
127 if (simple_switch !=
nullptr)
133 LOG(ERROR) <<
"Simple Switch not configured !" <<
NL;
143 LOG(TRACE) << __PRETTY_FUNCTION__ <<
NL;
145 if (simple_switch !=
nullptr)
147 simple_switch->off();
151 LOG(ERROR) <<
"Simple Switch not configured !" <<
NL;
158 COMMAND(Toggle,
"toggle",
"toggle:Toggle Command")
161 LOG(TRACE) << __PRETTY_FUNCTION__ <<
NL;
163 if (simple_switch !=
nullptr)
165 simple_switch->toggle();
169 LOG(ERROR) <<
"Simple Switch not configured !" <<
NL;
186 LOG(TRACE) << __PRETTY_FUNCTION__ <<
NL;
190 transport.
add(&node);
This file contains the definition of the Node class that represents the HAN-FUN Node on the applicati...
This file contains the definitions for the HAN-FUN example applications.
void Saved()
Callback indicating that the application configuration has been saved.
This class defines the API for the transport layer.
void Restored()
Callback indicating that the application configuration has been restored.
#define COMMAND_ADD(_name)
Helper macro to add a new command to the registry.
virtual void initialize()=0
Initialize the associated transport layer.
virtual void add(Endpoint *ep)=0
Register the given Endpoint to receive events.
#define NL
Helper define for new-line and stream clear.
COMMAND(Register, "r", "r:register device")
Register node command.
#define UNUSED(x)
Helper macro to remove warning about unused function/method argument.
void Restore()
Restore application configuration.
This file contains the definitions for the common functionality in the HAN-FUN example applications...
#define LOG(X)
Log messages with the level given by X.
void Save()
Save application configuration.
void Initialize(HF::Transport::Layer &transport)
Initialize the application.