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


Classes | |
| struct | SubDBEntry |
| Client subscribe database entry. More... | |
Public Types | |
| using | LocalAddrT = typename TLocalLayer::LocalAddrT |
| using | LocalMessageT = typename TLocalLayer::LocalMessageT |
Public Member Functions | |
| Client (TLocalLayer *ll, ClientConfig conf={}) | |
| Constructs a new client node. More... | |
| ~Client () | |
| Destroys the client node. 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... | |
| bool | unsubscribe (const std::string &topic) |
| Unsubscribes from topic. More... | |
| void | resubscribeAll () |
| Resubscribes to all topics. More... | |
| bool | syncTime () |
| Synchronizes clock with bridge. 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... | |
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 | sendSubscribe (const std::string &topic) |
| Prepares and sends SUB_REQ message to local layer. More... | |
| void | subDBTick () |
| Subscribe DB timer tick callback. 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 Attributes | |
| std::mutex | m_mutex |
| Mutex to prevent race conditions. | |
| ClientConfig | m_conf |
| Configuration. | |
| WildcardTrie< SubDBEntry > | m_subDB |
| Subscribe database. | |
| Timer | m_subDBTimer |
| Sub DB timer. | |
| bool | m_timeSyncOngoing = false |
| Whether time synchronization is ongoing. | |
| std::promise< bool > | m_timeSyncPromise |
| Time synchronization promise. | |
Client node.
| TLocalLayer | Type of local layer |
Definition at line 77 of file client.hpp.
|
inline |
Constructs a new client node.
| ll | Local layer |
| conf | Configuration |
Definition at line 108 of file client.hpp.
|
inline |
Destroys the client node.
Definition at line 120 of file client.hpp.
|
inlineprotectedvirtual |
Processes PROBE_REQ message.
Doesn't do anything.
| req | Request message |
| rssi | Received signal strength indicator (in dBm) |
Implements SPSP::ILocalNode< TLocalLayer >.
Definition at line 318 of file client.hpp.
|
inlineprotectedvirtual |
Processes PROBE_RES message.
Just publishes RSSI. This is handled internally by concrete local layer.
| req | Request message |
| rssi | Received signal strength indicator (in dBm) |
Implements SPSP::ILocalNode< TLocalLayer >.
Definition at line 332 of file client.hpp.
|
inlineprotectedvirtual |
Processes PUB message.
Doesn't do anything.
| req | Request message |
| rssi | Received signal strength indicator (in dBm) |
Implements SPSP::ILocalNode< TLocalLayer >.
Definition at line 351 of file client.hpp.
|
inlineprotectedvirtual |
Processes SUB_DATA message.
| req | Request message |
| rssi | Received signal strength indicator (in dBm) |
Implements SPSP::ILocalNode< TLocalLayer >.
Definition at line 375 of file client.hpp.
|
inlineprotectedvirtual |
Processes SUB_REQ message.
Doesn't do anything.
| req | Request message |
| rssi | Received signal strength indicator (in dBm) |
Implements SPSP::ILocalNode< TLocalLayer >.
Definition at line 364 of file client.hpp.
|
inlineprotectedvirtual |
Processes TIME_REQ message.
Doesn't do anything.
| req | Request message |
| rssi | Received signal strength indicator (in dBm) |
Implements SPSP::ILocalNode< TLocalLayer >.
Definition at line 415 of file client.hpp.
|
inlineprotectedvirtual |
Processes TIME_RES message.
Synchronizes clock with time in received response.
| req | Request message |
| rssi | Received signal strength indicator (in dBm) |
Implements SPSP::ILocalNode< TLocalLayer >.
Definition at line 428 of file client.hpp.
|
inlineprotectedvirtual |
Processes UNSUB message.
| req | Request message |
| rssi | Received signal strength indicator (in dBm) |
Implements SPSP::ILocalNode< TLocalLayer >.
Definition at line 402 of file client.hpp.
|
inline |
Publishes payload to topic.
This is primary endpoint for publishing locally data on this node. Sends data to the local layer.
| topic | Topic |
| payload | Payload |
Definition at line 136 of file client.hpp.
|
inline |
Resubscribes to all topics.
Definition at line 241 of file client.hpp.
|
inlineprotected |
Prepares and sends SUB_REQ message to local layer.
| topic | Topic |
Definition at line 473 of file client.hpp.
|
inlineprotected |
Subscribe DB timer tick callback.
Decrements subscribe database lifetimes. If any item expires, renews it.
Definition at line 490 of file client.hpp.
|
inline |
Subscribes to topic.
This is primary endpoint for subscribing locally on this node. Directly forwards incoming data from local layer to given callback. Subscribe request is sent to the bridge and extended automatically until unsubscribe() is called.
| topic | Topic |
| cb | Callback function |
Definition at line 168 of file client.hpp.
|
inline |
Synchronizes clock with bridge.
Definition at line 258 of file client.hpp.
|
inline |
Unsubscribes from topic.
This is primary endpoint for unsubscribing locally on this node.
| topic | Topic |
Definition at line 203 of file client.hpp.
1.8.17