5 #include <Poco/Mutex.h>
6 #include <Poco/Timespan.h>
8 #include "core/DeviceManager.h"
9 #include "model/DeviceID.h"
10 #include "net/MqttClient.h"
11 #include "sonoff/SonoffDevice.h"
26 void setMqttClient(MqttClient::Ptr mqttClient);
27 void setMaxLastSeen(
const Poco::Timespan &timeout);
33 const Poco::Timespan &)
override;
34 void handleAccept(
const DeviceAcceptCommand::Ptr cmd)
override;
52 void createNewDevice(
const std::pair<DeviceID, std::string>& deviceInfo);
55 Poco::FastMutex m_devicesMutex;
56 std::map<DeviceID, SonoffDevice::Ptr> m_devices;
58 MqttClient::Ptr m_mqttClient;
59 Poco::Timespan m_maxLastSeen;
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: SonoffDeviceManager.cpp:159
AsyncWork< std::set< DeviceID > >::Ptr startUnpair(const DeviceID &id, const Poco::Timespan &) override
Starts device unpair process in a technology-specific way. This method is always called inside a crit...
Definition: SonoffDeviceManager.cpp:200
void createNewDevice(const std::pair< DeviceID, std::string > &deviceInfo)
Creates instance of sonoff device according to device name and appends it into m_devices.
Definition: SonoffDeviceManager.cpp:145
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
void stop() override
Definition: SonoffDeviceManager.cpp:87
Definition: MqttMessage.h:7
std::pair< DeviceID, std::string > retrieveDeviceInfo(const std::string &message) const
Retrieves device information from JSON message received from MQTT broker.
Definition: SonoffDeviceManager.cpp:125
void processMQTTMessage(const MqttMessage &message)
Processes the incoming MQTT message, which means creating a new device or sending the gathered data t...
Definition: SonoffDeviceManager.cpp:93
Definition: DeviceManager.h:48
The class implements the work with Sonoff devices. Allows us to process and execute the commands from...
Definition: SonoffDeviceManager.h:20
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: SonoffDeviceManager.cpp:189
Definition: DeviceID.h:17