8 #include <Poco/AtomicCounter.h>
9 #include <Poco/Mutex.h>
10 #include <Poco/Path.h>
11 #include <Poco/Timespan.h>
13 #include "hotplug/HotplugListener.h"
14 #include "loop/StoppableLoop.h"
15 #include "util/EventSource.h"
16 #include "util/PeriodicRunner.h"
17 #include "zwave/AbstractZWaveNetwork.h"
18 #include "zwave/OZWCommand.h"
19 #include "zwave/ZWaveListener.h"
20 #include "zwave/ZWaveNode.h"
175 void add(
const CommandClass &cc,
const OpenZWave::ValueID &
id);
181 OpenZWave::ValueID
operator[](
const CommandClass &cc)
const;
184 std::map<CommandClass, OpenZWave::ValueID> m_valueIDs;
221 OpenZWave::Notification
const *n,
247 void driverReady(
const OpenZWave::Notification *n);
272 void nodeNew(
const OpenZWave::Notification *n);
281 void nodeAdded(
const OpenZWave::Notification *n);
296 void nodeNaming(
const OpenZWave::Notification *n);
323 void nodeReady(
const OpenZWave::Notification *n);
337 void nodeRemoved(
const OpenZWave::Notification *n);
348 void valueAdded(
const OpenZWave::Notification *n);
377 void nodeQueried(
const OpenZWave::Notification *n);
424 const OpenZWave::ValueID &
id);
472 std::string
valueForList(
const OpenZWave::ValueID &valueID,
const int value);
475 Poco::Path m_configPath;
476 Poco::Path m_userPath;
477 Poco::Timespan m_pollInterval;
478 bool m_intervalBetweenPolls;
479 Poco::Timespan m_retryTimeout;
481 unsigned int m_driverMaxAttempts;
482 std::set<uint32_t> m_controllersToReset;
483 std::vector<uint8_t> m_networkKey;
488 std::map<uint32_t, std::map<uint8_t, OZWNode>> m_homes;
495 Poco::AtomicCounter m_configured;
500 mutable Poco::FastMutex m_managerLock;
505 mutable Poco::FastMutex m_lock;
513 AsyncExecutor::Ptr m_executor;
OZWCommand handles OpenZWave command management. It allows to request a command to be executed and ta...
Definition: OZWCommand.h:25
void fireStatistics()
Fire Z-Wave statistics. This is called periodically by the m_statisticsRunner.
Definition: OZWNetwork.cpp:992
std::string valueForList(const OpenZWave::ValueID &valueID, const int value)
Definition: OZWNetwork.cpp:1119
Command class representation of a Z-Wave value. We support only a subset of command classes that are ...
Definition: ZWaveNode.h:48
OZWNetwork manages the Z-Wave network by using the OpenZWave library (OZW). Its purpose is to handle ...
Definition: OZWNetwork.h:54
Definition: HotplugListener.h:9
void awakeNodesQueried(const OpenZWave::Notification *n)
Called when OZW believes that all awaken node have been queried fully. Here we analyze some stats abo...
Definition: OZWNetwork.cpp:793
void setExecutor(AsyncExecutor::Ptr executor)
Set asynchronous executor used for asynchronous tasks and events reporting.
Definition: OZWNetwork.cpp:185
void cleanup()
Deinitialize OZW library. Stop the statistics reporter.
Definition: OZWNetwork.cpp:282
bool checkNodeIsController(const uint32_t home, const uint8_t node) const
Find out whether the given node ID represents a controller of the given home.
Definition: OZWNetwork.cpp:554
Executes some function periodacally based on the given interval.
Definition: PeriodicRunner.h:18
void setNetworkKey(const std::list< std::string > &bytes)
Set OZW NetworkKey option. The key is expected to be 16 bytes long.
Definition: OZWNetwork.cpp:144
Value coming from the Z-Wave network. It holds some data (usually sensor data) and metadata to identi...
Definition: ZWaveNode.h:102
void setRetryTimeout(const Poco::Timespan &timeout)
Set OZW RetryTimeout option.
Definition: OZWNetwork.cpp:123
void driverFailed(const OpenZWave::Notification *n)
Called when OZW driver fails to become ready. The associated home ID is uninstalled.
Definition: OZWNetwork.cpp:531
EventSource implements common logic for firing events to listeners.
Definition: EventSource.h:24
void startRemoveNode() override
Start the removal mode on the primary controller(s).
Definition: OZWNetwork.cpp:946
void postValue(const ZWaveNode::Value &value) override
Post the given value into the Z-Wave network. The call is non-blocking and there is no direct feedbac...
Definition: OZWNetwork.cpp:1051
void resetController(const uint32_t home)
Initiate asynchronous reset of controller associated with the given home ID.
Definition: OZWNetwork.cpp:488
void startInclusion() override
Start the inclusion mode on the primary controller(s).
Definition: OZWNetwork.cpp:914
OZWNode wraps the ZWaveNode to be able to hold specific data related to the OpenZWave library...
Definition: OZWNetwork.h:166
void setStatisticsInterval(const Poco::Timespan &interval)
Set the interval of reporting OZW statistics.
Definition: OZWNetwork.cpp:164
bool ignoreNotification(const OpenZWave::Notification *n) const
Certain notifications coming from OZW are to be ignored because they are uninteresting or known to sc...
Definition: OZWNetwork.cpp:365
void driverRemoved(const OpenZWave::Notification *n)
Called when OZW driver is removed from the system.
Definition: OZWNetwork.cpp:542
void cancelInclusion() override
Cancel the inclusion mode if active.
Definition: OZWNetwork.cpp:927
void registerListener(ZWaveListener::Ptr listener)
Register a ZWaveListener that would be receiving events.
Definition: OZWNetwork.cpp:180
void valueAdded(const OpenZWave::Notification *n)
Called when OZW discoveres a new value associated with a certain Z-Wave node.
Definition: OZWNetwork.cpp:720
void checkDirectory(const Poco::Path &path)
Check that the given directory exists and is readable.
Definition: OZWNetwork.cpp:191
void setAssumeAwake(bool awake)
Set OZW AssumeAwake option.
Definition: OZWNetwork.cpp:131
void setUserPath(const std::string &path)
Set OZW userPath (cache of device definitions). This directory would be created if it does not exist...
Definition: OZWNetwork.cpp:102
void nodeReady(const OpenZWave::Notification *n)
Called when OZW believes that the given Z-Wave node is ready for standard operations.
Definition: OZWNetwork.cpp:679
bool controller() const
Definition: ZWaveNode.cpp:283
void allNodesQueried(const OpenZWave::Notification *n)
Called when OZW believes that all nodes have been queried fully. This call is similar to awakeNodesQu...
Definition: OZWNetwork.cpp:852
ZWaveNode represents information from the Z-Wave network about a particular node. Each Z-Wave node is...
Definition: ZWaveNode.h:22
static void ozwNotification(OpenZWave::Notification const *n, void *context)
Definition: OZWNetwork.cpp:353
void setDriverMaxAttempts(int attempts)
Set OZW DriverMaxAttempts option.
Definition: OZWNetwork.cpp:136
void nodeRemoved(const OpenZWave::Notification *n)
Called when OZW assumes that a Z-Wave node was removed from the network and thus is unreachable...
Definition: OZWNetwork.cpp:697
void setPollInterval(const Poco::Timespan &interval)
Set OZW PollInterval option.
Definition: OZWNetwork.cpp:108
void cancelRemoveNode() override
Cancel the removal mode if active.
Definition: OZWNetwork.cpp:959
void onNotification(const OpenZWave::Notification *n)
Handle incoming OZW notifications in the context of the OZWNetwork instance.
Definition: OZWNetwork.cpp:390
Definition: HotplugEvent.h:10
void nodeQueried(const OpenZWave::Notification *n)
Called when OZW finishes discovering of a Z-Wave node. At this moment, we are sure to know all dynami...
Definition: OZWNetwork.cpp:775
void add(const CommandClass &cc, const OpenZWave::ValueID &id)
Register the command class together with ValueID representation as provided by the OpenZWave library...
Definition: OZWNetwork.cpp:58
void onAdd(const HotplugEvent &event) override
If the event represents a compatible Z-Wave dongle, an appropriate driver is added into the OZW runti...
Definition: OZWNetwork.cpp:314
void driverReady(const OpenZWave::Notification *n)
Called when the OZW driver becomes ready to work for the given home ID. The OZWNetwork installs the h...
Definition: OZWNetwork.cpp:500
void configure()
Initialize OZW library, set options and register self as a watcher for handling notifications. The statistics reporter is started.
Definition: OZWNetwork.cpp:221
void valueChanged(const OpenZWave::Notification *n)
Called when OZW received data associated with a Z-Wave node's value. Such data are processed by the u...
Definition: OZWNetwork.cpp:742
Abstract implementation of the ZWaveNetwork class. It provides a pre-implemented polling mechanism...
Definition: AbstractZWaveNetwork.h:19
void interrupt() override
Cancel the current OZW command and interrupt an active pollEvent() call.
Definition: OZWNetwork.cpp:978
void prepareDirectory(const Poco::Path &path)
Create the directory represented by the given path. If it already exists, it must be writable and rea...
Definition: OZWNetwork.cpp:204
void nodeAdded(const OpenZWave::Notification *n)
Called when the OZW added a Z-Wave node to its list.
Definition: OZWNetwork.cpp:572
void nodeNew(const OpenZWave::Notification *n)
Called when the OZW discovered a new Z-Wave node.
Definition: OZWNetwork.cpp:560
void setConfigPath(const std::string &path)
Set OZW configPath (contains definitions, XML files, etc.). The directory should exist prior to calli...
Definition: OZWNetwork.cpp:96
void nodeNaming(const OpenZWave::Notification *n)
Called when OZW resolves more details about a Z-Wave node.
Definition: OZWNetwork.cpp:593
void nodeProtocolInfo(const OpenZWave::Notification *n)
Called when OZW resolves properties of a Z-Wave node.
Definition: OZWNetwork.cpp:637
void setIntervalBetweenPolls(bool enable)
Set OZW IntervalBetweenPolls option.
Definition: OZWNetwork.cpp:118
void onRemove(const HotplugEvent &event) override
If the event represents a compatible Z-Wave dongle, the appropriate driver is removed from the OZW ru...
Definition: OZWNetwork.cpp:342
void setControllersToReset(const std::list< std::string > &homes)
Set controllers (list of home IDs) to be reset upon their first appearance in the network...
Definition: OZWNetwork.cpp:174
static bool matchEvent(const HotplugEvent &event)
Determine hotplugged devices compatible with the OZWNetwork. The property tty.BEEEON_DONGLE is tested...
Definition: OZWNetwork.cpp:306
OpenZWave::ValueID operator[](const CommandClass &cc) const
Return the appropriate ValueID for the given command class.
Definition: OZWNetwork.cpp:64
static std::string homeAsString(uint32_t home)
Helper method to print the home ID.
Definition: OZWNetwork.cpp:890
static ZWaveNode::CommandClass buildCommandClass(const OpenZWave::ValueID &id)
Helper method to build a CommandClass instance directly from the OZW ValueID instance.
Definition: OZWNetwork.cpp:895
Identity of a Z-Wave node that can be used separately without any instance of the ZWaveNode class...
Definition: ZWaveNode.h:28