6 #include <Poco/Mutex.h>
7 #include <Poco/Timespan.h>
9 #include "core/AbstractSeeker.h"
10 #include "core/DeviceManager.h"
11 #include "core/PollingKeeper.h"
12 #include "credentials/FileCredentialsStorage.h"
13 #include "loop/StopControl.h"
14 #include "model/DeviceID.h"
15 #include "model/RefreshTime.h"
16 #include "net/MACAddress.h"
17 #include "philips/PhilipsHueBridge.h"
18 #include "philips/PhilipsHueBulb.h"
19 #include "philips/PhilipsHueListener.h"
20 #include "util/AsyncWork.h"
21 #include "util/CryptoConfig.h"
22 #include "util/EventSource.h"
39 typedef Poco::SharedPtr<PhilipsHueSeeker> Ptr;
50 static const Poco::Timespan SEARCH_DELAY;
57 void setDevicePoller(DevicePoller::Ptr poller);
58 void setUPnPTimeout(
const Poco::Timespan &timeout);
59 void setHTTPTimeout(
const Poco::Timespan &timeout);
60 void setRefresh(
const Poco::Timespan &refresh);
61 void setCredentialsStorage(Poco::SharedPtr<FileCredentialsStorage> storage);
62 void setCryptoConfig(Poco::SharedPtr<CryptoConfig> config);
63 void setEventsExecutor(AsyncExecutor::Ptr executor);
64 void registerListener(PhilipsHueListener::Ptr listener);
67 void handleAccept(
const DeviceAcceptCommand::Ptr cmd)
override;
71 const Poco::Timespan &timeout)
override;
76 const Poco::Timespan &timeout)
override;
78 void searchPairedDevices();
87 void authorizationOfBridge(PhilipsHueBridge::Ptr bridge);
89 void processNewDevice(PhilipsHueBulb::Ptr newDevice);
91 void fireBridgeStatistics(PhilipsHueBridge::Ptr bridge);
92 void fireBulbStatistics(PhilipsHueBulb::Ptr bulb);
95 Poco::FastMutex m_bridgesMutex;
96 Poco::FastMutex m_pairedMutex;
98 std::map<MACAddress, PhilipsHueBridge::Ptr> m_bridges;
99 std::map<DeviceID, PhilipsHueBulb::Ptr> m_devices;
103 Poco::Timespan m_httpTimeout;
104 Poco::Timespan m_upnpTimeout;
106 Poco::SharedPtr<FileCredentialsStorage> m_credentialsStorage;
107 Poco::SharedPtr<CryptoConfig> m_cryptoConfig;
RefreshTime represents time of refreshing values from sensors. E.g. sensors are polled periodically o...
Definition: RefreshTime.h:24
EventSource implements common logic for firing events to listeners.
Definition: EventSource.h:24
AsyncWork< std::set< DeviceID > >::Ptr startUnpair(const DeviceID &id, const Poco::Timespan &timeout) override
Starts device unpair process in a technology-specific way. This method is always called inside a crit...
Definition: PhilipsHueDeviceManager.cpp:212
PollingKeeper takes care of devices that are being polled. It cancels all polled devices it manages u...
Definition: PollingKeeper.h:17
AsyncWork is an interface allowing to wait until an asynchronous operation finishes. It is also possible to force-stop it by calling cancel().
Definition: AsyncWork.h:21
AbstractSeeker represents an asynchronous process that seeks for new devices in a certain network...
Definition: AbstractSeeker.h:25
StopControl implements the stop mechanism generically.
Definition: StopControl.h:12
Definition: ModuleID.h:12
Poco::Timespan duration() const
Definition: AbstractSeeker.cpp:17
The class implements the work with Philips Hue bulbs. Allows us to process and execute the commands f...
Definition: PhilipsHueDeviceManager.h:31
void handleAccept(const DeviceAcceptCommand::Ptr cmd) override
Generic handler of the DeviceAcceptCommand. It might be helpful to override this method in case we ne...
Definition: PhilipsHueDeviceManager.cpp:238
Definition: DeviceManager.h:48
Provides searching philips devices on network in own thread.
Definition: PhilipsHueDeviceManager.h:37
void eraseUnusedBridges()
Erases the bridges which don't care any bulb.
Definition: PhilipsHueDeviceManager.cpp:174
AsyncWork::Ptr startDiscovery(const Poco::Timespan &timeout) override
Starts device discovery process in a technology-specific way. This method is always called inside a c...
Definition: PhilipsHueDeviceManager.cpp:204
void stop() override
Definition: PhilipsHueDeviceManager.cpp:88
Definition: DeviceID.h:17
AsyncWork< double >::Ptr startSetValue(const DeviceID &id, const ModuleID &module, const double value, const Poco::Timespan &timeout) override
Starts set-value operation in a technology specific way. The method is always called inside a critica...
Definition: PhilipsHueDeviceManager.cpp:250