|
SPSP
Simple publish-subscribe protocol. Connects low power IoT clients to MQTT.
|
#include <bridge.hpp>


Classes | |
| struct | SubDBEntry |
| Bridge subscribe entry. More... | |
Public Types | |
| using | LocalAddrT = typename TLocalLayer::LocalAddrT |
| using | LocalMessageT = typename TLocalLayer::LocalMessageT |
Public Member Functions | |
| Bridge (TLocalLayer *ll, TFarLayer *fl, BridgeConfig conf={}) | |
| Construct a new bridge object. More... | |
| ~Bridge () | |
| Destroys the bridge node. More... | |
| bool | receiveFar (const std::string &topic, const std::string &payload) |
| Receives the message from far layer. More... | |
| bool | publish (const std::string &topic, const std::string &payload) |
| Publishes payload to topic. More... | |
| bool | subscribe (const std::string &topic, SubscribeCb cb) |
| Subscribes to topic. More... | |
| void | resubscribeAll () |
| Resubscribes to all topics. More... | |
| bool | unsubscribe (const std::string &topic) |
| Unsubscribes from topic. More... | |
Public Member Functions inherited from SPSP::ILocalAndFarNode< TLocalLayer, TFarLayer > | |
| ILocalAndFarNode (TLocalLayer *ll, TFarLayer *fl) | |
| Constructs a new node. More... | |
Public Member Functions inherited from SPSP::ILocalNode< TLocalLayer > | |
| ILocalNode (TLocalLayer *ll) | |
| Constructs a new node. More... | |
| void | receiveLocal (const LocalMessageT &msg, int rssi=NODE_RSSI_UNKNOWN) |
| Receives the message from local layer. More... | |
| void | setLocalRecvSendCb (LocalRecvSendCb cb) |
| Sets local receive/send callback function. More... | |
Public Member Functions inherited from SPSP::IFarNode< TFarLayer > | |
| IFarNode (TFarLayer *fl) | |
| Constructs a new node. More... | |
Protected Types | |
| using | SubDBMapT = std::unordered_map< LocalAddrT, SubDBEntry > |
Protected Member Functions | |
| bool | processProbeReq (const LocalMessageT &req, int rssi=NODE_RSSI_UNKNOWN) |
| Processes PROBE_REQ message. More... | |
| bool | processProbeRes (const LocalMessageT &req, int rssi=NODE_RSSI_UNKNOWN) |
| Processes PROBE_RES message. More... | |
| bool | processPub (const LocalMessageT &req, int rssi=NODE_RSSI_UNKNOWN) |
| Processes PUB message. More... | |
| bool | processSubReq (const LocalMessageT &req, int rssi=NODE_RSSI_UNKNOWN) |
| Processes SUB_REQ message. More... | |
| bool | processSubData (const LocalMessageT &req, int rssi=NODE_RSSI_UNKNOWN) |
| Processes SUB_DATA message. More... | |
| bool | processUnsub (const LocalMessageT &req, int rssi=NODE_RSSI_UNKNOWN) |
| Processes UNSUB message. More... | |
| bool | processTimeReq (const LocalMessageT &req, int rssi=NODE_RSSI_UNKNOWN) |
| Processes TIME_REQ message. More... | |
| bool | processTimeRes (const LocalMessageT &req, int rssi=NODE_RSSI_UNKNOWN) |
| Processes TIME_RES message. More... | |
| bool | publishSubData (const LocalAddrT &addr, const std::string &topic, const std::string &payload) |
| Publishes received subscription data to local layer node. More... | |
| void | subDBTick () |
| Subscribe DB timer tick callback. More... | |
| void | subDBDecrementLifetimes () |
| Decrements lifetimes of entries. More... | |
| void | subDBRemoveExpiredEntries () |
| Removes expired entries. More... | |
| void | subDBRemoveUnusedTopics () |
| Removes and unsubscribes from unused topics. More... | |
Protected Member Functions inherited from SPSP::ILocalNode< TLocalLayer > | |
| TLocalLayer * | getLocalLayer () const |
| Gets the far layer object. More... | |
| bool | sendLocal (const LocalMessageT &msg) |
| Sends the message to local layer. More... | |
| void | publishRssi (const LocalAddrT &addr, int rssi) |
Publishes RSSI of received message from addr More... | |
Protected Member Functions inherited from SPSP::IFarNode< TFarLayer > | |
| TFarLayer * | getFarLayer () const |
| Gets the far layer object. More... | |
Protected Attributes | |
| std::mutex | m_mutex |
| Mutex to prevent race conditions. | |
| BridgeConfig | m_conf |
| Configuration. | |
| WildcardTrie< SubDBMapT > | m_subDB |
| Subscribe database. | |
| Timer | m_subDBTimer |
| Sub DB timer. | |
Bridge node.
It is necessary to have synchronized clock with outside world before bridge construction (from SNTP server), because bridge serves time to clients.
| TLocalLayer | Type of local layer |
| TFarLayer | Type of far layer |
Definition at line 82 of file bridge.hpp.
|
inline |
Construct a new bridge object.
| ll | Local layer |
| fl | Far layer |
| conf | Configuration |
Definition at line 117 of file bridge.hpp.
|
inline |
Destroys the bridge node.
Definition at line 131 of file bridge.hpp.
|
inlineprotectedvirtual |
Processes PROBE_REQ message.
| req | Request message |
| rssi | Received signal strength indicator (in dBm) |
Implements SPSP::ILocalNode< TLocalLayer >.
Definition at line 301 of file bridge.hpp.
|
inlineprotectedvirtual |
Processes PROBE_RES message.
Doesn't do anything.
| req | Request message |
| rssi | Received signal strength indicator (in dBm) |
Implements SPSP::ILocalNode< TLocalLayer >.
Definition at line 336 of file bridge.hpp.
|
inlineprotectedvirtual |
Processes PUB message.
| req | Request message |
| rssi | Received signal strength indicator (in dBm) |
Implements SPSP::ILocalNode< TLocalLayer >.
Definition at line 347 of file bridge.hpp.
|
inlineprotectedvirtual |
Processes SUB_DATA message.
Doesn't do anything.
| req | Request message |
| rssi | Received signal strength indicator (in dBm) |
Implements SPSP::ILocalNode< TLocalLayer >.
Definition at line 416 of file bridge.hpp.
|
inlineprotectedvirtual |
Processes SUB_REQ message.
| req | Request message |
| rssi | Received signal strength indicator (in dBm) |
Implements SPSP::ILocalNode< TLocalLayer >.
Definition at line 372 of file bridge.hpp.
|
inlineprotectedvirtual |
Processes TIME_REQ message.
Responds with TIME_RES message.
| req | Request message |
| rssi | Received signal strength indicator (in dBm) |
Implements SPSP::ILocalNode< TLocalLayer >.
Definition at line 461 of file bridge.hpp.
|
inlineprotectedvirtual |
Processes TIME_RES message.
Doesn't do anything.
| req | Request message |
| rssi | Received signal strength indicator (in dBm) |
Implements SPSP::ILocalNode< TLocalLayer >.
Definition at line 486 of file bridge.hpp.
|
inlineprotectedvirtual |
Processes UNSUB message.
| req | Request message |
| rssi | Received signal strength indicator (in dBm) |
Implements SPSP::ILocalNode< TLocalLayer >.
Definition at line 427 of file bridge.hpp.
|
inline |
Publishes payload to topic.
This is primary endpoint for publishing locally data on this node. Directly sends data to far layer.
| topic | Topic |
| payload | Payload |
Definition at line 187 of file bridge.hpp.
|
inlineprotected |
Publishes received subscription data to local layer node.
| addr | Node address |
| topic | Topic |
| payload | Payload |
Definition at line 498 of file bridge.hpp.
|
inlinevirtual |
Receives the message from far layer.
Acts as a callback for far layer receiver.
| topic | Topic |
| payload | Payload (data) |
Implements SPSP::IFarNode< TFarLayer >.
Definition at line 146 of file bridge.hpp.
|
inline |
Resubscribes to all topics.
Definition at line 244 of file bridge.hpp.
|
inlineprotected |
Decrements lifetimes of entries.
Definition at line 534 of file bridge.hpp.
|
inlineprotected |
Removes expired entries.
Definition at line 553 of file bridge.hpp.
|
inlineprotected |
Removes and unsubscribes from unused topics.
Definition at line 582 of file bridge.hpp.
|
inlineprotected |
Subscribe DB timer tick callback.
Decrements subscribe database lifetimes. Unsubscribes from unused topics.
Definition at line 519 of file bridge.hpp.
|
inline |
Subscribes to topic.
This is primary endpoint for subscribing locally on this node. Directly forwards incoming data from far layer to given callback.
| topic | Topic |
| cb | Callback function |
Definition at line 212 of file bridge.hpp.
|
inline |
Unsubscribes from topic.
This is primary endpoint for unsubscribing locally on this node.
| topic | Topic |
Definition at line 267 of file bridge.hpp.
1.8.17