BeeeOn Gateway  v2020.3.1-2-g6f737dc
Platform to interconnect the IoT world
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions
BeeeOn::VektivaSmarwi Class Reference

The class represents a standalone device Smarwi. It allows to communicate with the actual device via MQTT client and thus control it. More...

#include <VektivaSmarwi.h>

Inheritance diagram for BeeeOn::VektivaSmarwi:
BeeeOn::Loggable

Public Types

typedef Poco::SharedPtr
< VektivaSmarwi
Ptr
 

Public Member Functions

 VektivaSmarwi (const MACAddress &macAddr, const std::string &remoteID)
 
std::string remoteID ()
 
MACAddress macAddress ()
 
DeviceID deviceID ()
 
std::list< ModuleTypemoduleTypes () const
 
Poco::Net::IPAddress ipAddress ()
 
void setIpAddress (const Poco::Net::IPAddress &ipAddress)
 
std::string productName ()
 
void requestModifyState (const ModuleID &moduleID, double value, MqttClient::Ptr mqttClient)
 Attempts to change status of the device. More...
 
SensorData createSensorData (const VektivaSmarwiStatus &smarwiStatus)
 Creates Smarwi sensor data to send to registered exporters. More...
 

Static Public Member Functions

static DeviceID buildDeviceID (const MACAddress &macAddrStr)
 Called internally when constructing the instance. Creates DeviceID based on Mac address of device. More...
 
static MqttMessage buildMqttMessage (const std::string &remoteId, const std::string &macAddress, const std::string &command)
 Constructs an MQTT message with the topic "ion/<remoteId>/%<macAddress>/cmd" and message specified in the command parameter. More...
 
static VektivaSmarwiStatus parseStatusResponse (std::string &rcvmsg)
 Parses Smarwi's status response to an object which is returned if parsing is successful. More...
 

Protected Member Functions

void publishModifyStateCommand (const ModuleID &moduleID, double value, MqttClient::Ptr mqttClient)
 Function checks if module id and it's value is valid and if so, publishes a command to change state of Smarwi. More...
 
void confirmStateModification (MqttClient::Ptr mqttClient)
 After command to modify state was published, this function waits until the message with correct status is received. More...
 
- Protected Member Functions inherited from BeeeOn::Loggable
void setupLogger (Poco::Logger *logger=0) const
 
Poco::Logger & logger () const
 
 Loggable (const ClassInfo &info)
 
 Loggable (const std::type_info &info)
 

Static Protected Member Functions

static std::string buildTopicRegex (const std::string &remoteId, const std::string &macAddress, const std::string &lastSegment)
 
- Static Protected Member Functions inherited from BeeeOn::Loggable
static Poco::Logger & forMethod (const char *name)
 
static Poco::Logger & forClass (const ClassInfo &info)
 
static Poco::Logger & forClass (const std::type_info &info)
 
template<typename T >
static Poco::Logger & forInstance (const T *i)
 
static void configureSimple (Poco::Logger &logger, const std::string &level)
 
static void logException (Poco::Logger &logger, const Poco::Message::Priority priority, const Poco::Exception &e, const char *file, size_t line)
 

Detailed Description

The class represents a standalone device Smarwi. It allows to communicate with the actual device via MQTT client and thus control it.

Member Function Documentation

DeviceID VektivaSmarwi::buildDeviceID ( const MACAddress macAddrStr)
static

Called internally when constructing the instance. Creates DeviceID based on Mac address of device.

Returns
DeviceID - DeviceID created out of MAC address provided
MqttMessage VektivaSmarwi::buildMqttMessage ( const std::string &  remoteId,
const std::string &  macAddress,
const std::string &  command 
)
static

Constructs an MQTT message with the topic "ion/<remoteId>/%<macAddress>/cmd" and message specified in the command parameter.

Parameters
remoteId- remoteId of the user, can be found in Smarwi settings
macAddress- mac address of Smarwi
command- command to send to Smarwi
Returns
MqttMessage on success
string VektivaSmarwi::buildTopicRegex ( const std::string &  remoteId,
const std::string &  macAddress,
const std::string &  lastSegment 
)
staticprotected

Builds simple topic regex to validate the incoming message' topic.

Returns
regex in string
void VektivaSmarwi::confirmStateModification ( MqttClient::Ptr  mqttClient)
protected

After command to modify state was published, this function waits until the message with correct status is received.

Parameters
mqttClient- client ptr which will receive message
SensorData VektivaSmarwi::createSensorData ( const VektivaSmarwiStatus smarwiStatus)

Creates Smarwi sensor data to send to registered exporters.

Parameters
smarwiStatus- status of Smarwi status
Returns
SensorData - sensor data created out of SmarWiStatus
VektivaSmarwiStatus VektivaSmarwi::parseStatusResponse ( std::string &  rcvmsg)
static

Parses Smarwi's status response to an object which is returned if parsing is successful.

Parameters
rcvmsgMQTT message received from Smarwi after status request
Returns
VektivaSmarwiStatus object representation of SmarWi status message
void VektivaSmarwi::publishModifyStateCommand ( const ModuleID moduleID,
double  value,
MqttClient::Ptr  mqttClient 
)
protected

Function checks if module id and it's value is valid and if so, publishes a command to change state of Smarwi.

Parameters
moduleID- ID of the module
value- intended value
mqttClient- client ptr which will publish the message
void VektivaSmarwi::requestModifyState ( const ModuleID moduleID,
double  value,
MqttClient::Ptr  mqttClient 
)

Attempts to change status of the device.

Parameters
moduleID- what module to change
value- to what value to change to
mqttClient- which MQTT client to use

The documentation for this class was generated from the following files: