BeeeOn Gateway  v2020.3.1-2-g6f737dc
Platform to interconnect the IoT world
VektivaSmarwi.h
1 #pragma once
2 
3 #include <list>
4 
5 #include "model/DeviceID.h"
6 #include "model/ModuleID.h"
7 #include "model/ModuleType.h"
8 #include "net/MqttClient.h"
9 #include "net/MACAddress.h"
10 #include "util/Loggable.h"
11 #include "vektiva/VektivaSmarwiStatus.h"
12 
13 namespace BeeeOn {
14 
20 class VektivaSmarwi : protected Loggable {
21 public:
22  typedef Poco::SharedPtr<VektivaSmarwi> Ptr;
23 
25  const MACAddress& macAddr,
26  const std::string &remoteID);
27 
28  std::string remoteID();
29  MACAddress macAddress();
30  DeviceID deviceID();
31  std::list<ModuleType> moduleTypes() const;
32  Poco::Net::IPAddress ipAddress();
33  void setIpAddress(const Poco::Net::IPAddress &ipAddress);
34  std::string productName();
35 
42  void requestModifyState(
43  const ModuleID &moduleID,
44  double value,
45  MqttClient::Ptr mqttClient);
46 
52  SensorData createSensorData(const VektivaSmarwiStatus &smarwiStatus);
53 
59  static DeviceID buildDeviceID(
60  const MACAddress &macAddrStr);
61 
72  const std::string &remoteId,
73  const std::string &macAddress,
74  const std::string &command);
75 
84  std::string &rcvmsg);
85 
86 protected:
95  const ModuleID &moduleID,
96  double value,
97  MqttClient::Ptr mqttClient);
98 
105  MqttClient::Ptr mqttClient);
106 
111  static std::string buildTopicRegex(
112  const std::string &remoteId,
113  const std::string &macAddress,
114  const std::string &lastSegment);
115 
116 private:
117  DeviceID m_deviceId;
118  std::string m_remoteID;
119  MACAddress m_macAddress;
120  Poco::Net::IPAddress m_ipAddress;
121 };
122 }
void requestModifyState(const ModuleID &moduleID, double value, MqttClient::Ptr mqttClient)
Attempts to change status of the device.
Definition: VektivaSmarwi.cpp:158
The class represents a standalone device Smarwi. It allows to communicate with the actual device via ...
Definition: VektivaSmarwi.h:20
Definition: SensorData.h:20
static std::string buildTopicRegex(const std::string &remoteId, const std::string &macAddress, const std::string &lastSegment)
Definition: VektivaSmarwi.cpp:244
static MqttMessage buildMqttMessage(const std::string &remoteId, const std::string &macAddress, const std::string &command)
Constructs an MQTT message with the topic &quot;ion/&lt;remoteId&gt;/%&lt;macAddress&gt;/cmd&quot; and message specified in...
Definition: VektivaSmarwi.cpp:236
static VektivaSmarwiStatus parseStatusResponse(std::string &rcvmsg)
Parses Smarwi&#39;s status response to an object which is returned if parsing is successful.
Definition: VektivaSmarwi.cpp:167
SensorData createSensorData(const VektivaSmarwiStatus &smarwiStatus)
Creates Smarwi sensor data to send to registered exporters.
Definition: VektivaSmarwi.cpp:203
Definition: MACAddress.h:8
Definition: MqttMessage.h:7
Definition: ModuleID.h:12
void publishModifyStateCommand(const ModuleID &moduleID, double value, MqttClient::Ptr mqttClient)
Function checks if module id and it&#39;s value is valid and if so, publishes a command to change state o...
Definition: VektivaSmarwi.cpp:54
The class represents the status of the Smarwi device. The status information is obtained by MQTT clie...
Definition: VektivaSmarwiStatus.h:11
Definition: Loggable.h:19
Definition: DeviceID.h:17
void confirmStateModification(MqttClient::Ptr mqttClient)
After command to modify state was published, this function waits until the message with correct statu...
Definition: VektivaSmarwi.cpp:106
static DeviceID buildDeviceID(const MACAddress &macAddrStr)
Called internally when constructing the instance. Creates DeviceID based on Mac address of device...
Definition: VektivaSmarwi.cpp:216