class NRPMQTTProxy¶
Overview¶
#include <nrp_mqtt_proxy.h> class NRPMQTTProxy { public: // construction NRPMQTTProxy(); NRPMQTTProxy(const NRPMQTTProxy&); NRPMQTTProxy(NRPMQTTProxy&&); // methods NRPMQTTProxy& operator = (const NRPMQTTProxy&); NRPMQTTProxy& operator = (NRPMQTTProxy&&); void subscribe( const std::string& address, const std::function<void(const std::string&)>& callback ); void publish( const std::string& address, const std::string& msg, bool retained = false ); bool isConnected(); void disconnect(); void clearRetained(); static NRPMQTTProxy& getInstance(); static NRPMQTTProxy& resetInstance(const nlohmann::json& clientParams); };
Detailed Documentation¶
Methods¶
void subscribe( const std::string& address, const std::function<void(const std::string&)>& callback )
Subscribe to MQTT topic ‘address’ with callback function ‘callback’.
void publish( const std::string& address, const std::string& msg, bool retained = false )
Publishes ‘msg’ to MQTT topic ‘address’.
bool isConnected()
Check connection status to broker.
void disconnect()
Disconnects client from MQTT Broker.
void clearRetained()
Clear all topics with retain messages by sending an empty msg.
static NRPMQTTProxy& getInstance()
Get singleton instance of NRPMQTTProxy.
static NRPMQTTProxy& resetInstance(const nlohmann::json& clientParams)
Reset singleton instance.