SPSP
Simple publish-subscribe protocol. Connects low power IoT clients to MQTT.
Public Member Functions | Protected Member Functions | List of all members
SPSP::FarLayers::MQTT::MQTT Class Reference

MQTT far layer. More...

#include <mqtt.hpp>

Inheritance diagram for SPSP::FarLayers::MQTT::MQTT:
Inheritance graph
[legend]
Collaboration diagram for SPSP::FarLayers::MQTT::MQTT:
Collaboration graph
[legend]

Public Member Functions

 MQTT (IAdapter &adapter, const Config &conf)
 Constructs a new MQTT layer object. More...
 
 ~MQTT ()
 Destroys MQTT layer object. More...
 
bool publish (const std::string &src, const std::string &topic, const std::string &payload)
 Publishes message coming from node. More...
 
bool subscribe (const std::string &topic)
 Subscribes to given topic. More...
 
bool unsubscribe (const std::string &topic)
 Unsubscribes from given topic. More...
 
- Public Member Functions inherited from SPSP::IFarLayer
void setNode (void *n)
 Sets pointer to the owner node. More...
 
IFarNode< IFarLayer > * getNode () const
 Gets the node object. More...
 
bool nodeConnected () const
 Checks whether the owner node is connected. More...
 

Protected Member Functions

void connectedCb ()
 Signalizes successful initial connection to broker. More...
 
void subDataCb (const std::string &topic, const std::string &payload)
 Callback for underlaying adapter to receive subscribe data. More...
 

Detailed Description

MQTT far layer.

Definition at line 25 of file mqtt.hpp.

Constructor & Destructor Documentation

◆ MQTT()

SPSP::FarLayers::MQTT::MQTT::MQTT ( IAdapter adapter,
const Config conf 
)

Constructs a new MQTT layer object.

Block until connection is successfully made.

Parameters
adapterMQTT low-level adapter
confConfiguration
Exceptions
AdapterErrorwhen adapter can't be constructed
ConnectionErrorwhen connection can't be established

◆ ~MQTT()

SPSP::FarLayers::MQTT::MQTT::~MQTT ( )

Destroys MQTT layer object.

Member Function Documentation

◆ connectedCb()

void SPSP::FarLayers::MQTT::MQTT::connectedCb ( )
protected

Signalizes successful initial connection to broker.

◆ publish()

bool SPSP::FarLayers::MQTT::MQTT::publish ( const std::string &  src,
const std::string &  topic,
const std::string &  payload 
)
virtual

Publishes message coming from node.

Parameters
srcSource address
topicTopic
payloadPayload (data)
Returns
true Delivery successful
false Delivery failed

Implements SPSP::IFarLayer.

◆ subDataCb()

void SPSP::FarLayers::MQTT::MQTT::subDataCb ( const std::string &  topic,
const std::string &  payload 
)
protected

Callback for underlaying adapter to receive subscribe data.

Parameters
topicTopic
payloadPayload

◆ subscribe()

bool SPSP::FarLayers::MQTT::MQTT::subscribe ( const std::string &  topic)
virtual

Subscribes to given topic.

Should be used by INode only!

Parameters
topicTopic
Returns
true Subscribe successful
false Subscribe failed

Implements SPSP::IFarLayer.

◆ unsubscribe()

bool SPSP::FarLayers::MQTT::MQTT::unsubscribe ( const std::string &  topic)
virtual

Unsubscribes from given topic.

Should be used by INode only!

Parameters
topicTopic
Returns
true Unsubscribe successful
false Unsubscribe failed

Implements SPSP::IFarLayer.


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