36 struct SimpleDetector:
public HF::Units::Unit<HF::Profiles::SimpleDetector>
39 HF::Units::Unit<
HF::Profiles::SimpleDetector>(id, device)
49 SimpleDetector detector;
51 Alarm(): detector(1, *this)
83 _Parent::toggle(source);
94 SimpleLight simple_light;
96 Light(): simple_light(1, *this)
111 LOG(INFO) <<
"Alert received from " << source.
device <<
"/" << (int) source.
unit <<
" : " 128 struct Alarm2Switch:
public HF::Units::Unit<HF::Profiles::SimpleOnOffSwitch, AlertSink>
131 HF::Units::Unit<
HF::Profiles::SimpleOnOffSwitch, AlertSink>(id, device)
140 Alarm2Switch alarm2switch;
142 Base(): alarm2switch(1, *this)
152 int main(
int argc,
char **argv)
157 LOG(INFO) <<
"Use case : Catch all binding rules." <<
NL;
164 LOG(INFO) <<
"Create the node instances ..." <<
NL;
177 LOG(INFO) <<
"Create the base instance ..." <<
NL;
180 LOG(INFO) <<
"Create transport instance" <<
NL;
189 LOG(INFO) <<
"Network setup ..." <<
NL;
191 loop.set_base(&base);
193 loop.add_node(&alarm_1,
"alarm_1");
194 loop.add_node(&alarm_2,
"alarm_2");
195 loop.add_node(&alarm_3,
"alarm_3");
197 loop.add_node(&light_4,
"light_4");
198 loop.add_node(&light_5,
"light_5");
199 loop.add_node(&light_6,
"light_6");
203 LOG(INFO) <<
"Registering alarm_1 ... " <<
NL;
204 alarm_1.unit0()->device_management()->register_device();
205 LOG(INFO) <<
"Alarm1 address ... " << alarm_1.address() <<
NL;
206 assert(alarm_1.address() == 1);
208 LOG(INFO) <<
"Registering alarm_2 ... " <<
NL;
209 alarm_2.unit0()->device_management()->register_device();
210 LOG(INFO) <<
"Alarm2 address ... " << alarm_2.address() <<
NL;
211 assert(alarm_2.address() == 2);
213 LOG(INFO) <<
"Registering alarm_3 ... " <<
NL;
214 alarm_3.unit0()->device_management()->register_device();
215 LOG(INFO) <<
"Alarm3 address ... " << alarm_3.address() <<
NL;
216 assert(alarm_3.address() == 3);
218 LOG(INFO) <<
"Registering light_4 ... " <<
NL;
219 light_4.unit0()->device_management()->register_device();
220 LOG(INFO) <<
"Node4 address ... " << light_4.address() <<
NL;
221 assert(light_4.address() == 4);
223 LOG(INFO) <<
"Registering light_5 ... " <<
NL;
224 light_5.unit0()->device_management()->register_device();
225 LOG(INFO) <<
"Node5 address ... " << light_5.address() <<
NL;
226 assert(light_5.address() == 5);
228 LOG(INFO) <<
"Registering light_6 ... " <<
NL;
229 light_6.unit0()->device_management()->register_device();
230 LOG(INFO) <<
"Node6 address ... " << light_6.address() <<
NL;
231 assert(light_6.address() == 6);
233 LOG(INFO) <<
"There should be 6 registered devices ... " 234 << base.
unit0()->device_management()->entries().size() <<
NL;
235 assert(base.
unit0()->device_management()->entries().size() == 6);
237 LOG(INFO) <<
"=== Setup catch all binding for alert interface ===" <<
NL;
238 LOG(INFO) <<
"Alert commands will be sent to unit 1 on the base." <<
NL;
244 base.
unit0()->bind_management()->add(source, destination, itf);
245 LOG(INFO) <<
"There should be one bind entry ... " 246 << base.
unit0()->bind_management()->entries().size() <<
NL;
247 assert(base.
unit0()->bind_management()->entries().size() == 1);
249 LOG(INFO) <<
"=== Sending alarms should toggle the corresponding lights ===" <<
NL;
250 LOG(INFO) <<
"1 -> 4 | 2 -> 5 | 3 -> 6" <<
NL;
252 LOG(INFO) <<
"Alarm 1 ON ..." <<
NL;
253 alarm_1.detector.alert(
true);
255 LOG(INFO) <<
"Alarm 2 ON ..." <<
NL;
256 alarm_2.detector.alert(
true);
258 LOG(INFO) <<
"Alarm 3 ON ..." <<
NL;
259 alarm_3.detector.alert(
true);
261 LOG(INFO) <<
"Alarm 2 OFF ..." <<
NL;
262 alarm_2.detector.alert(
false);
264 LOG(INFO) <<
"Alarm 3 OFF ..." <<
NL;
265 alarm_3.detector.alert(
false);
267 LOG(INFO) <<
"Alarm 1 OFF ..." <<
NL;
268 alarm_1.detector.alert(
false);
This class represents a HAN-FUN Concentrator.
void toggle(HF::Protocol::Address &source)
Callback that is called when a TOGGLE_CMD message is received.
This is the top level include file for the HAN-FUN library.
This file contains the prototypes of the debug functionality in HAN-FUN.
virtual void status(Protocol::Address &source, Message &message)
Callback function called when a status update message is received from an Alert server.
void on(HF::Protocol::Address &source)
Callback that is called when a ON_CMD message is received.
Payload for the Status command.
uint32_t state
Current state of the server.
Alert Interface : Client side implementation.
Helper template class to implement units.
This class represents the interface common to all HAN-FUN devices.
virtual uint16_t address() const =0
Return the device address on the HAN-FUN network, when the device is registered, or HF_BROADCAST_ADDR...
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.
IDevice & device() const
Reference to the device this unit belongs to.
This file contains an implementation of a HAN-FUN transport layer to be used in the example applicati...
This class represents the interface implemented by all HAN-FUN units.
void off(HF::Protocol::Address &source)
Callback that is called when a OFF_CMD message is received.
uint16_t device
Device Address.
#define UNUSED(x)
Helper macro to remove warning about unused function/method argument.
#define LOG(X)
Log messages with the level given by X.
SimpleLight(uint8_t index, HF::IDevice &device)
Constructor.
Template for declaring HAN-FUN node devices.
Top-level namespace for the HAN-FUN library.