SharkSSL C/C++ Reference
TLS, cryptography, certificates, and PSA integration
SharkMQ Struct Reference

#include <SMQ.h>

Public Member Functions

 SharkMQ (U8 *buf, U16 bufLen)
 Create a secure SMQ client instance. More...
 
int init (SharkSslCon *scon, const char *url, U32 *rnd)
 Initiate the SMQ server connection. More...
 
int connect (const char *uid, int uidLen, const char *credentials, U8 credLen, const char *info, int infoLen, U16 maxTlsFrameSize)
 Connect/establish a persistent SMQ connection. More...
 
void disconnect ()
 Gracefully close the connection. More...
 
 ~SharkMQ ()
 Terminate an SMQ instance. More...
 
int create (const char *topic)
 Create a topic an fetch the topic ID (tid). More...
 
int createsub (const char *subtopic)
 Create a sub-topic and fetch the subtopic ID. More...
 
int subscribe (const char *topic)
 The response to SharkMQ_subscribe is asynchronous and returned as status SMQ_SUBACK via SharkMQ_getMessage. More...
 
int unsubscribe (U32 tid)
 Requests the broker to unsubscribe the server from a topic. More...
 
int publish (const void *data, int len, U32 tid, U32 subtid)
 Publish messages to a topic and optionally to a sub-topic. More...
 
int wrtstr (const char *str)
 Publish a message in chunks and request the broker to assemble the message before publishing to the subscriber(s). More...
 
int write (const void *data, int len)
 Publish a message in chunks and request the broker to assemble the message before publishing to the subscriber(s). More...
 
int pubflush (U32 tid, U32 subtid)
 Flush the internal buffer and request the broker to assemble all stored fragments as one message. More...
 
int observe (U32 tid)
 Request the broker to provide change notification events when the number of subscribers to a specific topic changes. More...
 
int unobserve (U32 tid)
 Stop receiving change notifications for a topic ID or ephemeral topic ID. More...
 
int getMessage (U8 **msg)
 Wait for messages sent from the broker. More...
 
int getMsgSize ()
 Returns the message size, which is SMQ::frameLen - 15. More...
 

Data Fields

SOCKET sock
 
SharkSslCon * scon
 
U8 * sharkBuf
 
U8 * buf
 
U16 sharkBufLen
 
U16 sharkBufIx
 
U16 bufLen
 
U16 bufIx
 
U32 timeout
 Timeout in milliseconds to wait in functions waiting for server data. More...
 
S32 pingTmoCounter
 
S32 pingTmo
 
U32 clientTid
 Client's unique topic ID. More...
 
U32 tid
 Topic: set when receiving MSG_PUBLISH from broker. More...
 
U32 ptid
 Publisher's tid: Set when receiving MSG_PUBLISH from broker. More...
 
U32 subtid
 Sub-tid: set when receiving MSG_PUBLISH from broker. More...
 
int status
 Last known error code. More...
 
U16 sendBufIx
 
U16 frameLen
 The SMQ frame size for the incomming data. More...
 
U16 bytesRead
 Read frame data using SharkMQ_getMessage until: frameLen-bytesRead = 0. More...
 

Detailed Description

SharkMQ structure.

Field Documentation

◆ buf

U8* SharkMQ::buf

◆ bufIx

U16 SharkMQ::bufIx

◆ bufLen

U16 SharkMQ::bufLen

◆ bytesRead

U16 SharkMQ::bytesRead

Read frame data using SharkMQ_getMessage until: frameLen-bytesRead = 0.

◆ clientTid

U32 SharkMQ::clientTid

Client's unique topic ID.

◆ frameLen

U16 SharkMQ::frameLen

The SMQ frame size for the incomming data.

◆ pingTmo

S32 SharkMQ::pingTmo

◆ pingTmoCounter

S32 SharkMQ::pingTmoCounter

◆ ptid

U32 SharkMQ::ptid

Publisher's tid: Set when receiving MSG_PUBLISH from broker.

◆ scon

SharkSslCon* SharkMQ::scon

◆ sendBufIx

U16 SharkMQ::sendBufIx

◆ sharkBuf

U8* SharkMQ::sharkBuf

◆ sharkBufIx

U16 SharkMQ::sharkBufIx

◆ sharkBufLen

U16 SharkMQ::sharkBufLen

◆ sock

SOCKET SharkMQ::sock

◆ status

int SharkMQ::status

Last known error code.

◆ subtid

U32 SharkMQ::subtid

Sub-tid: set when receiving MSG_PUBLISH from broker.

◆ tid

U32 SharkMQ::tid

Topic: set when receiving MSG_PUBLISH from broker.

◆ timeout

U32 SharkMQ::timeout

Timeout in milliseconds to wait in functions waiting for server data.