31 struct SimpleDetector:
public HF::Units::Unit<HF::Profiles::SimpleDetector>
34 HF::Units::Unit<
HF::Profiles::SimpleDetector>(id, device)
44 HF::Units::Unit<
HF::Profiles::Alertable>(id, device)
51 LOG(INFO) <<
"Alert received " << std::hex << std::showbase
74 int main(
int argc,
char **argv)
79 LOG(INFO) <<
"Use case : Alert interface usage" <<
NL;
86 LOG(INFO) <<
"Create the node instances ..." <<
NL;
90 LOG(INFO) <<
"Add unit to node1 instance ..." <<
NL;
91 SimpleDetector simple_detector(1, node1);
95 LOG(INFO) <<
"Add unit to node2 instance ..." <<
NL;
96 AlertSink alert_sink(1, node2);
101 LOG(INFO) <<
"Create the base instance ..." <<
NL;
104 LOG(INFO) <<
"Create transport instance" <<
NL;
113 LOG(INFO) <<
"Network setup ..." <<
NL;
115 loop.set_base(&base);
116 loop.add_node(&node1,
"node_1");
117 loop.add_node(&node2,
"node_2");
124 LOG(INFO) <<
"Registering node1 ... " <<
NL;
125 node1.unit0()->device_management()->register_device();
126 LOG(INFO) <<
"Node1 address ... " << node1.address() <<
NL;
129 assert(node1.address() == 1);
134 LOG(INFO) <<
"Registering node2 ... " <<
NL;
135 node2.unit0()->device_management()->register_device();
136 LOG(INFO) <<
"Node2 address ... " << node2.address() <<
NL;
139 assert(node2.address() == 2);
141 LOG(INFO) <<
"There should be two registered devices ... " 142 << base.
unit0()->device_management()->entries().size() <<
NL;
144 assert(base.
unit0()->device_management()->entries().size() == 2);
150 LOG(INFO) <<
"Send alerts to a specific device/unit ... " <<
NL;
154 LOG(INFO) <<
"Send alert on ..." <<
NL;
155 simple_detector.alert(addr,
true);
157 LOG(INFO) <<
"Send alert off ... " <<
NL;
158 simple_detector.alert(addr,
false);
164 LOG(INFO) <<
"Send alerts to the broadcast device/unit ... " <<
NL;
167 LOG(INFO) <<
"Create bind entry on the base ... " <<
NL;
172 base.
unit0()->bind_management()->add(source, destination, itf);
173 LOG(INFO) <<
"There should be one bind entry ... " 174 << base.
unit0()->bind_management()->entries().size() <<
NL;
175 assert(base.
unit0()->bind_management()->entries().size() == 1);
177 LOG(INFO) <<
"Send alert on to the broadcast device/unit ... " <<
NL;
178 simple_detector.alert(
true);
180 LOG(INFO) <<
"Send alert off to the broadcast device/unit ... " <<
NL;
181 simple_detector.alert(
false);
This class represents a HAN-FUN Concentrator.
This is the top level include file for the HAN-FUN library.
This file contains the prototypes of the debug functionality in HAN-FUN.
constexpr uint16_t BROADCAST_ADDR
HAN-FUN Broadcast - device address.
Payload for the Status command.
uint32_t state
Current state of the server.
Helper template class to implement units.
This class represents the interface common to all HAN-FUN devices.
Template for HAN-FUN concentrator devices.
#define NL
Helper define for new-line and stream clear.
CoreServices * unit0() const
Get the unit 0 used by this concentrator device.
This file contains an implementation of a HAN-FUN transport layer to be used in the example applicati...
#define UNUSED(x)
Helper macro to remove warning about unused function/method argument.
#define LOG(X)
Log messages with the level given by X.
Template for declaring HAN-FUN node devices.
Top-level namespace for the HAN-FUN library.