|
SPSP
Simple publish-subscribe protocol. Connects low power IoT clients to MQTT.
|
MQTT adapter for ESP platform. More...
#include <mqtt_adapter.hpp>


Public Member Functions | |
| Adapter (const Config &conf) | |
| Constructs a new MQTT layer object. More... | |
| ~Adapter () | |
| Destroys MQTT layer object. More... | |
| bool | publish (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... | |
| void | setSubDataCb (AdapterSubDataCb cb) |
| Sets callback for incoming subscription data. More... | |
| AdapterSubDataCb | getSubDataCb () const |
| Gets callback for incoming subscription data. More... | |
| void | setConnectedCb (AdapterConnectedCb cb) |
| Sets connected callback. More... | |
| AdapterConnectedCb | getConnectedCb () const |
| Gets connected callback. More... | |
| Adapter (const Config &conf) | |
| Constructs a new MQTT layer object. More... | |
| ~Adapter () | |
| Destroys MQTT layer object. More... | |
| bool | publish (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... | |
| void | setSubDataCb (AdapterSubDataCb cb) |
| Sets callback for incoming subscription data. More... | |
| AdapterSubDataCb | getSubDataCb () const |
| Gets callback for incoming subscription data. More... | |
| void | setConnectedCb (AdapterConnectedCb cb) |
| Sets connected callback. More... | |
| AdapterConnectedCb | getConnectedCb () const |
| Gets connected callback. More... | |
| virtual bool | publish (const std::string &topic, const std::string &payload) |
| Publishes message coming from node. More... | |
| virtual bool | subscribe (const std::string &topic) |
| Subscribes to given topic. More... | |
| virtual bool | unsubscribe (const std::string &topic) |
| Unsubscribes from given topic. More... | |
| virtual void | setSubDataCb (AdapterSubDataCb cb) |
| Sets callback for incoming subscription data. More... | |
| virtual void | setConnectedCb (AdapterConnectedCb cb) |
| Sets connected callback. More... | |
Protected Member Functions | |
| bool | connect () |
| Connects to MQTT server. More... | |
Static Protected Member Functions | |
| static const char * | stringToCOrNull (const std::string &str) |
Helper to convert std::string to C string or nullptr More... | |
| static void | connectedCb (void *ctx, char *cause) |
| Connected callback. More... | |
| static void | connFailureCb (void *ctx, MQTTAsync_failureData *resp) |
| Connection failure callback. More... | |
| static void | connLostCb (void *ctx, char *cause) |
| Connection lost callback. More... | |
| static int | subMsgCb (void *ctx, char *topic, int topicLen, MQTTAsync_message *msg) |
| Subscription message callback. More... | |
| static const char * | stringToCOrNull (const std::string &str) |
Helper to convert std::string to C string or nullptr More... | |
MQTT adapter for ESP platform.
Generic MQTT adapter for testing.
MQTT adapter for Linux platform.
Doesn't check if connection was successfully established within time limit.
Only one MQTT instance can use this at a time and there may be many Adapter instances at a time.
Only one MQTT instance can use this at a time and there may be many Adapter instances at a time.
Definition at line 27 of file espidf/spsp/mqtt_adapter.hpp.
| SPSP::FarLayers::MQTT::Adapter::Adapter | ( | const Config & | conf | ) |
Constructs a new MQTT layer object.
Requires already initialized WiFi (with IP address).
| conf | Configuration |
| AdapterError | when MQTT client can't be created and started |
| SPSP::FarLayers::MQTT::Adapter::~Adapter | ( | ) |
Destroys MQTT layer object.
| SPSP::FarLayers::MQTT::Adapter::Adapter | ( | const Config & | conf | ) |
Constructs a new MQTT layer object.
Requires already initialized WiFi (with IP address).
| conf | Configuration |
| AdapterError | when MQTT client can't be created and started |
| SPSP::FarLayers::MQTT::Adapter::~Adapter | ( | ) |
Destroys MQTT layer object.
|
protected |
Connects to MQTT server.
|
staticprotected |
Connected callback.
Passed to underlaying library.
| ctx | Context |
| cause | Cause |
|
staticprotected |
Connection failure callback.
Passed to underlaying library.
| ctx | Context |
| resp | Response |
|
staticprotected |
Connection lost callback.
Passed to underlaying library.
| ctx | Context |
| cause | Cause |
| AdapterConnectedCb SPSP::FarLayers::MQTT::Adapter::getConnectedCb | ( | ) | const |
Gets connected callback.
| AdapterConnectedCb SPSP::FarLayers::MQTT::Adapter::getConnectedCb | ( | ) | const |
Gets connected callback.
| AdapterSubDataCb SPSP::FarLayers::MQTT::Adapter::getSubDataCb | ( | ) | const |
Gets callback for incoming subscription data.
| AdapterSubDataCb SPSP::FarLayers::MQTT::Adapter::getSubDataCb | ( | ) | const |
Gets callback for incoming subscription data.
|
inlinevirtual |
Publishes message coming from node.
| topic | Topic |
| payload | Payload (data) |
Implements SPSP::FarLayers::MQTT::IAdapter.
Definition at line 32 of file testing/spsp/mqtt_adapter.hpp.
|
virtual |
Publishes message coming from node.
This doesn't block.
| topic | Topic |
| payload | Payload (data) |
Implements SPSP::FarLayers::MQTT::IAdapter.
|
virtual |
Publishes message coming from node.
This doesn't block.
| topic | Topic |
| payload | Payload (data) |
Implements SPSP::FarLayers::MQTT::IAdapter.
|
inlinevirtual |
Sets connected callback.
Should be called on successful connection and reconnection.
| cb | Callback |
Implements SPSP::FarLayers::MQTT::IAdapter.
Definition at line 77 of file testing/spsp/mqtt_adapter.hpp.
|
virtual |
Sets connected callback.
Should be called on successful connection and reconnection.
| cb | Callback |
Implements SPSP::FarLayers::MQTT::IAdapter.
|
virtual |
Sets connected callback.
Should be called on successful connection and reconnection.
| cb | Callback |
Implements SPSP::FarLayers::MQTT::IAdapter.
|
inlinevirtual |
Sets callback for incoming subscription data.
| cb | Callback |
Implements SPSP::FarLayers::MQTT::IAdapter.
Definition at line 68 of file testing/spsp/mqtt_adapter.hpp.
|
virtual |
Sets callback for incoming subscription data.
| cb | Callback |
Implements SPSP::FarLayers::MQTT::IAdapter.
|
virtual |
Sets callback for incoming subscription data.
| cb | Callback |
Implements SPSP::FarLayers::MQTT::IAdapter.
|
inlinestaticprotected |
Helper to convert std::string to C string or nullptr
| str | String |
nullptr, otherwise C string. Definition at line 122 of file espidf/spsp/mqtt_adapter.hpp.
|
inlinestaticprotected |
Helper to convert std::string to C string or nullptr
| str | String |
nullptr, otherwise C string. Definition at line 171 of file linux/spsp/mqtt_adapter.hpp.
|
staticprotected |
Subscription message callback.
Passed to underlaying library.
| ctx | Context |
| topic | Topic |
| topicLen | Length of topic |
| msg | MQTT message |
|
inlinevirtual |
Subscribes to given topic.
| topic | Topic |
Implements SPSP::FarLayers::MQTT::IAdapter.
Definition at line 44 of file testing/spsp/mqtt_adapter.hpp.
|
virtual |
Subscribes to given topic.
This blocks.
| topic | Topic |
Implements SPSP::FarLayers::MQTT::IAdapter.
|
virtual |
Subscribes to given topic.
This blocks.
| topic | Topic |
Implements SPSP::FarLayers::MQTT::IAdapter.
|
inlinevirtual |
Unsubscribes from given topic.
This blocks.
| topic | Topic |
Implements SPSP::FarLayers::MQTT::IAdapter.
Definition at line 58 of file testing/spsp/mqtt_adapter.hpp.
|
virtual |
Unsubscribes from given topic.
This blocks.
| topic | Topic |
Implements SPSP::FarLayers::MQTT::IAdapter.
|
virtual |
Unsubscribes from given topic.
This blocks.
| topic | Topic |
Implements SPSP::FarLayers::MQTT::IAdapter.
1.8.17